Deploying Tanzu Kubernetes Grid Workload Cluster to Microsoft Azure
Tags: uncategorized, azure, microsoft, tanzucli
Published: 2021-05-10 20:16:32

---
title: Deploying Tanzu Kubernetes Grid Workload Cluster to Microsoft Azure
published: true
date: 2021-05-10 12:32:54 UTC
tags: Uncategorized,Azure,microsoft,TanzuCLI
canonical_url: https://veducate.co.uk/tkg-workload-cluster-azure/?utm_source=rss&utm_medium=rss&utm_campaign=tkg-workload-cluster-azure
---

Following on from my previous blog post;

- [Deploying Tanzu Kubernetes Grid Management Cluster to Microsoft Azure](https://veducate.co.uk/tkg-management-cluster-azure)

We will now continue and deploy our first Workload (Guest) Cluster into Azure for us by our developers to deploy their applications into.

For this technical walkthrough, I am assuming you have followed the [previous blog post](https://veducate.co.uk/tkg-management-cluster-azure) and have the [Tanzu CLI and Kubectl CLI](https://my.vmware.com/web/vmware/downloads/details?downloadGroup=TKG-130&productId=988&rPId=61886) installed, and a working management cluster.

As a reminder of the terminology;

- Tanzu Kubernetes Workload Clusters

Once you have deployed your management cluster, you can deploy additional CNCF conformant Kubernetes clusters and manage their full lifecycle. These clusters are designed to run your application workloads, managed via your management cluster. These clusters canrun different Kubernetes versions as required. These clusters use Antrea networking by default.

These types of clusters are also referred to as “workload” clusters, or “guest” clusters, with the latter typically referring to the Tanzu Kubernetes Grid Service running in vSphere.

###### Deploying a Guest Cluster

Login to your Tanzu environment Management Cluster with the following:

```
Tanzu login
```

[![Deploy Management cluster to Azure - Tanzu Login](https://i0.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Management-cluster-to-Azure-Tanzu-Login-1.jpg?resize=438%2C78&ssl=1)](https://i0.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Management-cluster-to-Azure-Tanzu-Login-1.jpg?ssl=1)

First we need to create a cluster configuration YAML file. You can find a [template here for Azure](https://docs.vmware.com/en/VMware-Tanzu-Kubernetes-Grid/1.3/vmware-tanzu-kubernetes-grid-13/GUID-tanzu-k8s-clusters-azure.html), or view the [full available variables here](https://docs.vmware.com/en/VMware-Tanzu-Kubernetes-Grid/1.3/vmware-tanzu-kubernetes-grid-13/GUID-tanzu-config-reference.html).

Alternatively, we can use the existing YAML file in our ~/.tanzu/tkg/clusterconfigs folder used for the management cluster deployment and change a few settings to make it ready for our workload guest cluster.

This was my preferred method as it contained all my Azure settings already.

```
#Find existing cluster config file 

ls -lh ~/.tanzu/tkg/clusterconfigs/

#Copy file to a new config

cp ~/.tanzu/tkg/clusterconfigs/6x4hl1wy8o.yaml tanzu-veducate-guest-azure.yaml

# Edit file = CLUSTER_NAME
# Workload cluster names must be 42 characters or less.

```

[![Deploy Tanzu Kubernetes Guest cluster to Azure - create cluster configuration yaml file](https://i0.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-create-cluster-configuration-yaml-file.jpg?resize=569%2C107&ssl=1)](https://i0.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-create-cluster-configuration-yaml-file.jpg?ssl=1)

Once we have our file, we can run the cluster create command, and sit back and wait for the cluster to be made available.

```
#Create cluster 

tanzu cluster create --file tanzu-guest-azure.yaml

#Alternatively you can not edit the file and just specify a new cluster name as part of the tanzu create command

tanzu cluster create {new_cluster_name} --file {file_location}
```

[![Deploy Tanzu Kubernetes Guest cluster to Azure - tanzu cluster create](https://i2.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-tanzu-cluster-create-.jpg?resize=567%2C48&ssl=1)](https://i2.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-tanzu-cluster-create-.jpg?ssl=1)

Below is the output of my cluster create command. It took 6 minutes and 50 seconds to create my basic guest workload cluster.

[![Deploy Tanzu Kubernetes Guest cluster to Azure - tanzu cluster create - output](https://i2.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-tanzu-cluster-create-output.jpg?resize=604%2C139&ssl=1)](https://i2.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-tanzu-cluster-create-output.jpg?ssl=1)

Next, we can validate and view the Workload cluster details,

```
# Get available clusters once deployed

tanzu cluster list

# To include the management cluster in our list

tanzu cluster list --include-management-cluster

# To get more information about our specific cluster deployment
tanzu cluster get {name}
```

###### [![Deploy Tanzu Kubernetes Guest cluster to Azure - tanzu cluster list - tanzu cluster get](https://i0.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-tanzu-cluster-list-tanzu-cluster-get.jpg?resize=604%2C214&ssl=1)](https://i0.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-tanzu-cluster-list-tanzu-cluster-get.jpg?ssl=1)

And here are the resources deployed to Microsoft Azure.

[![Deploy Tanzu Kubernetes Guest cluster to Azure - Azure Resources](https://i1.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-Azure-Resources.jpg?resize=604%2C400&ssl=1)](https://i1.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-Azure-Resources.jpg?ssl=1)

###### Getting your Workload (Guest) Cluster credentials

Now we have successfully deployed our Workload Cluster, we need to be able to connect to it.

By default, this clusters details will not be added to our Kubeconfig contexts file.

[![Deploy Tanzu Kubernetes Guest cluster to Azure - kubectl config get contexts](https://i2.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-kubectl-config-get-contexts.jpg?resize=604%2C71&ssl=1)](https://i2.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-kubectl-config-get-contexts.jpg?ssl=1)

But it is easy to rectify this by running the following commands:

```
# Running the below command adds the cluster context to your kubeconfig file locally
# Using the argument "--admin" ensures the administrator access context is added

tanzu cluster kubeconfig get --admin {cluster_name}

# View your kubeconfig file contexts

kubectl config get-contexts

# Change kubectl context to run commands on your workload cluster
kubectl config use-context {context_name}
```

[![Deploy Tanzu Kubernetes Guest cluster to Azure - tanzu cluster kubeconfig get --admin - kubectl config use-context](https://i1.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-tanzu-cluster-kubeconfig-get-admin-kubectl-config-use-context-1.jpg?resize=604%2C159&ssl=1)](https://i1.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-tanzu-cluster-kubeconfig-get-admin-kubectl-config-use-context-1.jpg?ssl=1)

Finally, we can also export the kubeconfig context to a standalone file, for example, for your developers to use to access the cluster using their own authentication details.

```
tanzu cluster kubeconfig get {cluster_name} --export-file {file_name} --admin
```

Alternatively, you can use the “–admin” argument so that the credentials are embedded into the file, and no external authentication provider is needed. This would be considered less secure.

[![](https://i0.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-tanzu-cluster-kubeconfig-get-admin-export-file.jpg?resize=604%2C41&ssl=1)](https://i0.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-tanzu-cluster-kubeconfig-get-admin-export-file.jpg?ssl=1)

And here is my file itself.

[![Deploy Tanzu Kubernetes Guest cluster to Azure - tanzu cluster kubeconfig get --admin --export-file - output screenshot](https://i2.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-tanzu-cluster-kubeconfig-get-admin-export-file-output-screenshot.jpg?resize=604%2C539&ssl=1)](https://i2.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-tanzu-cluster-kubeconfig-get-admin-export-file-output-screenshot.jpg?ssl=1)

You can find more details about [connecting to clusters here](https://docs.vmware.com/en/VMware-Tanzu-Kubernetes-Grid/1.3/vmware-tanzu-kubernetes-grid-13/GUID-cluster-lifecycle-connect.html).

These are the default locations where the Tanzu cluster context files are saved on your bootstrap machine.

- Management cluster contexts:
  - ~/.kube-tkg/config
- Workload cluster contexts:
  - ~/.kube/config

###### Scaling your Workload Cluster

To scale your workload cluster is simple and quick, once again using the Tanzu CLI.

```
tanzu cluster scale {workload_cluster_name} --controlplane-machine-count {number} --worker-machine-count {number}
```

If you have deployed a development management cluster, like I did in this blog, when deploying control plane nodes of 3 or higher, the cluster will automatically initiate high availability configuration.

[![Deploy Tanzu Kubernetes Guest cluster to Azure - Tanzu cluster scale](https://i1.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-Tanzu-cluster-scale.jpg?resize=604%2C51&ssl=1)](https://i1.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-Tanzu-cluster-scale.jpg?ssl=1)

To view the scaling up or down process run.

```
tanzu cluster list
tanzu cluster get
```

[![Deploy Tanzu Kubernetes Guest cluster to Azure - Tanzu cluster scale - tanzu cluster list - tanzu cluster get - output](https://i2.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-Tanzu-cluster-scale-tanzu-cluster-list-tanzu-cluster-get-output.jpg?resize=604%2C215&ssl=1)](https://i2.wp.com/veducate.co.uk/wp-content/uploads/2021/03/Deploy-Tanzu-Kubernetes-Guest-cluster-to-Azure-Tanzu-cluster-scale-tanzu-cluster-list-tanzu-cluster-get-output.jpg?ssl=1)

###### Summary

In these two blog posts we have deployed a new Tanzu Kubernetes Grid Management Cluster and Workload Cluster into Microsoft Azure using the Tanzu CLI (previously TKG CLI).

For the next steps and ideas where to head next, I recommend reading the official TKG documentation and looking at these articles:

- [Deploy Tanzu Kubernetes Clusters with Different Kubernetes Versions](https://docs.vmware.com/en/VMware-Tanzu-Kubernetes-Grid/1.3/vmware-tanzu-kubernetes-grid-13/GUID-tanzu-k8s-clusters-k8s-versions.html)
- [Deploy a Cluster with a Non-Default CNI](https://docs.vmware.com/en/VMware-Tanzu-Kubernetes-Grid/1.3/vmware-tanzu-kubernetes-grid-13/GUID-tanzu-k8s-clusters-nondefault-cni.html)
- [Create Persistent Volumes with Storage Classes](https://docs.vmware.com/en/VMware-Tanzu-Kubernetes-Grid/1.3/vmware-tanzu-kubernetes-grid-13/GUID-tanzu-k8s-clusters-storage.html)
- [Configure Tanzu Kubernetes Cluster Plans](https://docs.vmware.com/en/VMware-Tanzu-Kubernetes-Grid/1.3/vmware-tanzu-kubernetes-grid-13/GUID-tanzu-k8s-clusters-config-plans.html)
- [Tanzu Kubernetes Grid Logs and Troubleshooting](https://docs.vmware.com/en/VMware-Tanzu-Kubernetes-Grid/1.3/vmware-tanzu-kubernetes-grid-13/GUID-troubleshooting-tkg-index.html)

Regards

[Follow @Saintdle](https://twitter.com/saintdle)<script async="" src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

[Dean Lewis](https://uk.linkedin.com/in/saintdle?trk=profile-badge)

 

The post [Deploying Tanzu Kubernetes Grid Workload Cluster to Microsoft Azure](https://veducate.co.uk/tkg-workload-cluster-azure/) appeared first on [vEducate.co.uk](https://veducate.co.uk).