In disk planning and striped logical disk creation, it is difficult for users to flexibly attach and partition disks when creating a node.
During node creation, the storage field selects a data disk based on parameters, such as the disk size and disk type, to prevent failures in node creation, resetting, migration, and management caused by drive letter matching failures.
This section provides details about the storage field used in node creation so that you can implement complex disk selection and partitioning by calling the node creation API.
The storage field consists of storageSelectors and storageGroups. The storageSelectors field is responsible for disk selection, and the storageGroups field is responsible for disk processing.
The basic logic for field matching is as follows:
During node creation on the CCE console, click Add Data Disk. Then, click Expand next to the newly added data disk and select Default. The created disk is a raw disk.
The following figure shows the API calling logic.
After the node is created, log in to the node and check whether a 100 GiB disk has been attached but not initialized.
The following is an API example:
{
"kind": "Node",
"apiVersion": "v3",
"metadata": {
"name": "test-83790"
},
"spec": {
"flavor": "c3.large.2",
"az": "eu-de-01",
"os": "EulerOS 2.9",
"dataVolumes": [
{
"size": 100,
"volumetype": "SAS"
},
{
"size": 100,
"volumetype": "SAS"
}
],
"billingMode": 0,
"extendParam": {
"maxPods": 110
},
"nodeNicSpec": {
"primaryNic": {
"subnetId": "ca964acf-8468-4735-8229-97940ef6c881"
}
},
"rootVolume": {
"size": 50,
"volumetype": "SAS"
},
"runtime": {
"name": "docker"
},
"login": {
"userPassword": {
"username": "root",
"password": "******"
}
},
"storage": {
"storageSelectors": [
{
"name": "cceUse",
"storageType": "evs",
"matchLabels": {
"size": "100",
"volumeType": "SAS",
"count": "1"
}
}
],
"storageGroups": [
{
"name": "vgpaas",
"selectorNames": [
"cceUse"
],
"cceManaged": true,
"virtualSpaces": [
{
"name": "runtime",
"size": "90%"
},
{
"name": "kubernetes",
"size": "10%"
}
]
}
]
},
"count": 1
}
}
During node creation on the CCE console, click Add Data Disk. Then, click Expand next to the newly added data disk, select Mount Disk, and set the mount path. In this case, CCE initializes and attaches the disk by default.
The following figure shows the API calling logic.
After the node is created, log in to the node and check whether a 100 GiB disk has been attached and managed by LVM.
The following is an API example. There are two data disks. One is used by CCE, and the other is mounted to the /tmp2 directory.
{
"kind": "Node",
"apiVersion": "v3",
"metadata": {
"name": "test-37106"
},
"spec": {
"flavor": "c3.large.2",
"az": "eu-de-01",
"os": "EulerOS 2.9",
"dataVolumes": [
{
"size": 100,
"volumetype": "SAS"
},
{
"size": 100,
"volumetype": "SAS"
}
],
"billingMode": 0,
"extendParam": {
"maxPods": 110
},
"nodeNicSpec": {
"primaryNic": {
"subnetId": "ca964acf-8468-4735-8229-97940ef6c881"
}
},
"rootVolume": {
"size": 50,
"volumetype": "SAS"
},
"runtime": {
"name": "docker"
},
"login": {
"userPassword": {
"username": "root",
"password": "******"
}
},
"storage": {
"storageSelectors": [
{
"name": "cceUse",
"storageType": "evs",
"matchLabels": {
"size": "100",
"volumeType": "SAS",
"count": "1"
}
},
{
"name": "user1",
"storageType": "evs",
"matchLabels": {
"size": "100",
"volumeType": "SAS",
"count": "1"
}
}
],
"storageGroups": [
{
"name": "vgpaas",
"selectorNames": [
"cceUse"
],
"cceManaged": true,
"virtualSpaces": [
{
"name": "runtime",
"size": "80%"
},
{
"name": "kubernetes",
"size": "20%"
}
]
},
{
"name": "vguser1",
"selectorNames": [
"user1"
],
"virtualSpaces": [
{
"name": "user",
"size": "100%",
"lvmConfig": {
"lvType": "linear",
"path": "/tmp2"
}
}
]
}
]
},
"count": 1
}
}
Currently, the striped LV function is supported only by calling an API. The following is an example:
Log in to the node and run the following command to view the striping result:
The following is an API example:
{
"kind": "Node",
"apiVersion": "v3",
"metadata": {
"name": "test-83773"
},
"spec": {
"flavor": "c3.large.2",
"az": "eu-de-01",
"os": "EulerOS 2.9",
"dataVolumes": [
{
"size": 100,
"volumetype": "SAS"
},
{
"size": 100,
"volumetype": "SAS"
}
],
"billingMode": 0,
"extendParam": {
"maxPods": 110
},
"nodeNicSpec": {
"primaryNic": {
"subnetId": "ca964acf-8468-4735-8229-97940ef6c881"
}
},
"rootVolume": {
"size": 50,
"volumetype": "SAS"
},
"runtime": {
"name": "docker"
},
"login": {
"userPassword": {
"username": "root",
"password": "******"
}
},
"storage": {
"storageSelectors": [
{
"name": "cceUse",
"storageType": "evs"
}
],
"storageGroups": [
{
"name": "vgpaas",
"selectorNames": [
"cceUse"
],
"cceManaged": true,
"virtualSpaces": [
{
"name": "runtime",
"size": "90%",
"runtimeConfig": {
"lvType": "striped"
}
},
{
"name": "kubernetes",
"size": "10%",
"lvmConfig": {
"lvType": "striped"
}
}
]
}
]
},
"count": 1
}
}