After adding worker nodes, it is necessary to configure the storage that will be used for creating virtual machine disks and storing cluster component metrics. The storage can be selected from the supported list.
Next, we will consider using software-defined replicated block storage based on DRBD, which allows creating replicated volumes based on the disk space of nodes. As an example, we will configure a StorageClass based on volumes with two replicas, located on the disks /dev/sda.
To run the commands below, you need to have the d8 utility (Deckhouse CLI) installed and a configured kubectl context for accessing the cluster. Alternatively, you can connect to the master node via SSH and run the command as the root user using sudo -i.
Enabling the use of replicated storage
Enable the sds-node-configurator, sds-replicated-volume, and snapshot-controller modules using either the administrator web interface or the CLI:
-
Enable the
sds-node-configuratormodule:sudo -i d8 s module enable sds-node-configurator -
Wait until the
sds-node-configuratormodule reaches theReadystate:d8 k get module sds-node-configurator -w -
Enable the
snapshot-controllermodule:sudo -i d8 s module enable snapshot-controller -
Enable the
sds-replicated-volumemodule:sudo -i d8 s module enable sds-replicated-volume -
Wait until the
sds-replicated-volumemodule reaches theReadystate:sudo -i d8 k wait module sds-replicated-volume --for='jsonpath={.status.status}=Ready' --timeout=1200s -
Verify that in the
d8-sds-node-configurator,d8-snapshot-controller, andd8-sds-replicated-volumenamespaces, all pods are in theRunningorCompletedstatus:sudo -i d8 k -n d8-sds-replicated-volume get pod -owide -w sudo -i d8 k -n d8-sds-node-configurator get pod -owide -w sudo -i d8 k -n d8-sds-node-configurator get pod -owide -w
Configuration of replicated storage
Configuring the storage involves combining the available block devices on the nodes into pools, from which a StorageClass will then be created.
-
Retrieve the available block devices:
d8 k get blockdevices.storage.deckhouse.io
-
Create a VolumeGroup on each node.
On each node, you need to create an LVM volume group using the LVMVolumeGroup resource.
To create the LVMVolumeGroup resource, use the following commands on each node (specify the node name and block device name):
export NODE_NAME="<NODE_NAME>" export DEV_NAME="<BLOCK_DEVICE_NAME>" d8 k apply -f - <<EOF apiVersion: storage.deckhouse.io/v1alpha1 kind: LVMVolumeGroup metadata: name: "vg-on-${NODE_NAME}" spec: type: Local local: nodeName: "$NODE_NAME" blockDeviceSelector: matchExpressions: - key: kubernetes.io/metadata.name operator: In values: - "$DEV_NAME" # The name of the LVM volume group that will be created from the block devices on the selected node. actualVGNameOnTheNode: "vg-1" EOFWait for all the created LVMVolumeGroup resources to transition to the
Readystate:d8 k get lvg -w
-
Create a pool of LVM volume groups.
Created volume groups need to be assembled into a pool for replication (specifies in ReplicatedStoragePool resource). To do this, run the following command (specify the names of the created volume groups):
d8 k apply -f - <<EOF apiVersion: storage.deckhouse.io/v1alpha1 kind: ReplicatedStoragePool metadata: name: sds-pool spec: type: LVM lvmVolumeGroups: # Укажите свои имена групп томов. - name: vg-on-dvp-worker-01 - name: vg-on-dvp-worker-02 - name: vg-on-master EOFWait for the resource to transition to the
Completedstate:d8 k get rsp data -w
-
Set StorageClass parameters.
The
sds-replicated-volumemodule uses the ReplicatedStorageClass resources to automatically create StorageClasses with the required characteristics. The following parameters are important in this resource:replication: Replication parameters, for 2 replicas, the valueAvailabilitywill be used.storagePool: The name of the pool created earlier, in this example, it issds-pool.
Other parameters are described in the ReplicatedStorageClass resource documentation.
d8 k apply -f - <<EOF apiVersion: storage.deckhouse.io/v1alpha1 kind: ReplicatedStorageClass metadata: name: sds-r2 spec: replication: Availability storagePool: sds-pool reclaimPolicy: Delete topology: Ignored EOFCheck that the corresponding StorageClass has appeared in the cluster:
d8 k get sc
-
Set the default StorageClass (specify the name of your StorageClass object):
DEFAULT_STORAGE_CLASS=<DEFAULT_STORAGE_CLASS_NAME> sudo -i d8 k patch mc global --type='json' -p='[{"op": "replace", "path": "/spec/settings/defaultClusterStorageClass", "value": "'"$DEFAULT_STORAGE_CLASS"'"}]'