Install GlusterFS

GlusterFS is an in-tree storage plugin in Kubernetes. Hence, you only need to install the storage class.

This tutorial demonstrates how to use KubeKey to set up a KubeSphere cluster and configure GlusterFS to provide storage services.

Note

Ubuntu 16.04 is used as an example in this tutorial.

Prerequisites

You have set up your GlusterFS cluster and configured Heketi. For more information, see Set up a GlusterFS Server.

Step 1: Configure the Client Machine

You need to install the GlusterFS client package on all your client machines.

  1. Install software-properties-common.

    1. apt-get install software-properties-common
  2. Add the community GlusterFS PPA.

    1. add-apt-repository ppa:gluster/glusterfs-7
  3. Make sure you are using the latest package.

    1. apt-get update
  4. Install the GlusterFS client.

    1. apt-get install glusterfs-server -y
  5. Verify your GlusterFS version.

    1. glusterfs -V

Step 2: Create a Configuration File for GlusterFS

The separate configuration file contains all parameters of GlusterFS storage which will be used by KubeKey during installation.

  1. Go to one of the nodes (taskbox) where you want to download KubeKey later and run the following command to create a configuration file.

    1. vi glusterfs-sc.yaml

    An example configuration file (include a Heketi Secret):

    1. apiVersion: v1
    2. kind: Secret
    3. metadata:
    4. name: heketi-secret
    5. namespace: kube-system
    6. type: kubernetes.io/glusterfs
    7. data:
    8. key: "MTIzNDU2" # Replace it with your own key. Base64 coding.
    9. ---
    10. apiVersion: storage.k8s.io/v1
    11. kind: StorageClass
    12. metadata:
    13. annotations:
    14. storageclass.beta.kubernetes.io/is-default-class: "true"
    15. storageclass.kubesphere.io/supported-access-modes: '["ReadWriteOnce","ReadOnlyMany","ReadWriteMany"]'
    16. name: glusterfs
    17. parameters:
    18. clusterid: "21240a91145aee4d801661689383dcd1" # Replace it with your own GlusterFS cluster ID.
    19. gidMax: "50000"
    20. gidMin: "40000"
    21. restauthenabled: "true"
    22. resturl: "http://192.168.0.2:8080" # The Gluster REST service/Heketi service url which provision gluster volumes on demand. Replace it with your own.
    23. restuser: admin
    24. secretName: heketi-secret
    25. secretNamespace: kube-system
    26. volumetype: "replicate:3" # Replace it with your own volume type.
    27. provisioner: kubernetes.io/glusterfs
    28. reclaimPolicy: Delete
    29. volumeBindingMode: Immediate
    30. allowVolumeExpansion: true

    Note

    • Use the field storageclass.beta.kubernetes.io/is-default-class to set glusterfs as your default storage class. If it is false, KubeKey will install OpenEBS as the default storage class.
    • For more information about parameters in the storage class manifest, see the Kubernetes documentation.
  2. Save the file.

Step 3: Download KubeKey

Follow the steps below to download KubeKey on the taskbox.

Download KubeKey from its GitHub Release Page or use the following command directly.

  1. curl -sfL https://get-kk.kubesphere.io | VERSION=v2.2.1 sh -

Run the following command first to make sure you download KubeKey from the correct zone.

  1. export KKZONE=cn

Run the following command to download KubeKey:

  1. curl -sfL https://get-kk.kubesphere.io | VERSION=v2.2.1 sh -

Note

After you download KubeKey, if you transfer it to a new machine also with poor network connections to Googleapis, you must run export KKZONE=cn again before you proceed with the steps below.

Note

The commands above download the latest release (v2.2.1) of KubeKey. You can change the version number in the command to download a specific version.

Make kk executable:

  1. chmod +x kk

Step 4: Create a Cluster

  1. Specify a Kubernetes version and a KubeSphere version that you want to install. For example:

    1. ./kk create config --with-kubernetes v1.22.10 --with-kubesphere v3.3.0

    Note

    • Recommended Kubernetes versions for KubeSphere 3.3.0: v1.19.x, v1.20.x, v1.21.x, v1.22.x, and v1.23.x (experimental support). If you do not specify a Kubernetes version, KubeKey will install Kubernetes v1.23.7 by default. For more information about supported Kubernetes versions, see Support Matrix.

    • If you do not add the flag --with-kubesphere in the command in this step, KubeSphere will not be deployed unless you install it using the addons field in the configuration file or add this flag again when you use ./kk create cluster later.

    • If you add the flag --with-kubesphere without specifying a KubeSphere version, the latest version of KubeSphere will be installed.

  2. A default file config-sample.yaml will be created if you do not customize the name. Edit the file.

    1. vi config-sample.yaml
    1. ...
    2. metadata:
    3. name: sample
    4. spec:
    5. hosts:
    6. - {name: client1, address: 192.168.0.5, internalAddress: 192.168.0.5, user: ubuntu, password: Testing123}
    7. - {name: client2, address: 192.168.0.6, internalAddress: 192.168.0.6, user: ubuntu, password: Testing123}
    8. - {name: client3, address: 192.168.0.7, internalAddress: 192.168.0.7, user: ubuntu, password: Testing123}
    9. roleGroups:
    10. etcd:
    11. - client1
    12. control-plane:
    13. - client1
    14. worker:
    15. - client2
    16. - client3
    17. controlPlaneEndpoint:
    18. domain: lb.kubesphere.local
    19. address: ""
    20. port: 6443
    21. kubernetes:
    22. version: v1.21.5
    23. imageRepo: kubesphere
    24. clusterName: cluster.local
    25. network:
    26. plugin: calico
    27. kubePodsCIDR: 10.233.64.0/18
    28. kubeServiceCIDR: 10.233.0.0/18
    29. registry:
    30. registryMirrors: []
    31. insecureRegistries: []
    32. addons:
    33. - name: glusterfs
    34. namespace: kube-system
    35. sources:
    36. yaml:
    37. path:
    38. - /root/glusterfs-sc.yaml
    39. ...
  3. Pay special attention to the field of addons, under which you must provide the information of the storage class to be created as well as the Heketi Secret. For more information about each parameter in this file, see Multi-node Installation.

  4. Save the file and execute the following command to install Kubernetes and KubeSphere:

    1. ./kk create cluster -f config-sample.yaml
  5. When the installation finishes, you can inspect installation logs with the following command:

    1. kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l 'app in (ks-install, ks-installer)' -o jsonpath='{.items[0].metadata.name}') -f

    Expected output:

    1. #####################################################
    2. ### Welcome to KubeSphere! ###
    3. #####################################################
    4. Console: http://192.168.0.4:30880
    5. Account: admin
    6. Password: [email protected]
    7. NOTES
    8. 1. After you log into the console, please check the
    9. monitoring status of service components in
    10. "Cluster Management". If any service is not
    11. ready, please wait patiently until all components
    12. are up and running.
    13. 2. Please change the default password after login.
    14. #####################################################
    15. https://kubesphere.io 20xx-xx-xx xx:xx:xx
    16. #####################################################

Step 5: Verify Installation

You can verify that GlusterFS has been successfully installed either from the command line or from the KubeSphere web console.

Command line

Run the following command to check your storage class.

  1. kubectl get sc

Expected output:

  1. NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
  2. glusterfs (default) kubernetes.io/glusterfs Delete Immediate true 104m

KubeSphere console

  1. Log in to the web console with the default account and password (admin/[[email protected]](https://kubesphere.io/cdn-cgi/l/email-protection)) at <NodeIP>:30880. Click Platform in the upper-left corner and select Cluster Management.

  2. Go to Volumes under Storage, and you can see PVCs in use.

    Note

    For more information about how to create volumes on the KubeSphere console, see Volumes.

  3. On the Storage Classes page, you can see the storage class available in your cluster.