cluster-api-vsphere

by labo-pe

Helm chartv4.1.5App 1.2.0

Helm chart to create kubernetes cluster using [cluster-api](https://github.com/kubernetes-sigs/cluster-api) and its [vsphere provider](https://github.com/kubernetes-sigs/cluster-api-provider-vsphere)

About this chart

cluster-api-vsphere

Helm chart to create kubernetes cluster using cluster-api and its vsphere provider

TL;DR

$ helm repo add cluster-api-vsphere https://labo-pe.gitlab.io/capv-helm-chart/
$ helm show values cluster-api-vsphere/cluster-api-vsphere

Issues and contributions

Source code and issues for this helm chart are hosted on gitlab :

Prerequisites

  • cluster-api 1.1+
  • cluster-api-provider-vsphere 1.2+

Values

KeyTypeDefaultDescription
commonLabelsobject{}Labels to add to all objects generated by this chart
commonAnnotationsobject{}Annotations to add to all objects generated by this chart
wait.clusterboolfalseDeploy a job waiting for machines to rollout after deployment
wait.apiServerboolfalseDeploy a job waiting for apiServer to be available
wait.timeoutint900max time waiting for resources to rollout
cluster.namestring""Cluster name. If unset, the release name will be used
cluster.controlPlaneEndpoint.hoststring""IP or DNS name of the kubernetes endpoint
cluster.controlPlaneEndpoint.portint6443Kubernetes endpoint port
cluster.controlPlaneEndpoint.interfacestring""Linux interface on the node
cluster.podCidrBlockslist["19.0.0.0/16"]Network CIDR for pods
cluster.servicesCidrBlockslist["56.0.0.0/16"]Network CIDR for services
cluster.additionalClusterResourceSetlist[]Additionnal ClusterResource to add to ClusterResourceSet
kubernetes.versionstring"v1.24.7"Version of kubernetes
kubernetes.additionnalClientCaFilestring""Pem encoded certificate to authenticate clients over x509
kubernetes.kubeadm.commonKubeletExtraArgsobject{}Additional kubelet command line arguments for init and join configurations
kubernetes.kubeadm.controlPlane.clusterConfigurationobject{}Kubeadm cluster configuration, more info : https://kubernetes.io/docs/reference/config-api/kubeadm-config.v1beta3/
kubernetes.kubeadm.controlPlane.additionalFileslist[]Additional files to create on the kubeadm control plane instances
kubernetes.kubeadm.controlPlane.preKubeadmAdditionalCommandslist[]Additional commands to execute on control plane before kubeadm join/init
kubernetes.kubeadm.controlPlane.postKubeadmAdditionalCommandslist[]Additional commands to execute on control plane after kubeadm join/init
kubernetes.kubeadm.controlPlane.patchesDirectorystring""Directory containing kubeadm patches on target vms
kubernetes.kubeadm.workers.fileslist[]files to create on the workers instances
kubernetes.kubeadm.workers.preKubeadmAdditionalCommandslist[]Additional commands to execute on workers before kubeadm join/init
kubernetes.kubeadm.workers.postKubeadmAdditionalCommandslist[]Additional commands to execute on workers after kubeadm join/init
machines.dhcp4booltrueUse dhcp for ipv4 configuration
machines.addressesFromPoolsobject{"enabled":false,"providers":[]}Use an IPAMProvider pool to reserve IPs
machines.addressesFromPools.enabledboolfalseEnable the IPAMProvider usage
machines.addressesFromPools.providerslist[]List of providers to reserve IPs from
machines.nameServerslist[]Nameservers for VMs DNS resolution
machines.searchDomainslist[]Search domains suffixes to configure on VMs
machines.domainstring""VM network domain
machines.gatewaystring""IPv4 gateway
machines.userslist[]users to create on machines see https://github.com/kubernetes-sigs/cluster-api/blob/main/bootstrap/kubeadm/api/v1beta1/kubeadmconfig_types.go#L257 for documentation about user config object
machines.controlPlane.annotationsobject{}Control plane VsphereMachineTemplate annotations
machines.controlPlane.replicasint3Number of control plane VMs instances
machines.controlPlane.kubeVipVersionstring"v0.5.5"kube-vip version
machines.controlPlane.ipAddrslist[]ipaddrs passed to capi if necessary
machines.controlPlane.criSocketstring"/var/run/containerd/containerd.sock"Path of the CRI socket to use
machines.controlPlane.resourcePoolstring""Control plane VSphere resource pool
machines.controlPlane.templatestring""Control plane VSphere machine template to clone, must contain kubeadm at the same version as specified in kubernetes.version
machines.controlPlane.folderstring""Control plane VSphere folder to store VM
machines.controlPlane.storagePolicystring""Control plane VSphere storage policy name to use for disks
machines.controlPlane.dataStorestring""Control plane VSphere datastore to create/locate machine
machines.controlPlane.cpuCountint2Control plane Number of vCPUs to allocate to controlPlane instances
machines.controlPlane.diskSizeGiBint40Control plane Disk size of VM in GiB
machines.controlPlane.memorySizeMiBint4096Control plane Memory to allocate to controlPlane VMs
machines.controlPlane.kubeletExtraArgsobject{}Additional kubelet command line arguments for join configurations
machines.controlPlane.nodeDrainTimeoutstring""Node drain timeout is the total amount of time that the controller will spend on draining a node
machines.controlPlane.machineHealthCheck.enabledboolfalseDeploys a machineHealthCheck object for the controlPlane
machines.controlPlane.machineHealthCheck.maxUnhealthystring"100%"Any further remediation is only allowed if at most "MaxUnhealthy" machines are not healthy
machines.controlPlane.machineHealthCheck.nodeStartupTimeoutstring""Machines older than this duration without a node will be considered to have failed and will be remediated
machines.controlPlane.machineHealthCheck.unhealthyConditionslist[{"status":"Unknown","timeout":"300s","type":"Ready"},{"status":"False","timeout":"300s","type":"Ready"}]list of the conditions that determine whether a node is considered unhealthy. if any of the conditions is met, the node is unhealthy.
machines.controlPlane.machineHealthCheck.unhealthyRangestring""remediation is only allowed if the number of machines selected by "selector" as not healthy is within the range of "UnhealthyRange"
machines.workersobject{}Worker pools, more details on its configuration in Worker pools configuration
vsphere.dataCenterstring""Datacenter to use
vsphere.networkstring""VSphere network for VMs and CSI
vsphere.usernamestring""Vsphere username
vsphere.passwordstring""VSphere password
vsphere.serverstring""VSphere server dns name
vsphere.tlsThumbprintstring""VSphere https TLS thumbprint
vsphereCsi.enabledbooltrueInstalls vsphere-csi on the cluster
vsphereCsi.cloudControllerManager.resourcesobject{"requests":{"cpu":"200m"}}resources of vsphere-cloud-controller-manager
vsphereCsi.controller.csiAttacher.resourcesobject{}resources of the container csi-attacher in vsphere-csi-controller
vsphereCsi.controller.csiResizer.resourcesobject{}resources of the container csi-resizer in vsphere-csi-controller
vsphereCsi.controller.vsphereCsiController.resourcesobject{}resources of the container vsphere-csi-controller in vsphere-csi-controller
vsphereCsi.controller.vsphereSyncer.resourcesobject{}resources of the container vsphere-syncer in vsphere-csi-controller
vsphereCsi.controller.csiProvisioner.resourcesobject{}resources of the container csi-provisioner in vsphere-csi-controller
vsphereCsi.controller.csiSnapshotter.resourcesobject{}resources of the container csi-snapshotter in vsphere-csi-controller
vsphereCsi.controller.livenessProbe.resourcesobject{}resources of the container liveness-probe in vsphere-csi-controller
vsphereCsi.node.nodeDriverRegistrar.resourcesobject{}resources of the container node-driver-registrar in vsphere-csi-node
vsphereCsi.node.vsphereCsiNode.resourcesobject{}resources of the container vsphere-csi-node in vsphere-csi-node
vsphereCsi.node.livenessProbe.resourcesobject{}resources of the container liveness-probe in vsphere-csi-node
storageClass.enabledboolfalseCreate storage class
storageClass.namestring"default"Storage class name
storageClass.defaultbooltrueDefine storage class as default class
storageClass.reclaimPolicystring"Delete"Storage class reclaimPolicy
storageClass.fsTypestring"ext4"Storage class fsType
storageClass.storagePolicystring""VSphere Storage policy
cni.calico.enabledboolfalseInstalls cni calico on the cluster
cni.calico.configstring""specific config for calico, see https://projectcalico.docs.tigera.io/getting-started/kubernetes/installation/config-options

About this chart

Application version

The application version of this chart reflect the supported version of the cluster api provider vsphere

Configuration and installation details

cluster upgrade

This chart creates a VSphereMachineTemplate for the control-plane and another one for the workers. Each of those are named with a sha256 identifier which will change if their content is modified.

During a helm upgrade, the new VSphereMachineTemplates will be created, the KubeadmControlPlane and MachineDeployment will be updated with the new names and trigger a RollingUpdate.

In other words :

  • Change the values
  • Launch an upgrade
  • Wait and see your cluster being updated

note: The control-plane old template is removed at deployment, but not the deployment templates, as, after upgrade, the old MachineSets still references the them

Worker pools configuration

You can configure as many worker pools as desired, the value machines.workers takes a map in which each key is the worker pool name :

exemple:

# -- Name of the worker pool, you can define as many others pools as desired
worker-md-0:
  # -- Number of worker VMs instances
  replicas: 1
  # -- MachineDeployment annotations
  machineDeploymentAnnotations: {}
  # -- Labels to add to the machines created by the machineDeployment
  machinesLabels: {}
  # -- Labels to add to the machineDeployment selector to match the machines
  machinesSelectors: {}
  # -- workers VsphereMachineTemplate annotations
  annotations: {}
  # -- ipaddrs passed to capi if necessary
  ipAddrs: []
  # -- Path of the CRI socket to use
  criSocket: "/var/run/containerd/containerd.sock"
  # -- workers VSphere resource pool
  resourcePool: ""
  # -- workers VSphere machine template to clone, must contain kubeadm at the same version as specified in kubernetes.version
  template: ""
  # -- workers VSphere folder to store VM
  folder: ""
  # -- workers VSphere storage policy name to use for disks
  storagePolicy: ""
  # -- workers VSphere datastore to create/locate machine
  dataStore: ""
  # -- Number of vCPUs to allocate to worker instances
  cpuCount: 4
  # -- disk size of workers VM in GiB
  diskSizeGiB: 100
  # -- Memory to allocate to worker VMs
  memorySizeMiB: 8192
  # -- files to create on the workers instances of this pool
  files: []
  # -- Additional commands to execute on workers before kubeadm join/init on this pool
  preKubeadmAdditionalCommands: []
  # -- Additional commands to execute on workers after kubeadm join/init on this pool
  postKubeadmAdditionalCommands: []
  # -- Additional kubelet command line arguments for join configurations
  kubeletExtraArgs: {}
  # -- Node drain timeout is the total amount of time that the controller will spend on draining a node
  nodeDrainTimeout: ""
  machineHealthCheck:
    # -- Deploys a machineHealthCheck object for the workerPool
    enabled: false
    # -- Any further remediation is only allowed if at most "MaxUnhealthy" machines are not healthy
    maxUnhealthy: ""
    # -- Machines older than this duration without a node will be considered to have failed and will be remediated
    nodeStartupTimeout: ""
    # -- list of the conditions that determine whether a node is considered unhealthy. if any of the conditions is met, the node is unhealthy.
    unhealthyConditions:
    - type: Ready
      status: Unknown
      timeout: 300s
    - type: Ready
      status: "False"
      timeout: 300s
    # -- remediation is only allowed if the number of machines selected by "selector" as not healthy is within the range of "UnhealthyRange"
    unhealthyRange: ""

Helm --atomic

Helm waits and check status of deployments and statefulsets, for other kinds of objects, it relies only on the creation and considers it fully deployed if the creation is successful. To address this, the chart contains a Job, deployed as a helm hook, which waits until the control-plane and workers have finished their install/upgrade.

Deploy cluster-api-vsphere with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has cluster-api-vsphere on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartcluster-api-vsphere is pinned at v4.1.5 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply