Deploying Tanzu Kubernetes Grid with YAML

3 minutes

read –

in

In another post about automation, i tested the creation of Cloud Templates in Aria Automation using ChatGPT.

This can also be done for the kubernetes yaml files.

This YAML file describes a TKG workload cluster configuration, using Cluster API (CAPI).

Explanation:

  • apiVersion: Specifies the API version for the Tanzu Kubernetes Cluster resource.
  • kind: Specifies the type of resource, in this case, TanzuKubernetesCluster.
  • metadata: Contains metadata about the cluster, such as its name.
  • spec: Defines the specifications for the cluster.
    • topology: Specifies the cluster topology, including control plane and worker node configurations.
      • controlPlane: Configuration for the control plane nodes.
        • count: Number of control plane nodes.
        • class: Resource class for control plane nodes (e.g., best-effort-small).
        • storageClass: Storage class for the control plane nodes (e.g., vsphere-with-kubernetes).
      • workers: Configuration for worker nodes.
        • count: Number of worker nodes.
        • class: Resource class for worker nodes (e.g., best-effort-small).
        • storageClass: Storage class for the worker nodes (e.g., vsphere-with-kubernetes).

This YAML configuration creates a Tanzu Kubernetes Cluster named “example-cluster” with one control plane node and three worker nodes. It uses the specified resource classes and storage classes for provisioning the nodes. Adjust the configuration according to your requirements and the specifications of your environment.

Explanation of Key Elements

  • Namespace: Ensure the tkg-cluster-namespace exists or create it.
  • VSphereMachineTemplate:
    • Defines the specifications for the control plane and worker node VMs.
  • KubeadmControlPlane:
    • Sets the control plane parameters like the Kubernetes version and replicas.
  • MachineDeployment:
    • Describes the worker node pool and its configuration.

Usage Instructions

  1. Create the Namespace:
  1. Apply the YAML File:
  1. Monitor Cluster Creation:

The Tanzu Management cluster:

Creating a YAML configuration file for deploying a Tanzu Kubernetes Grid (TKG) cluster involves defining specifications for the Kubernetes cluster within a VMware environment. Below, I provide a sample YAML file to deploy a TKG management cluster and a workload cluster.

Example YAML for TKG Management Cluster

The management cluster in Tanzu Kubernetes Grid acts as the central control plane through which workload clusters are deployed and managed. Here’s how you could define it:

This presumes Tanzu CLI is set up with the necessary plugins.

then run:

tanzu management-cluster create --file management-cluster-config.yaml

Example YAML for TKG Workload Cluster

Now that you have a management cluster, you can deploy a workload cluster for your applications:

# workload-cluster-config.yaml
---
CLUSTER_NAME: "tkg-workload-cluster-01"
CLUSTER_PLAN: "dev"
INFRASTRUCTURE_PROVIDER: "vsphere"
NAMESPACE: "default"
VSPHERE_USERNAME: "vsphere-user"
VSPHERE_PASSWORD: "vsphere-password"
VSPHERE_SERVER: "vsphere-server.example.com"
VSPHERE_DATACENTER: "Datacenter"
VSPHERE_DATASTORE: "vsphere-datastore"
VSPHERE_NETWORK: "VM Network"
VSPHERE_RESOURCE_POOL: "*/Resources"
VSPHERE_FOLDER: "tkg-clusters"
VSPHERE_SSH_AUTHORIZED_KEY: "ssh-rsa AAAA..."
CONTROL_PLANE_MACHINE_TYPE: "small"
WORKER_MACHINE_TYPE: "small"
WORKER_MACHINE_COUNT: 3
KUBERNETES_VERSION: "v1.22.5+vmware.1-tkg.1-zshippable"

and create with:

tanzu cluster create --file workload-cluster-config.yaml


Comments

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.