Conversion of cluster variables to the new variable schema introduced in VKS 3.2.0
vSphere Kubernetes Service version 3.2.0 and above
The following covers the process for automated as well as manual conversion of cluster variables using the tanzukubernetescluster or builtin-generic-v3.1.0 ClusterClass. This article contains the information which will allow cluster operators to:
With the release of vSphere Kubernetes Service v3.2.0, the variables for customizing the clusters using the v1beta1 API have undergone significant changes. The variable schema on the new ClusterClass versions introduce a hierarchical variable structure. This new variable schema groups multiple configurations under top level variables such that similar customization variables can be set together under one variable. For example, instead of having three different variables for proxy setting, CA trust configurations and NTP servers, the new variable schema exposes an osConfiguration variable which contains these three individual settings.
Note: Any changes to the Kubernetes version or the ClusterClass versions and/or variables will likely result in a rollout of the nodes of the cluster.
TKGS/VKS exposes the concept of auto-rebasing clusters to use the latest supported ClusterClass. When the Kubernetes version of the cluster is updated, VKS chooses to move the cluster to the latest ClusterClass that supports the requested Kubernetes version. This behavior is turned on by default for all clusters except the ones which have the kubernetes.vmware.com/skip-auto-cc-rebase annotation set.
Any existing clusters created using a VKS version less than v.3.2.0 will have this skip rebase annotation set on them by default after upgrade to VKS version 3.2.0 or above. Inspect the metadata.annotations field of the cluster object after the VKS version upgrade to confirm the same.
Edit the cluster manifest using kubectl edit cluster -n <namespace> <cluster-name>
Remove the kubernetes.vmware.com/skip-auto-cc-rebase annotation from the metadata.annotations field.
(Optional) Update the spec.topology.class field to builtin-generic-v3.x.0, where x is the VKS minor version in use.
Save the changes and close the editor.
This should cause the variables to be automatically updated to the new variable schema. Inspect the variables on the cluster using the following command. It makes a check for the presence key extensionCert, which has been removed from the new variable schema and instead handled internally via VKS.
# This should return no output since the variable is removed
kubectl get cluster -n <NAMESPACE> <CLUSTER> -o jsonpath='{.spec.topology.variables}' | grep extensionCert
Note: You can use any of the ClusterClass versioned support by VKS but VKS will always rebase the Cluster to the latest ClusterClass supporting the Kubernetes version. Please consult the release notes of the VKS version in use for more information about Kubernetes versions supported by a ClusterClass.
If for any reason you do not want to leverage the automatic rebasing, you can use this table to interpret the destination variables for all the variables in the new schema. The table is a subset of the original table published in ClusterClass Variable Conversion to showcase the manual conversion process:
Variable for TKG Service v3.1.x or earlier |
New variable for TKG Service v3.2.x or later |
ntp |
osConfiguration.ntp.servers |
storageClass |
storageClass |
storageClasses |
vsphereOptions.persistentVolumes.availableStorageClasses |
If the existing cluster YAML has the ntp variable with a value defined, this value now should be included the osConfiguration variable under the ntp section.
# original variable declaration
- name: ntp
value: ntp.example.com
# new variable declaration
- name: osConfiguration
value:
ntp:
servers:
- ntp.example.com
Similarly, for the storageClasses variable, this should now reside under the vsphereOptions variable under the section persistentVolumes against the availableStorageClasses sub-section.
# original variable declaration
- name: storageClasses
value:
- storage-class-1
- storage-class-2
# new variable declaration
- name: vsphereOptions
value:
persistentVolumes:
availableStorageClasses:
- storage-class-1
- storage-class-2
Use the same method, to create a new set variables and replace it under the spec.topology.variables field of the cluster object. Any variables overridden at the control plane or node pool level should also be transformed using the same process.
As shown above, the process to initiate a manual variable conversion can be time-consuming, error prone requires knowledge about the new variable schema. Instead, you can use the attached vks-variable-convert tool to convert the cluster YAML using the old variable schema to the new schema.
./vks-variable-convert --input-file cluster-manifest.yaml --to-clusterclass builtin-generic-v3.2.0 --output-file new-variable-patches.yaml
Retrieve the cluster manifest for the cluster you want to convert to the new schema
kubectl get cluster <CLUSTER> -o yaml > cluster-manifest.yaml
Run the tool
./vks-variable-convert --input-file cluster-manifest.yaml --to-clusterclass builtin-generic-v3.2.0 --output-file new-variable-patches.yaml
Run the following command to verify the output locally
kubectl patch -f cluster-manifest.yaml --type=json --patch-file new-variable-patches.yaml --local -o yaml
Run the following command to verify output of the cluster with converted cluster variables
kubectl patch cluster -n <NAMESPACE> <CLUSTER> --type=json --patch-file new-variable-patches.yaml --dry-run=client -o yaml
Run the following command to patch the converted cluster variables
kubectl patch cluster -n <NAMESPACE> <CLUSTER> --type=json --patch-file new-variable-patches.yaml
The variable definitions for the older or existing variables can be found at Cluster v1beta1 API