SlideShare a Scribd company logo
1 of 7
Download to read offline
12/11/2022, 07:09 Building and deploying to an AKS cluster using Terraform and Azure DevOps with Kubernetes and Helm providers – Thomas Thornton
https://thomasthornton.cloud/2022/11/09/building-and-deploying-to-an-aks-cluster-using-terraform-and-azure-devops-with-kubernetes-and-helm-providers/ 1/7
Thomas Thornton 9 November 2022
Building and deploying to an AKS cluster using Terraform and Azure DevOps with
Kubernetes and Helm providers
thomasthornton.cloud/2022/11/09/building-and-deploying-to-an-aks-cluster-using-terraform-and-azure-devops-with-kubernetes-and-helm-providers
I have a few blogs now on deploying Azure Kubernetes Services (AKS) with different scenarios, such as deploying AKS with Application
Gateway Ingress, in this blog post I am going to be building and deploying to an AKS cluster using Terraform and Azure DevOps. You
will also have noticed in the title, it references both Kubernetes and Helm providers – we will be looking at how Terraform can be used
to deploy to AKS as well once deployed. I am huge fan of GitOps within AKS, but to test an application or small environment; this way
could certainly be useful!
What will Terraform be deploying?
Initially Terraform will be used to deploy the AKS environment:
Virtual Network
Log Analytics
AKS cluster
The initial terraform code for this, can be found [HERE]. In this blog post, I won’t go deeper into the deployment of AKS as I have
covered this more in various other blogs, feel free to check these out
Azure DevOps Pipeline
As with most my pipelines, I utilise the use of variables alot , review these [HERE]
The Azure DevOps pipeline will consists of 4 stages:
terraform_plan: Running the action: plan will run this stage and output a plan for the above terraform
terraform_apply: Running the action: apply will run this stage and apply the above terraform
12/11/2022, 07:09 Building and deploying to an AKS cluster using Terraform and Azure DevOps with Kubernetes and Helm providers – Thomas Thornton
https://thomasthornton.cloud/2022/11/09/building-and-deploying-to-an-aks-cluster-using-terraform-and-azure-devops-with-kubernetes-and-helm-providers/ 2/7
bootstrap: Running the action: apply will run this stage and run the below Terraform using Kubernetes and Helm Providers
terraform_destroy: Running the action: destroy will destroy the environment
Full pipeline can be found [HERE]
Deploying to Kubernetes with Terraform using Kubernetes and Helm providers
Once this has been deployed, lets look at using Terraform with the Kubernetes & Helm providers to deploy an example namespace and
basic redis helm chart
The folder structure for this Terraform will be two files:
1
2
3
terraform-module-example
└── main.tf
└── providers.tf
Lets look at providers.tf , notice the reference to the helm & kubernetes providers along with config_path ?
12/11/2022, 07:09 Building and deploying to an AKS cluster using Terraform and Azure DevOps with Kubernetes and Helm providers – Thomas Thornton
https://thomasthornton.cloud/2022/11/09/building-and-deploying-to-an-aks-cluster-using-terraform-and-azure-devops-with-kubernetes-and-helm-providers/ 3/7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
provider "helm" {
kubernetes {
config_path = "/home/vsts/.kube/config"
}
}
provider "kubernetes" {
config_path = "/home/vsts/.kube/config"
config_context = "tamopsakstest-admin"
}
terraform {
backend "azurerm" {
}
}
To configure how the config_path is setup, it is the kubernetes context path – I have achieved this by using running some Azure CLI
within my aks_cluster_config stage here
Example output:
1
2
3
4
5
6
/usr/bin/az account set --subscription 04109105-f3ca-44ac-a3a7-66b4936112c3
/usr/bin/bash /home/vsts/work/_temp/azureclitaskscript1667379970075 .sh
+ AKS_RG=tamopsakstest-rg
+ AKS_NAME=tamopsakstest
+ az aks get-credentials -g tamopsakstest-rg -n tamopsakstest --admin
WARNING: Merged "tamopsakstest-admin" as current context in /home/vsts/ .kube /config
Great! Now that the context is setup and config_path’s are setup, it’s time to deploy some example resources that can be deployed by
these providers. I will be deploying a example Kubernetes namespace & helm release as below:
12/11/2022, 07:09 Building and deploying to an AKS cluster using Terraform and Azure DevOps with Kubernetes and Helm providers – Thomas Thornton
https://thomasthornton.cloud/2022/11/09/building-and-deploying-to-an-aks-cluster-using-terraform-and-azure-devops-with-kubernetes-and-helm-providers/ 4/7
1
2
3
4
5
6
7
8
9
10
11
12
13
resource "kubernetes_namespace" "test" {
metadata {
name = "test"
}
}
resource "helm_release" "redis" {
name = "redis"
repository = "https://charts.bitnami.com/bitnami"
chart = "redis"
namespace = "test"
}
Reviewing the apply stage, we can see its planning to create these two resources (log output)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Terraform will perform the following actions :
+ resource "helm_release" "redis" {
+ atomic = false
+ chart = "redis"
+ cleanup_on_fail = false
+ create_namespace = false
+ dependency_update = false
+ disable_crd_hooks = false
+ disable_openapi_validation = false
+ disable_webhooks = false
+ force_update = false
+ id = (known after apply)
+ lint = false
+ manifest = (known after apply)
+ max_history = 0
+ metadata = (known after apply)
+ name = "redis"
+ namespace = "test"
+ pass_credentials = false
+ recreate_pods = false
12/11/2022, 07:09 Building and deploying to an AKS cluster using Terraform and Azure DevOps with Kubernetes and Helm providers – Thomas Thornton
https://thomasthornton.cloud/2022/11/09/building-and-deploying-to-an-aks-cluster-using-terraform-and-azure-devops-with-kubernetes-and-helm-providers/ 5/7
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
+ render_subchart_notes = true
+ replace = false
+ repository = "https://charts.bitnami.com/bitnami"
+ reset_values = false
+ reuse_values = false
+ skip_crds = false
+ status = "deployed"
+ timeout = 300
+ verify = false
+ version = "17.3.7"
+ resource_version = (known after apply)
+ uid = (known after apply)
}
}
Output of log:
12/11/2022, 07:09 Building and deploying to an AKS cluster using Terraform and Azure DevOps with Kubernetes and Helm providers – Thomas Thornton
https://thomasthornton.cloud/2022/11/09/building-and-deploying-to-an-aks-cluster-using-terraform-and-azure-devops-with-kubernetes-and-helm-providers/ 6/7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
kubernetes_namespace. test : Creating...
kubernetes_namespace. test : Creation complete after 0s [ id = test ]
helm_release.redis: Creating...
helm_release.redis: Still creating... [10s elapsed]
helm_release.redis: Still creating... [20s elapsed]
helm_release.redis: Still creating... [30s elapsed]
helm_release.redis: Still creating... [40s elapsed]
helm_release.redis: Still creating... [50s elapsed]
helm_release.redis: Still creating... [1m0s elapsed]
helm_release.redis: Still creating... [1m10s elapsed]
helm_release.redis: Still creating... [1m20s elapsed]
helm_release.redis: Still creating... [1m30s elapsed]
helm_release.redis: Still creating... [1m40s elapsed]
helm_release.redis: Still creating... [1m50s elapsed]
helm_release.redis: Still creating... [2m0s elapsed]
helm_release.redis: Still creating... [2m10s elapsed]
helm_release.redis: Still creating... [2m20s elapsed]
helm_release.redis: Still creating... [2m30s elapsed]
helm_release.redis: Creation complete after 2m38s [ id =redis]
Great! We have successfully deployed a Kubernetes environment in Azure along with using the Helm & Kubernetes terraform providers
to deploy an example namespace & Helm Chart!
Finally, logging into the AKS cluster , we can see both the namespace & redis helm released has been deployed successfully
Namespace:
redis helm release:
12/11/2022, 07:09 Building and deploying to an AKS cluster using Terraform and Azure DevOps with Kubernetes and Helm providers – Thomas Thornton
https://thomasthornton.cloud/2022/11/09/building-and-deploying-to-an-aks-cluster-using-terraform-and-azure-devops-with-kubernetes-and-helm-providers/ 7/7
Although this is a concept – depending on your environment, I do recommend looking at GitOps for your Kubernetes cluster; especially
when deploying at scale!
Thanks for reading, another one of my blogs – as always, any queries do reach out!

More Related Content

What's hot

Github Actions and Terraform.pdf
Github Actions and Terraform.pdfGithub Actions and Terraform.pdf
Github Actions and Terraform.pdfVishwas N
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker IntroductionPeng Xiao
 
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...Edureka!
 
Docker and kubernetes
Docker and kubernetesDocker and kubernetes
Docker and kubernetesDongwon Kim
 
Introduction to Docker - 2017
Introduction to Docker - 2017Introduction to Docker - 2017
Introduction to Docker - 2017Docker, Inc.
 
Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...
Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...
Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...Amazon Web Services
 
Lets talk about: Azure Kubernetes Service (AKS)
Lets talk about: Azure Kubernetes Service (AKS)Lets talk about: Azure Kubernetes Service (AKS)
Lets talk about: Azure Kubernetes Service (AKS)Pedro Sousa
 
Introduction to Azure Blueprints
Introduction to Azure BlueprintsIntroduction to Azure Blueprints
Introduction to Azure BlueprintsCheah Eng Soon
 
Kubernetes for Beginners: An Introductory Guide
Kubernetes for Beginners: An Introductory GuideKubernetes for Beginners: An Introductory Guide
Kubernetes for Beginners: An Introductory GuideBytemark
 
Azure kubernetes service (aks)
Azure kubernetes service (aks)Azure kubernetes service (aks)
Azure kubernetes service (aks)Akash Agrawal
 
Docker Swarm for Beginner
Docker Swarm for BeginnerDocker Swarm for Beginner
Docker Swarm for BeginnerShahzad Masud
 
Why kubernetes matters
Why kubernetes mattersWhy kubernetes matters
Why kubernetes mattersPlatform9
 

What's hot (20)

Github Actions and Terraform.pdf
Github Actions and Terraform.pdfGithub Actions and Terraform.pdf
Github Actions and Terraform.pdf
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
 
Docker and kubernetes
Docker and kubernetesDocker and kubernetes
Docker and kubernetes
 
Kubernetes PPT.pptx
Kubernetes PPT.pptxKubernetes PPT.pptx
Kubernetes PPT.pptx
 
Introduction to Docker - 2017
Introduction to Docker - 2017Introduction to Docker - 2017
Introduction to Docker - 2017
 
Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...
Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...
Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...
 
Lets talk about: Azure Kubernetes Service (AKS)
Lets talk about: Azure Kubernetes Service (AKS)Lets talk about: Azure Kubernetes Service (AKS)
Lets talk about: Azure Kubernetes Service (AKS)
 
Introduction to Azure Blueprints
Introduction to Azure BlueprintsIntroduction to Azure Blueprints
Introduction to Azure Blueprints
 
Kubernetes for Beginners: An Introductory Guide
Kubernetes for Beginners: An Introductory GuideKubernetes for Beginners: An Introductory Guide
Kubernetes for Beginners: An Introductory Guide
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
Docker & kubernetes
Docker & kubernetesDocker & kubernetes
Docker & kubernetes
 
Introduction to container based virtualization with docker
Introduction to container based virtualization with dockerIntroduction to container based virtualization with docker
Introduction to container based virtualization with docker
 
Azure kubernetes service (aks)
Azure kubernetes service (aks)Azure kubernetes service (aks)
Azure kubernetes service (aks)
 
Docker Swarm for Beginner
Docker Swarm for BeginnerDocker Swarm for Beginner
Docker Swarm for Beginner
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
Tour of Azure DevOps
Tour of Azure DevOpsTour of Azure DevOps
Tour of Azure DevOps
 
Why Kubernetes on Azure
Why Kubernetes on AzureWhy Kubernetes on Azure
Why Kubernetes on Azure
 
Why kubernetes matters
Why kubernetes mattersWhy kubernetes matters
Why kubernetes matters
 
infrastructure as code
infrastructure as codeinfrastructure as code
infrastructure as code
 

Similar to Building and deploying to an AKS cluster using Terraform and Azure DevOps with Kubernetes and Helm providers – Thomas Thornton.pdf

Deploy Prometheus - Grafana and EFK stack on Kubic k8s Clusters
Deploy Prometheus - Grafana and EFK stack on Kubic k8s ClustersDeploy Prometheus - Grafana and EFK stack on Kubic k8s Clusters
Deploy Prometheus - Grafana and EFK stack on Kubic k8s ClustersSyah Dwi Prihatmoko
 
Building Deploying and Managing Microservices-based Applications with Azure P...
Building Deploying and Managing Microservices-based Applications with Azure P...Building Deploying and Managing Microservices-based Applications with Azure P...
Building Deploying and Managing Microservices-based Applications with Azure P...CodeOps Technologies LLP
 
AWS 기반 Docker, Kubernetes
AWS 기반 Docker, KubernetesAWS 기반 Docker, Kubernetes
AWS 기반 Docker, Kubernetes정빈 권
 
Kubernetes installation
Kubernetes installationKubernetes installation
Kubernetes installationAhmed Mekawy
 
How Helm, The Package Manager For Kubernetes, Works
How Helm, The Package Manager For Kubernetes, WorksHow Helm, The Package Manager For Kubernetes, Works
How Helm, The Package Manager For Kubernetes, WorksMatthew Farina
 
Kubernetes meetup 102
Kubernetes meetup 102Kubernetes meetup 102
Kubernetes meetup 102Jakir Patel
 
What Is AWS Elastic Kubernetes Service
 What Is AWS Elastic Kubernetes Service What Is AWS Elastic Kubernetes Service
What Is AWS Elastic Kubernetes ServiceAMELIAOLIVIA2
 
learn Helm 3 for kuberenetes
learn Helm 3 for kubereneteslearn Helm 3 for kuberenetes
learn Helm 3 for kuberenetesShyam Mohan
 
Getting Started with Kubernetes on AWS
Getting Started with Kubernetes on AWSGetting Started with Kubernetes on AWS
Getting Started with Kubernetes on AWSAmazon Web Services
 
Compare Docker deployment options in the public cloud
Compare Docker deployment options in the public cloudCompare Docker deployment options in the public cloud
Compare Docker deployment options in the public cloudSreenivas Makam
 
Apache Cassandra cluster cloning on Kubernetes
Apache Cassandra cluster cloning on KubernetesApache Cassandra cluster cloning on Kubernetes
Apache Cassandra cluster cloning on KubernetesDaniel M. Farrell
 
Artem Zhurbila - docker clusters (solit 2015)
Artem Zhurbila - docker clusters (solit 2015)Artem Zhurbila - docker clusters (solit 2015)
Artem Zhurbila - docker clusters (solit 2015)Artem Zhurbila
 
Lecture13 Containers
Lecture13   ContainersLecture13   Containers
Lecture13 Containersbtopro
 
Dockerized .Net Core based app services in azure K8s
Dockerized .Net Core based app services in azure K8s Dockerized .Net Core based app services in azure K8s
Dockerized .Net Core based app services in azure K8s Ranjeet Bhargava
 
Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112Nirmal Mehta
 
Kubernetes Application Deployment with Helm - A beginner Guide!
Kubernetes Application Deployment with Helm - A beginner Guide!Kubernetes Application Deployment with Helm - A beginner Guide!
Kubernetes Application Deployment with Helm - A beginner Guide!Krishna-Kumar
 
Kubernetes Kops - Automation Night
Kubernetes Kops - Automation NightKubernetes Kops - Automation Night
Kubernetes Kops - Automation NightKasper Nissen
 
Kubernetes Operability Tooling (devopsdays Seattle 2019)
Kubernetes Operability Tooling (devopsdays Seattle 2019)Kubernetes Operability Tooling (devopsdays Seattle 2019)
Kubernetes Operability Tooling (devopsdays Seattle 2019)bridgetkromhout
 

Similar to Building and deploying to an AKS cluster using Terraform and Azure DevOps with Kubernetes and Helm providers – Thomas Thornton.pdf (20)

Deploy Prometheus - Grafana and EFK stack on Kubic k8s Clusters
Deploy Prometheus - Grafana and EFK stack on Kubic k8s ClustersDeploy Prometheus - Grafana and EFK stack on Kubic k8s Clusters
Deploy Prometheus - Grafana and EFK stack on Kubic k8s Clusters
 
Building Deploying and Managing Microservices-based Applications with Azure P...
Building Deploying and Managing Microservices-based Applications with Azure P...Building Deploying and Managing Microservices-based Applications with Azure P...
Building Deploying and Managing Microservices-based Applications with Azure P...
 
AWS 기반 Docker, Kubernetes
AWS 기반 Docker, KubernetesAWS 기반 Docker, Kubernetes
AWS 기반 Docker, Kubernetes
 
Kubernetes installation
Kubernetes installationKubernetes installation
Kubernetes installation
 
How Helm, The Package Manager For Kubernetes, Works
How Helm, The Package Manager For Kubernetes, WorksHow Helm, The Package Manager For Kubernetes, Works
How Helm, The Package Manager For Kubernetes, Works
 
Kubernetes meetup 102
Kubernetes meetup 102Kubernetes meetup 102
Kubernetes meetup 102
 
What Is AWS Elastic Kubernetes Service
 What Is AWS Elastic Kubernetes Service What Is AWS Elastic Kubernetes Service
What Is AWS Elastic Kubernetes Service
 
learn Helm 3 for kuberenetes
learn Helm 3 for kubereneteslearn Helm 3 for kuberenetes
learn Helm 3 for kuberenetes
 
Getting Started with Kubernetes on AWS
Getting Started with Kubernetes on AWSGetting Started with Kubernetes on AWS
Getting Started with Kubernetes on AWS
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
Compare Docker deployment options in the public cloud
Compare Docker deployment options in the public cloudCompare Docker deployment options in the public cloud
Compare Docker deployment options in the public cloud
 
Apache Cassandra cluster cloning on Kubernetes
Apache Cassandra cluster cloning on KubernetesApache Cassandra cluster cloning on Kubernetes
Apache Cassandra cluster cloning on Kubernetes
 
Artem Zhurbila - docker clusters (solit 2015)
Artem Zhurbila - docker clusters (solit 2015)Artem Zhurbila - docker clusters (solit 2015)
Artem Zhurbila - docker clusters (solit 2015)
 
Lecture13 Containers
Lecture13   ContainersLecture13   Containers
Lecture13 Containers
 
Dockerized .Net Core based app services in azure K8s
Dockerized .Net Core based app services in azure K8s Dockerized .Net Core based app services in azure K8s
Dockerized .Net Core based app services in azure K8s
 
Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112
 
Kubernetes Application Deployment with Helm - A beginner Guide!
Kubernetes Application Deployment with Helm - A beginner Guide!Kubernetes Application Deployment with Helm - A beginner Guide!
Kubernetes Application Deployment with Helm - A beginner Guide!
 
Kubernetes Kops - Automation Night
Kubernetes Kops - Automation NightKubernetes Kops - Automation Night
Kubernetes Kops - Automation Night
 
Kubernetes Operability Tooling (devopsdays Seattle 2019)
Kubernetes Operability Tooling (devopsdays Seattle 2019)Kubernetes Operability Tooling (devopsdays Seattle 2019)
Kubernetes Operability Tooling (devopsdays Seattle 2019)
 
Lecture 12 - Docker
Lecture 12 - DockerLecture 12 - Docker
Lecture 12 - Docker
 

Recently uploaded

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 

Recently uploaded (20)

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 

Building and deploying to an AKS cluster using Terraform and Azure DevOps with Kubernetes and Helm providers – Thomas Thornton.pdf

  • 1. 12/11/2022, 07:09 Building and deploying to an AKS cluster using Terraform and Azure DevOps with Kubernetes and Helm providers – Thomas Thornton https://thomasthornton.cloud/2022/11/09/building-and-deploying-to-an-aks-cluster-using-terraform-and-azure-devops-with-kubernetes-and-helm-providers/ 1/7 Thomas Thornton 9 November 2022 Building and deploying to an AKS cluster using Terraform and Azure DevOps with Kubernetes and Helm providers thomasthornton.cloud/2022/11/09/building-and-deploying-to-an-aks-cluster-using-terraform-and-azure-devops-with-kubernetes-and-helm-providers I have a few blogs now on deploying Azure Kubernetes Services (AKS) with different scenarios, such as deploying AKS with Application Gateway Ingress, in this blog post I am going to be building and deploying to an AKS cluster using Terraform and Azure DevOps. You will also have noticed in the title, it references both Kubernetes and Helm providers – we will be looking at how Terraform can be used to deploy to AKS as well once deployed. I am huge fan of GitOps within AKS, but to test an application or small environment; this way could certainly be useful! What will Terraform be deploying? Initially Terraform will be used to deploy the AKS environment: Virtual Network Log Analytics AKS cluster The initial terraform code for this, can be found [HERE]. In this blog post, I won’t go deeper into the deployment of AKS as I have covered this more in various other blogs, feel free to check these out Azure DevOps Pipeline As with most my pipelines, I utilise the use of variables alot , review these [HERE] The Azure DevOps pipeline will consists of 4 stages: terraform_plan: Running the action: plan will run this stage and output a plan for the above terraform terraform_apply: Running the action: apply will run this stage and apply the above terraform
  • 2. 12/11/2022, 07:09 Building and deploying to an AKS cluster using Terraform and Azure DevOps with Kubernetes and Helm providers – Thomas Thornton https://thomasthornton.cloud/2022/11/09/building-and-deploying-to-an-aks-cluster-using-terraform-and-azure-devops-with-kubernetes-and-helm-providers/ 2/7 bootstrap: Running the action: apply will run this stage and run the below Terraform using Kubernetes and Helm Providers terraform_destroy: Running the action: destroy will destroy the environment Full pipeline can be found [HERE] Deploying to Kubernetes with Terraform using Kubernetes and Helm providers Once this has been deployed, lets look at using Terraform with the Kubernetes & Helm providers to deploy an example namespace and basic redis helm chart The folder structure for this Terraform will be two files: 1 2 3 terraform-module-example └── main.tf └── providers.tf Lets look at providers.tf , notice the reference to the helm & kubernetes providers along with config_path ?
  • 3. 12/11/2022, 07:09 Building and deploying to an AKS cluster using Terraform and Azure DevOps with Kubernetes and Helm providers – Thomas Thornton https://thomasthornton.cloud/2022/11/09/building-and-deploying-to-an-aks-cluster-using-terraform-and-azure-devops-with-kubernetes-and-helm-providers/ 3/7 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 provider "helm" { kubernetes { config_path = "/home/vsts/.kube/config" } } provider "kubernetes" { config_path = "/home/vsts/.kube/config" config_context = "tamopsakstest-admin" } terraform { backend "azurerm" { } } To configure how the config_path is setup, it is the kubernetes context path – I have achieved this by using running some Azure CLI within my aks_cluster_config stage here Example output: 1 2 3 4 5 6 /usr/bin/az account set --subscription 04109105-f3ca-44ac-a3a7-66b4936112c3 /usr/bin/bash /home/vsts/work/_temp/azureclitaskscript1667379970075 .sh + AKS_RG=tamopsakstest-rg + AKS_NAME=tamopsakstest + az aks get-credentials -g tamopsakstest-rg -n tamopsakstest --admin WARNING: Merged "tamopsakstest-admin" as current context in /home/vsts/ .kube /config Great! Now that the context is setup and config_path’s are setup, it’s time to deploy some example resources that can be deployed by these providers. I will be deploying a example Kubernetes namespace & helm release as below:
  • 4. 12/11/2022, 07:09 Building and deploying to an AKS cluster using Terraform and Azure DevOps with Kubernetes and Helm providers – Thomas Thornton https://thomasthornton.cloud/2022/11/09/building-and-deploying-to-an-aks-cluster-using-terraform-and-azure-devops-with-kubernetes-and-helm-providers/ 4/7 1 2 3 4 5 6 7 8 9 10 11 12 13 resource "kubernetes_namespace" "test" { metadata { name = "test" } } resource "helm_release" "redis" { name = "redis" repository = "https://charts.bitnami.com/bitnami" chart = "redis" namespace = "test" } Reviewing the apply stage, we can see its planning to create these two resources (log output) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Terraform will perform the following actions : + resource "helm_release" "redis" { + atomic = false + chart = "redis" + cleanup_on_fail = false + create_namespace = false + dependency_update = false + disable_crd_hooks = false + disable_openapi_validation = false + disable_webhooks = false + force_update = false + id = (known after apply) + lint = false + manifest = (known after apply) + max_history = 0 + metadata = (known after apply) + name = "redis" + namespace = "test" + pass_credentials = false + recreate_pods = false
  • 5. 12/11/2022, 07:09 Building and deploying to an AKS cluster using Terraform and Azure DevOps with Kubernetes and Helm providers – Thomas Thornton https://thomasthornton.cloud/2022/11/09/building-and-deploying-to-an-aks-cluster-using-terraform-and-azure-devops-with-kubernetes-and-helm-providers/ 5/7 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 + render_subchart_notes = true + replace = false + repository = "https://charts.bitnami.com/bitnami" + reset_values = false + reuse_values = false + skip_crds = false + status = "deployed" + timeout = 300 + verify = false + version = "17.3.7" + resource_version = (known after apply) + uid = (known after apply) } } Output of log:
  • 6. 12/11/2022, 07:09 Building and deploying to an AKS cluster using Terraform and Azure DevOps with Kubernetes and Helm providers – Thomas Thornton https://thomasthornton.cloud/2022/11/09/building-and-deploying-to-an-aks-cluster-using-terraform-and-azure-devops-with-kubernetes-and-helm-providers/ 6/7 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 kubernetes_namespace. test : Creating... kubernetes_namespace. test : Creation complete after 0s [ id = test ] helm_release.redis: Creating... helm_release.redis: Still creating... [10s elapsed] helm_release.redis: Still creating... [20s elapsed] helm_release.redis: Still creating... [30s elapsed] helm_release.redis: Still creating... [40s elapsed] helm_release.redis: Still creating... [50s elapsed] helm_release.redis: Still creating... [1m0s elapsed] helm_release.redis: Still creating... [1m10s elapsed] helm_release.redis: Still creating... [1m20s elapsed] helm_release.redis: Still creating... [1m30s elapsed] helm_release.redis: Still creating... [1m40s elapsed] helm_release.redis: Still creating... [1m50s elapsed] helm_release.redis: Still creating... [2m0s elapsed] helm_release.redis: Still creating... [2m10s elapsed] helm_release.redis: Still creating... [2m20s elapsed] helm_release.redis: Still creating... [2m30s elapsed] helm_release.redis: Creation complete after 2m38s [ id =redis] Great! We have successfully deployed a Kubernetes environment in Azure along with using the Helm & Kubernetes terraform providers to deploy an example namespace & Helm Chart! Finally, logging into the AKS cluster , we can see both the namespace & redis helm released has been deployed successfully Namespace: redis helm release:
  • 7. 12/11/2022, 07:09 Building and deploying to an AKS cluster using Terraform and Azure DevOps with Kubernetes and Helm providers – Thomas Thornton https://thomasthornton.cloud/2022/11/09/building-and-deploying-to-an-aks-cluster-using-terraform-and-azure-devops-with-kubernetes-and-helm-providers/ 7/7 Although this is a concept – depending on your environment, I do recommend looking at GitOps for your Kubernetes cluster; especially when deploying at scale! Thanks for reading, another one of my blogs – as always, any queries do reach out!