You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/plugins/cloudstack-kubernetes-service.rst
+244-7Lines changed: 244 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,8 @@ The Kubernetes Service plugin adds Kubernetes integration to CloudStack. The plu
18
18
With CoreOS having reached EOL, from 4.16 the Kubernetes Service Plugin will use the existing SystemVM Template by default for deploying kubernetes clusters. For installation of Kubernetes binaries on the cluster nodes, a binaries ISO is used for each Kubernetes version to be made available via CloudStack. This allows faster, offline installation of Kubernetes binaries and docker images along with support for adding multiple versions of Kubernetes for upgrades and running different clusters.
19
19
20
20
.. note::
21
-
Since version 4.21.0 users can choose different templates for different types of nodes (worker, control, etcd nodes) for deploying Kubernetes clusters. These templates must be previously registered selecting the 'For CKS' option.
21
+
Since version 4.21.0 users can choose different templates and service offerings for different types of nodes (worker, control, etcd nodes) for deploying Kubernetes clusters. The templates must be previously registered selecting the 'For CKS' option.
22
+
See :ref:`flexible-kubernetes-clusters`.
22
23
23
24
For deployment and setup of Kubernetes on cluster nodes, the plugin uses the Kubernetes tool, 'kubeadm'. kubeadm is the command-line tool for easily provisioning a secure Kubernetes cluster on top of physical or cloud servers or Instances. Under the hood, control node(s) of the cluster starts a Kubernetes cluster using kubeadm init command with a custom token, and worker nodes join this Kubernetes cluster using kubeadm join command with the same token. More about kubeadm here: https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm/. Weave Net CNI provider plugin is used for cluster networking. More about Weave Net provide plugin here: https://www.weave.works/docs/net/latest/kubernetes/kube-addon/.
24
25
@@ -48,6 +49,8 @@ Once the Kubernetes service is running the new APIs will become accessible and t
48
49
**NOTE:**
49
50
From ACS 4.16 onwards, if a CKS cluster is to be deployed on VMware, the 'vmware.create.full.clone' configuration parameter will need to be set to true, so as to allow resizing of root volumes of the cluster nodes.
From ACS 4.16 onwards, Kubernetes versions >= 1.20.x are only supported (https://endoflife.date/kubernetes).
87
90
91
+
**NOTE:**
92
+
From ACS 4.21 onwards, it is possible specify the version for etcd binaries on the create-kubernetes-binaries-iso.sh script as an optional parameter ETCD_VERSION. When the ETCD_VERSION parameter is set, the specified etcd version binaries are downloaded and stored on the /etcd directory on the Kubernetes ISO.
The Kubernetes ISOs generated with an specific etcd version are required to create separate etcd nodes on Kubernetes clusters. See :ref:`flexible-kubernetes-clusters`.
101
+
88
102
Working with Kubernetes supported version
89
103
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
90
104
@@ -96,7 +110,8 @@ Once the ISO has been built for a desired Kubernetes version, it can be added by
96
110
|cks-add-version-form.png|
97
111
98
112
.. note::
99
-
Since 4.21.0 it is possible to deploy separate dedicated etcd nodes. This requires the Kubernetes ISO contains the etcd binaries.
113
+
Since 4.21.0 it is possible to deploy separate dedicated etcd nodes. This requires
114
+
the Kubernetes ISO contains the etcd binaries.
100
115
101
116
addKubernetesSupportedVersion API can be used by an admin to add a new supported version for the service. It takes following input parameters:
102
117
@@ -200,11 +215,15 @@ New Kubernetes clusters can be created using the API or via the UI. User will be
200
215
201
216
|cks-create-cluster-form.png|
202
217
203
-
Since 4.21.0, users will be provided with an additional section displayed when toggling the option: 'Show Advanced Settings'. On this section, users can select templates and service offerings for:
218
+
Since 4.21.0, the Hypervisor selection is available for Kubernetes Cluster nodes. By default the Hypervisor selection is empty.
219
+
220
+
Since 4.21.0, users will be provided with an optional section displayed when toggling the option: 'Show Advanced Settings'. On this section, users can select templates and service offerings for:
204
221
- Worker nodes
205
222
- Control nodes
206
223
- Etcd nodes (if one or more are selected, no etcd nodes are selected by default)
207
224
225
+
For more information about the Advanced Settings see :ref:`flexible-kubernetes-clusters`.
226
+
208
227
|cks-create-cluster-additional-settings.png|
209
228
210
229
createKubernetesCluster API can be used to create new Kubernetes cluster. It takes following parameters as input,
@@ -228,9 +247,13 @@ createKubernetesCluster API can be used to create new Kubernetes cluster. It tak
228
247
- **dockerregistrypassword** (password for the docker image private registry; Experimental)
229
248
- **dockerregistryurl** (URL for the docker image private registry; Experimental)
230
249
- **dockerregistryemail** (email of the docker image private registry user; Experimental)
231
-
- **nodeofferings**: an optional map parameter to set the service offerings for worker, control or etcd nodes. If this parameter is not set, then every VM in the cluster will be deployed using the default service offering set on the serviceofferingid parameter.
232
-
- **etcdnodes**: an optional integer parameter to specify the number etcd nodes in the cluster, the default value is 0. In case the number is greater than 0, etcd nodes are separate from master nodes and are provisioned accordingly.
233
-
- **nodetemplates**: an optional map parameter to set the template to be used by worker, control or etcd nodes. If this parameter is not set, then every VM in the cluster will be deployed using the System VM template.
250
+
- **hypervisor** (an optional parameter to specify the hypervisor on which the Kubernetes cluster will be deployed)
251
+
- **nodeofferings** (an optional map parameter to set the service offerings for worker, control or etcd nodes. If this parameter is not set, then every VM in the cluster will be deployed using the default service offering set on the serviceofferingid parameter)
252
+
- **etcdnodes** (an optional integer parameter to specify the number etcd nodes in the cluster, the default value is 0. In case the number is greater than 0, etcd nodes are separate from master nodes and are provisioned accordingly)
253
+
- **nodetemplates**: (an optional map parameter to set the template to be used by worker, control or etcd nodes. If this parameter is not set, then every VM in the cluster will be deployed using the System VM template)
254
+
- **asnumber** (an optional parameter to set the AS Number of the Kubernetes cluster network)
255
+
- **cniconfigurationid** (an optional parameter to set the UUID of a registered CNI configuration)
256
+
- **cniconfigdetails** (an optional parameter to specify the parameters values for the variables in the CNI configuration)
234
257
235
258
For example:
236
259
@@ -421,6 +444,220 @@ To remove an Instance from an ExternalManaged Kubernetes cluster:
421
444
These operations are only supported for an ExternalManaged Kubernetes Cluster
422
445
423
446
447
+
.. _flexible-kubernetes-clusters:
448
+
449
+
Flexible Kubernetes Clusters
450
+
----------------------------
451
+
452
+
Since 4.21.0, CloudStack introduces many enhancements to Kubernetes Clusters allowing users to:
453
+
454
+
- Select the Hypervisor hype for the Kubernetes Cluster nodes
455
+
- Specify different templates and/or service offerings for different types of Kubernetes Clusters nodes
456
+
- Use CKS-ready custom and non-ready templates for Kubernetes cluster nodes
457
+
- Separate etcd nodes from control nodes of the Kubernetes clusters
458
+
- Add and remove a pre-created instance as a worker node to an existing Kubernetes cluster
459
+
- Mark Kubernetes cluster nodes for manual-only upgrade
460
+
- Dedicate specific hosts/clusters to a specific domain for CKS cluster deployment
461
+
- Use diverse CNI plugins (Calico, Cilium, etc)
462
+
463
+
Build a custom template to use for Kubernetes clusters nodes
CloudStack provides a custom CKS-ready template based on Ubuntu 22.04 to be used for Kubernetes clusters nodes: https://download.cloudstack.org/testing/custom_templates/ubuntu/22.04/.
467
+
468
+
This template contains all the required packages to be used as a Kubernetes cluster node. The default login credentials are: cloud:cloud.
469
+
470
+
A user may decide not to use the provided CKS-ready template and build its own template. The following needs to be made sure is present on the template:
471
+
472
+
- The following packages or the equivalent ones for the specific OS need to be installed:
By default, the Kubernetes clusters nodes are deployed from the System VM template. On the Advanced Settings for Kubernetes clusters creation, CloudStack allows selecting templates for different types of nodes.
501
+
502
+
To register a template that will be listed as an option for Kubernetes cluster nodes:
503
+
504
+
- Set URL to the provided CKS-ready template at: https://download.cloudstack.org/testing/custom_templates/ubuntu/22.04/ or a custom template built from the section above.
505
+
506
+
- Set the template specific values as usual for template registration.
507
+
508
+
- Mark the option 'For CKS'. This ensures the template is considered as an option for Kubernetes cluster nodes on the Advanced Settings section for clusters creation.
509
+
510
+
511
+
Separate etcd nodes from control nodes
512
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
513
+
514
+
By default, the number of etcd nodes in a CKS cluster is 0, the etcd service is included on the control nodes. If the number of etcd nodes passed on the CKS cluster creation is at least 1, then CloudStack will dedicate nodes only to the etcd service, separating them from the control nodes.
515
+
516
+
To use separate etcd nodes, it is required to build and register a CKS ISO version containing the etcd service as explained on: :ref:`kubernetes-supported-versions`
517
+
518
+
Add an external VM Instance as a worker node to a Kubernetes cluster
Requirements for a VM Instance to be added as worker node to a Kubernetes cluster:
522
+
523
+
- At least 8GB ROOT disk size, 2 CPU cores and 2GB RAM
524
+
525
+
- The VM Instance must have a NIC on the Kubernetes cluster network
526
+
527
+
- The Management Server’s SSH Public key must be added at the cloud user’s authorized_keys file at `~/.ssh/authorized_keys`.
528
+
529
+
The VM Instances meeting the requirements above must be added to the Kubernetes cluster by the `addNodesToKubernetesCluster` API specifying:
530
+
531
+
- **id** (UUID of the Kubernetes cluster. Required)
532
+
- **nodeids** (comma separated list of (external) node (physical or virtual machines) IDs that need to be added as worker nodes to an existing managed Kubernetes cluster (CKS). Required)
533
+
- **mountcksisoonvr** (optional parameter for Vmware only, uses the CKS cluster network VR to mount the CKS ISO)
534
+
- **manualupgrade** (optional parameter that indicates if the node is marked for manual upgrade and excluded from the Kubernetes cluster upgrade operation)
535
+
536
+
.. note::
537
+
Users are able to add nodes to Kubernetes cluster and mark them for manual upgrade only. Once the nodes are marked for manual upgrade, the future cluster upgrade operations will exclude these nodes and their Kubernetes version won't be upgraded.
538
+
539
+
The following course of actions are taken:
540
+
541
+
- Validation: The external node(s) are validated to ensure that all the above-mentioned prerequisites are present
542
+
543
+
- Addition of port-forwarding rules and firewall rules (for isolated networks)
544
+
545
+
- VM is rebooted with the Kubernetes config passed as userdata
546
+
547
+
- The ISO is attached either to the node or to the VR based on the value of `mountcksisoonvr` that is passed as a parameter to the addNodesToKubernetesCluster API (Vmware only).
548
+
549
+
- The cluster enters Importing state until all the nodes are successfully added, and the number of Ready nodes is equal to the expected number of nodes to be added.
550
+
551
+
- The process timeout is set by the setting: `cloud.kubernetes.cluster.add.node.timeout`.
552
+
553
+
Removing an external worker node from a Kubernetes cluster
External worker nodes must be removed from a Kubernetes cluster by the `removeNodesFromKubernetesCluster` API specifying:
557
+
558
+
- **id** (UUID of the Kubernetes cluster. Required)
559
+
- **nodeids** (comma separated list of (external) node (physical or virtual machines) IDs that need to be removed from an existing managed Kubernetes cluster (CKS). Required)
560
+
561
+
When node(s) are being removed from a Kubernetes cluster, the following happens:
562
+
563
+
- On the control node, drain the specific node before it can be removed
564
+
565
+
- Reset the corresponding worker node
566
+
567
+
- Delete the worker node from the cluster on the control node
568
+
569
+
- Remove the port-forwarding and firewall rules (for isolated networks) for the nodes being removed
570
+
571
+
- The cluster enters RemovingNodes state until all the nodes are successfully removed, and the number of Ready nodes is equal to the expected number of nodes
572
+
573
+
- The process timeout is set by the setting: `cloud.kubernetes.cluster.remove.node.timeout`.
574
+
575
+
Dedicate specific hosts/clusters to a specific domain for CKS cluster deployment
Administratos are able to dedicate hosts to a domain or account. CloudStack will take the host dedication in consideration when deploying Kubernetes clusters.
579
+
580
+
- When there are no hosts dedicated to the domain/account the user belongs, then the nodes will be deployed on any host.
581
+
582
+
- When there are hosts dedicated to the domain/account the user belongs, then the nodes will be deployed on the dedicated hosts.
583
+
584
+
.. note::
585
+
By design the hosts dedication does not consider the deployment of system VMs on the dedicated hosts (SSVM, CPVM and Virtual Routers). In case the Kubernetes cluster is created on an unimplemented network then the Virtual Router of the network will not be deployed on the dedicated hosts.
586
+
587
+
Use diverse CNI plugins (Calico, Cilium, etc)
588
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
589
+
590
+
A CNI framework has also been added which provides end users the flexibility to use the CNI plugin of their choice. The CNI framework internally leverages the managed Userdata feature provided by CloudStack.
591
+
592
+
Sample Calico CNI configuration data used which is appended to the existing Kubernetes control node userdata is:
0 commit comments