Skip to content

Create an AKS cluster with Terraform and deploy K8s to it using pipelines constructed out of template files.

License

Notifications You must be signed in to change notification settings

RustyTake-Off/aks-terraform-k8s-pipeline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aks-terraform-k8s-pipeline

Remember to look around all the folders, files and change things to your own liking.

Create an AKS cluster with Terraform and deploy K8s to it using pipelines constructed out of template files.

Prerequisites

Azure DevOps Account

Create Azure resources:

  • Resource Group
az group create --name "prrgazpro05" --location "westeurope"
  • Azure Storage Account
az storage account create --name "prstraccazpro05" --resource-group "prrgazpro05" --location "westeurope" --sku Standard_LRS
  • Azure Storage Account Container
az storage container create --name "prcontazpro05" --account-name "prstraccazpro05"

or run one of the prerequisites scripts.

The What?

Infrastructure

Terraform is used to create example infrastructure: Resource Group, Network, Log Analytics Workspace, User Identity, Roles and Aks. Its mostly reused from previous mini projects though slightly modified for this one.

Variables for Terraform are in the infra_variables folder divided further into dev and production.

K8s

K8s deployment is an example from previous mini projects.

Pipeline

The pipeline is constructed from separate templates so its easier to put together and maintain. Templates are separated similarly how you would use Terraform.

init => validate => plan => apply => destroy

Kubernetes is deployed with its own template that can be placed after terraform apply stage.

There's also a template for Checkov which scans Terraform code for any misconfigurations and potential vulnerabilities. It's best to run security scans before deploying resources.

Change all the necessary variables.

variables:
  - name: backendServiceArm
    value: "" # Subscription
  - name: backendAzureRmResourceGroupName
    value: "prrgazpro05"
  - name: backendAzureRmStorageAccountName
    value: "prstraccazpro05"
  - name: backendAzureRmContainerName
    value: "prcontazpro05"
  - name: backendAzureRmKey
    value: "aztfpro05.tfstate"
  - name: environment
    value: "production"
  - name: workingDirectory
    value: "$(System.DefaultWorkingDirectory)/infra/"
  - name: terraformVersion
    value: "latest"
  - name: action
    value: ${{ parameters.Action }}

And play around with the stages.

About

Create an AKS cluster with Terraform and deploy K8s to it using pipelines constructed out of template files.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published