check-circle-line exclamation-circle-line close-line

<

You can connect the Tanzu Kubernetes Grid CLI to a vSphere with Kubernetes Supervisor Cluster that is running in a vSphere 7.0 instance. In this way, you can deploy Tanzu Kubernetes clusters to vSphere with Kubernetes and manage their lifecycle directly from the Tanzu Kubernetes Grid CLI.

vSphere with Kubernetes provides a vSphere Plugin for kubectl. The vSphere Plugin for kubectl extends the standard kubectl commands so that you can connect to the Supervisor Cluster from kubectl by using vCenter Single Sign-On credentials. Once you have installed the vSphere Plugin for kubectl, you can connect the Tanzu Kubernetes Grid CLI to the Supervisor Cluster. Then, you can use the Tanzu Kubernetes Grid CLI to deploy and manage Tanzu Kubernetes clusters running in vSphere.

Prerequisites

Procedure

  1. On the bootstrap environment machine, run the kubectl vsphere login command to log in to your vSphere 7.0 instance.

    Specify a vCenter Single Sign-On user account with vSphere Administrator privileges to use to log in to vSphere, and the virtual IP (VIP) address for the control plane of the Supervisor Cluster. For example:

    kubectl vsphere login --vsphere-username Administrator@vsphere.local --server=control_Plane_VIP --insecure-skip-tls-verify=true

  2. Enter the password for the vSphere Administrator account.

    When you have successfully logged in, kubectl vsphere displays all of the contexts to which you have access. The list of contexts should include the vSphere with Kubernetes Supervisor Cluster.

  3. Set the focus of kubectl to the context of the Supervisor Cluster.

    kubectl config use-context <Supervisor_Cluster_context>
    
  4. Add the Supervisor Cluster to your Tanzu Kubernetes Grid instance.

    tkg add management-cluster 
    
  5. Run tkg get management-cluster to see the list of management clusters that your Tanzu Kubernetes Grid CLI can access.

    tkg get management-cluster
    

    The output should show the vSphere with Kubernetes Supervisor Cluster in the list.

    +-------------------------+-------------------------------+
    | MANAGEMENT CLUSTER NAME | CONTEXT NAME                  |
    +-------------------------+-------------------------------+
    | vsphere-mc              | vsphere-mc-admin@vsphere-mc   |
    | aws-mc *                | aws-mc-admin@aws-mc           |
    | <Supervisor_Cluster_IP> | <Supervisor_Cluster_context>  |
    +-------------------------+-------------------------------+
    
  6. Set the focus of the Tanzu Kubernetes Grid CLI to the Supervisor Cluster.

    tkg set management-cluster <Supervisor_Cluster_IP>
    
  7. Obtain information about the storage classes that are defined in the Supervisor Cluster.

    kubectl get storageclasses
    
  8. Set variables to define the storage classes, VM classes, and service domain with which to create your cluster.

    For information about all of the configuration parameters that you can set when deploying Tanzu Kubernetes clusters to vSphere with Kubernetes, see Configuration Parameters for Provisioning Tanzu Kubernetes Clusters in the vSphere with Kubernetes documentation.

    You can either set these variables as environment variables by specifying export <variable>=<value> at the command line, or set them by updating the ~/.tkg/config file.

    • For the *_STORAGE_CLASS variables, specify one of the storage classes that you obtained in the previous step.

      CONTROL_PLANE_STORAGE_CLASS=<storage_class_name>
      
      WORKER_STORAGE_CLASS=<storage_class_name>
      
    • For the DEFAULT_STORAGE_CLASS variable, specify a storage class. Alternatively, you can specify DEFAULT_STORAGE_CLASS="", in which case no default storage class is set.

      DEFAULT_STORAGE_CLASS=<storage_class_name>
      

      Or

      DEFAULT_STORAGE_CLASS=""
      
    • For the STORAGE_CLASSES variable, enter a comma-separated list of storage classes for the cluster to use. Alternatively, you can specify STORAGE_CLASSES="" so that all storage classes that are available to the namespace are made available to clusters that you create. For example, set either of the following:

      STORAGE_CLASSES="<storageclass1>,<storageclass2>,<storageclass3>"
      

      Or

      STORAGE_CLASSES=""
      
    • For the SERVICE_DOMAIN variable, enter a service domain name for the cluster. If you are going to assign FQDNs with the nodes, DNS lookup is required.

      SERVICE_DOMAIN=my.domain.com
      
    • For the *_VM_CLASS variables, specify one of the standard VM classes for vSphere with Kubernetes. For information about the VM classes that vSphere with Kubernetes provides, see Virtual Machine Class Types for Tanzu Kubernetes Clusters in the vSphere with Kubernetes documentation. For example, set the following variables.

      CONTROL_PLANE_VM_CLASS=guaranteed-large
      
      WORKER_VM_CLASS=guaranteed-xlarge
      
    • For the SERVICE_CIDR variable, specify the CIDR range to use for the Kubernetes services. The recommended range is 100.64.0.0/13. Use a different range if the recommended range is unavailable.

      SERVICE_CIDR=100.64.0.0/13
      
    • For the CLUSTER_CIDR variable, specify the CIDR range to use for pods. The recommended range is 100.96.0.0/11. Use a different range if the recommended range is unavailable.

      CLUSTER_CIDR=100.96.0.0/11
      
  9. Obtain the list of Kubernetes versions that are available in the Supervisor Cluster.

    kubectl get virtualmachineimages
    
  10. Obtain the list of namespaces that are available in the Supervisor Cluster.

    kubectl get namespaces
    
  11. Run tkg create cluster to create a cluster in vSphere with Kubernetes.

    When deploying clusters to vSphere with Kubernetes, you must provide the namespace when you run tkg create cluster. If the available versions of Kubernetes differ from the one expected by Tanzu Kubernetes Grid, you must also specify the Kubernetes version. You must also specify which of the Tanzu Kubernetes Grid plans to use, dev or prod.

    tkg create cluster my-vsphere7-cluster --plan=dev --namespace=<namespace> --kubernetes-version=v1.16.8+vmware.1-tkg.3.60d2ffd
    

What to Do Next

You can now use the Tanzu Kubernetes Grid CLI to deploy more Tanzu Kubernetes clusters to the vSphere with Kubernetes Supervisor Cluster. You can also use the Tanzu Kubernetes Grid CLI to manage the lifecycles of clusters that are already running there. For information about how to manage the lifecycle of clusters, see the other topics in Deploying Tanzu Kubernetes Clusters and Managing their Lifecycle.