API Guide for Tanzu Kubernetes Clusters for VMware Cloud Director

0
361
API Guide for Tanzu Kubernetes Clusters for VMware Cloud Director


The Container Service Extension 4.0 has been launched with a number of vital enhancements and extra use instances, together with Cluster API, lifecycle administration by means of a person interface, GPU help for Kubernetes clusters, and integration with VMware Cloud Director as infrastructure. With its feature-rich person interface, clients can carry out operations equivalent to creation, scaling, and upgrading on Tanzu Kubernetes clusters. However, some clients could search automation help for these identical operations.

This weblog publish is meant for purchasers who wish to automate the provisioning of Tanzu Kubernetes clusters on the VMware Cloud Director Tenant portal utilizing the VMware Cloud Director API. Although the VCD API is supported, the weblog publish is critical as a result of the Cluster API is used to create and handle TKG clusters on VCD. The payload required to carry out operations on TKG clusters requires some work to supply the Cluster API-generated payload. The weblog publish outlines the step-by-step course of for producing the right payload for purchasers utilizing their VCD infrastructure.

Version Support:

This API information is relevant to clusters created by CSE 4.0 and CSE 4.0.1 Tanzu Kubernetes Clusters.

The current stipulations for purchasers to create TKG clusters of their organizations additionally apply to the automation stream. These stipulations are summarized right here and may be discovered within the official documentation to onboard Provider and Tenant Admin customers. The following sections present an summary of the necessities for each cloud supplier directors and Tenant Admin customers.

Cloud Provider Admin Steps

The Steps to onboard the shoppers is demonstrated on this video and documented right here. Once buyer group and its customers are onboarded, they’ll use subsequent part to make use of APIs, or eat it to create automated Cluster operations.

As a fast abstract following steps are anticipated to be carried out by cloud supplier to onboard and put together the shopper:

  1. Review Interoperability Matrix to help Container Service Extension 4.0 and 4.0.1
  2. Allow needed communication for CSE server
  3. Start CSE server and Onboard buyer group (Reference Demo and Official Documentation)

Customer Org Admin Steps

When the cloud supplier has onboarded the shopper onto the Container Service Extension, the group administrator should create and assign customers with the potential to create and handle TKG clusters for the shopper group. This documentation outlines the process for making a person with the “Kubernetes cluster author” function inside the tenant group.

It is then assumed that the person “acmekco” has obtained the required assets and entry inside the buyer group to execute Kubernetes cluster operations.

Generate ‘capiyaml’ payload

  • Collect VCD Infrastructure and Kubernetes Cluster particulars

This Operation requires following data for VCD tenant portal. The proper column describes instance values used as reference on this weblog publish.

Input Example worth for this weblog
VCD_SITE VCD Address (https://vcd-01a.local)
VCD_ORGANIZATION Customer Organization title(ACME)
VCD_ORGANIZATION_VDC Customer OVDC title (ACME_VDC_T)
VCD_ORGANIZATION_VDC_NETWORK Network title in buyer org (172.16.2.0)
VCD_CATALOG CSE shared catalog title (cse)
Table -1 Infrastructure particulars
Input Example worth for this weblog
VCD_TEMPLATE_NAME Kubernetes and TKG model of the cluster(Ubuntu 20.04 and Kubernetes v1.22.9+vmware.1)
VCD_CONTROL_PLANE_SIZING_POLICY Sizing coverage of management aircraft vms(TKG small)
VCD_CONTROL_PLANE_STORAGE_PROFILE Storage profile for management aircraft of the cluster (Capacity)
VCD_CONTROL_PLANE_PLACEMENT_POLICY Optional – Leave empty if not utilizing
VCD_WORKER_SIZING_POLICY Sizing coverage of employee nodes vms(TKG small)
VCD_WORKER_PLACEMENT_POLICY Optional – Leave empty if not utilizing
VCD_WORKER_STORAGE_PROFILE Storage profile for management aircraft of the cluster (Capacity)
CONTROL_PLANE_MACHINE_COUNT 1
WORKER_MACHINE_COUNT 1
VCD_REFRESH_TOKEN_B64 “MHB1d0tXSllVb2twU2tGRjExNllCNGZnVWZqTm5UZ2U=”
Ref VMware Doc to Generate token earlier than remodeling it to Base64
Table 2- Kubernetes Cluster properties
  • Install required instruments to generate the capiyaml. User can use any Operating System or a Virtual Machine(together with Linux, Mac or Windows) to generate the payload.
  • Once the tenant person has collected all the knowledge, person should set up following parts equivalent to  Clusterctl 1.1.3, Kind(0.17.0), and Docker (20.10.21) on finish person’s machine. The following step requires above collected data, and never the entry to VCD Infrastructure to generate capiyaml payload.
  • Copy TKG CRS Files regionally. Incase the TKG model is lacking from the folder, be sure you have the templates created for the specified TKG variations. The Following desk offers supported listing of and many others, coredns, tkg, tkr variations for CSE 40 and CSE 4.0.1 launch. Alternatively this script to fetch the identical values from Tanzu Kubernetes Grid assets.
Kubernetes Version Etcd ImageTag CoreDNS ImageTag Complete Unique Version OVA TKG Product Version TKr model
v1.22.9+vmware.1 v3.5.4_vmware.2 v1.8.4_vmware.9 v1.22.9+vmware.1-tkg.1 ubuntu-2004-kube-v1.22.9+vmware.1-tkg.1-2182cbabee08edf480ee9bc5866d6933.ova 1.5.4 v1.22.9—vmware.1-tkg.1
v1.21.11+vmware.1 v3.4.13_vmware.27 v1.8.0_vmware.13 v1.21.11+vmware.1-tkg.2 ubuntu-2004-kube-v1.21.11+vmware.1-tkg.2-d788dbbb335710c0a0d1a28670057896.ova 1.5.4 v1.21.11—vmware.1-tkg.3
v1.20.15+vmware.1 v3.4.13_vmware.23 v1.7.0_vmware.15 v1.20.15+vmware.1-tkg.2 ubuntu-2004-kube-v1.20.15+vmware.1-tkg.2-839faf7d1fa7fa356be22b72170ce1a8.ova 1.5.4 v1.20.15—vmware.1-tkg.2
Table 3 – Kubernetes, Etcd, Coredns for relavant Tanzu Kubernetes variations for CSE 4.0, 4.0.1

  • Copy the ~/infrastructure-vcd/v1.0.0/clusterctl.yaml to ~/.cluster-api/clusterctl.yaml.
  • The ‘clusterctl‘ command makes use of clusterctl.yaml from ~/.cluster-api/clusterctl.yaml to create the capiyaml payload. Update the infrastructure particulars from step one on this doc.
  • Update the suppliers.url in ~/.cluster-api/clusterctl.yaml to ~/infrastructure-vcd/v1.0.0/infrastructure-components.yaml.

  • At this level your ~/cluster-api/clusterctl.yaml values ought to look as follows

At this level, we are going to want a form cluster to put in clusterctl to generate the payload. In this step, create Kind cluster to generate capiyaml payload and initialize clusterctl as follows:

Update the beneath tkg labels to “Kind: Cluster” object and annotations.

  • At this level, the capiyaml is able to be consumed by VCD APIs to carry out varied operations. For verification, make certain cluster title, namespace values are constant. Copy the content material of capiyaml to generate jsonstring utilizing related instrument as right here.

Following part describes all supported API operations for Tanzu Kubernetes Cluster on VMware Cloud Director:

List Clusters

List all clusters within the buyer group. for CSE 4.0 launch the CAPVCD model is 1.

Info Cluster

Filter Cluster by title

Get cluster by ID:

Get Kubeconfig of the cluster:

The Kubeconfig may be discovered as follows at: entity.standing.capvcd.personal.kubeconfig

Create a brand new Cluster

Resize a Cluster

  • Fetch the Cluster ID("id": "urn:vcloud:entity:vmware:capvcdCluster:<ID>) from the above API name’s output.
  • Copy the entire output of the API response.
  • Notedown eTag Value from API response header
  • Modify “capiyaml” with following values:
    • To resize Control Plane VMs Modify kubeadmcontrolplane.spec.replicas with desired variety of management aircraft vms. Note solely odd numbers of management aircraft are supported.
    • To resize Worker Plane VMS Modify MachineDeployment.spec.replicas with desired variety of employee aircraft VMs
  • While performing the PUT API name, guarantee to incorporate fetched eTag worth as If-Match

Upgrade a Cluster

To Upgrade a cluster, Provider admin must publish desired the Tanzu Kubernetes templates to the shopper group in catalog utilized by Container Service Extension.

acquire the GET API response for the cluster to be upgraded as follows:

  • Fetch the Cluster ID("id": "urn:vcloud:entity:vmware:capvcdCluster:<ID>) from the above API name’s output.
  • Copy the entire output of the API response.
  • Notedown eTag Value from API response header
  • The buyer person performing cluster improve would require entry to Table 3 data. Modify Following values matching the goal TKG model. The Following desk exhibits Upgrade for TKG model 1.5.4 from v1.20.15+vmware.1 to v1.22.9+vmware.1
Control Plane Version Old Values New Values
VCDMachineTemplate
VCDMachineTemplate.spec.template.spec.template Ubuntu 20.04 and Kubernetes v1.20.15+vmware.1 Ubuntu 20.04 and Kubernetes v1.22.9+vmware.1
KubeadmControlPlane
KubeadmControlPlane.spec.model v1.20.15+vmware.1 v1.22.9+vmware.1
KubeadmControlPlane.spec.kubeadmConfigSpec.dns imageTag: v1.7.0_vmware.15 v1.8.4_vmware.9
KubeadmControlPlane.spec.kubeadmConfigSpec.etcd v3.4.13_vmware.23 v3.5.4_vmware.2
KubeadmControlPlane.spec.kubeadmConfigSpec.imageRepository imageRepository: initiatives.registry.vmware.com/tkg imageRepository: initiatives.registry.vmware.com/tkg
Worker Node Version
VCDMachineTemplate
VCDMachineTemplate.spec.template.spec.template Ubuntu 20.04 and Kubernetes v1.20.15+vmware.1 Ubuntu 20.04 and Kubernetes v1.22.9+vmware.1
VCDMachineTemplate.spec.template.spec
MachineDeployment
MachineDeployment.spec.model v1.20.15+vmware.1 v1.22.9+vmware.1
Table 4 – Example values to vary in capiyaml payload for TKG 1.5.4 Kubernetes model 1.20.15 to 1.22.9 for CSE 4.0, 4.0.1
  • While performing the PUT API name, guarantee to incorporate fetched eTag worth as If-Match

Delete a Cluster

  • Fetch the Cluster ID("id": "urn:vcloud:entity:vmware:capvcdCluster:<ID>) from the above API name’s output.
  • Copy the entire output of the API response.
  • Notedown eTag Value from API response header
  • Add or modify the next fields to delete or forcefully delete the cluster below entity.spec.vcdke:
    • “markForDelete”: true, –> Set the worth to true to delete the cluster
    • “forceDelete”: true, –> Set this worth to true for Forceful deletion of a cluster

Recommendation for API Usage throughout automation

  • DO NOT hardcode API urls with RDE variations. ALWAYS parameterize RDE variations. For instance:

POST https://{{vcd}}/cloudapi/1.0.0/entityTypes/urn:vcloud:type:vmware:capvcdCluster:1.1.0 Ensure to declare 1.1.0 as a variable. This will guarantee straightforward API shopper upgrades to future variations of CSE.

  • Ensure the API shopper code ignores any unknown/extra properties whereas unmarshaling the API response

Summary

To summarize, we checked out CRUD operations for a Tanzu Kubernetes clusters on VMware Cloud Director platform utilizing VMware Cloud Director supported APIs. Please be at liberty to checkout different assets for Container Service Extension as follows:

  1. Generate API token utilizing VMware Cloud Director
  2. CSE 4.0 Official Documentation
  3. Cluster API for VMware Cloud Director Platform official Documentation

LEAVE A REPLY

Please enter your comment!
Please enter your name here