Skip to content

@hashicorp Terraform configuration for provisioning a Azure Kubernetes Service (AKS) cluster.

License

Notifications You must be signed in to change notification settings

anubhavmishra/terraform-azurerm-aks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure Kubernetes Service (AKS) with Terraform

This repository contains HashiCorp Terraform configuration required to create a Azure AKS cluster.

Prerequisites

Clone the Github repository

git clone https://github.com/anubhavmishra/terraform-azurerm-aks.git

Tutorial

Generate Azure client id and secret.

az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/YOUR_SUBSCRIPTION_ID"

Expected output:

{
  "appId": "00000000-0000-0000-0000-000000000000",
  "displayName": "azure-cli-2017-06-05-10-41-15",
  "name": "http://azure-cli-2017-06-05-10-41-15",
  "password": "0000-0000-0000-0000-000000000000",
  "tenant": "00000000-0000-0000-0000-000000000000"
}

appId - Client id. password - Client secret. tenant - Tenant id.

Export environment variables to configure the Azure Terraform provider.

export ARM_SUBSCRIPTION_ID="YOUR_SUBSCRIPTION_ID"
export ARM_TENANT_ID="TENANT_ID"
export ARM_CLIENT_ID="CLIENT_ID"
export ARM_CLIENT_SECRET="CLIENT_SECRET"

Run Terraform init and plan.

cd terraform-azurerm-aks/
terraform init
Initializing the backend...

Initializing provider plugins...

The following providers do not have any version constraints in configuration,
so the latest version was installed.

To prevent automatic upgrades to new major versions that may contain breaking
changes, it is recommended to add version = "..." constraints to the
corresponding provider blocks in configuration, with the constraint strings
suggested below.

* provider.null: version = "~> 2.1"
* provider.tls: version = "~> 2.1"

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
terraform plan
terraform apply

Note: Creating an Azure AKS cluster can take up to 15 minutes.

Configure kubeconfig

Instructions can be obtained by running the following command

terraform output configure

Run the following commands to configure kubernetes client:

$ terraform output kube_config > ~/.kube/aksconfig
$ export KUBECONFIG=~/.kube/aksconfig

Test configuration using kubectl

$ kubectl get nodes

Save kubernetes config file to ~/.kube/aksconfig

terraform output kube_config > ~/.kube/aksconfig

Set KUBECONFIG environment variable to the kubernetes config file

export KUBECONFIG=~/.kube/aksconfig

Test configuration.

kubectl get nodes
NAME                     STATUS   ROLES   AGE   VERSION
aks-default-75135322-0   Ready    agent   18m   v1.13.12
aks-default-75135322-1   Ready    agent   18m   v1.13.12
aks-default-75135322-2   Ready    agent   18m   v1.13.12

About

@hashicorp Terraform configuration for provisioning a Azure Kubernetes Service (AKS) cluster.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages