Setting up Continuous Delivery from Git repositories to a Kubernetes Clusters in TMC

Tanzu Mission Control (TMC) released a new feature couple of days back to support the Continuous Delivery. In this blog post, I will try to explain the process to setup Continuous Delivery (CD) to a Azure Kubernetes Cluster (AKS).

Tanzu Mission Control uses Flux (an open source community standard) for continuous delivery. Flux uses Kustomize to sync YAML to your cluster. Flux CD runs in your cluster, connects to your repositories, and periodically syncs your defined kustomization files to your cluster.

Important Note: Continuous delivery is supported on workload clusters managed by Tanzu Mission Control, with the following exceptions:

  • Openshift clusters
  • Unmanaged Tanzu Community Edition (TCE) clusters
  • TCE clusters prior to version 0.12

Pre-Requirements

  • Supported Kubernetes Cluster is up and running
  • Cluster is attached or created using TMC and in healthy state

Enabling CD to an AKS cluster from TMC

  • Login to TMC and click on Clusters tab
  • Click on an appropriate cluster
  • Navigate to the Continuous Delivery tab
  • Click Enable Continuous Delivery button. In the very beginning, you will see this button inside all three options and you can click from any one.
  • Enablement is in progress
  • Once CD is enabled, you will notice that there are 4 namespace created.
  • tanzu-fluxcd-packageinstalls – namespace for Flux package install resources (source controller and Kustomization controller)
  • tanzu-source-controller – namespace for Flux source controller deployments
  • tanzu-kustomize-controller – namespace for Flux Kustomize controller deployments
  • tanzu-continuousdelivery-resources – namespace for user-created GitRepository and Kustomization resources, and intents resources
  • Also, You will notice the change on a TMC UI where it will display buttons to add resources. We will do that soon.

Now, before we can apply yaml’s in a cluster, following resources needs to be created.

Create a Git Repository Credential 

You need to add a Git Repository Credentials in case you are using a private repository and require credentials to pull the yaml files. In my case, I have created the credentials but never used in this post the repository is publicly accessible.

For your reference, I have used a very simple git repo that is

https://github.com/dineshtripathi30/tmc-cd

  • Click on Repository credentials option under CD
  • Provide the required details and click on Create Repository Credential button
  • Repository credential added successfully.

Add a Git Repository to a Cluster

  • Go to Git repositories option under CD and click on Add Git Repository button
  • Provide the required details and click on Add Git Repository button. In this case you may notice that I haven’t select any repository credentials as it’s public.
  • Git repository addition is in progress
  • Git repository added successfully.
  • You can also run a kubectl command to validate the same.
k get gitrepository -A
NAMESPACE                            NAME     URL                                              AGE   READY   STATUS
tanzu-continuousdelivery-resources   tmc-cd   https://github.com/dineshtripathi30/tmc-cd.git   44m   True    stored artifact for revision 'master/9a336e1179e9e2b1474a5a7e4e2bbb2e25b255d5'

Add a Kustomization to a Cluster

Finally, add a kustomization resource to sync the yaml file in a Kubernetes cluster.

  • Go to Kustomizations option under CD and click on Add Kustomization button.
  • Provide the required details and click on Add Kustomization button.

Note:
– Path: You need to specify the folder path from git repository. In this case, I want to apply all yaml files under / path in a git repository under master branch
– Prune : You can enable this option if you want to delete the resource from a Kubernetes cluster after Kustomization resource is deleted.

  • Applying yaml files is in progress
  • Kustomization applied yaml files successfully in a Kubernetes cluster.

Validate the Resources on a K8S Cluster

❯ k get kustomizations -A
NAMESPACE                            NAME                   AGE   READY   STATUS
tanzu-continuousdelivery-resources   tmc-cd-kustomization   19m   True    Applied revision: master/9a336e1179e9e2b1474a5a7e4e2bbb2e25b255d5

❯ k get po
NAME    READY   STATUS    RESTARTS   AGE
nginx   1/1     Running   0          19m

Additional Reference Documentation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s