pre-requisite
Terraform is installed on your machine
Azure subscription
Kubectl is installed on your machine
Azure cli is installed
Login to Azure using credentials Make sure you are login to Azure portal first.
az login
Choose your Microsoft credentials.
Let's create following tf files using Visual studio Code:
- Variables.tf - where we will define the variables used in main.tf
- terraform.tfvars - Declare the values for the variables
- providers.tf - declare the providers with version
- main.tf - main configuration file with all the resources which will be created
- output.tf - Export some data to output file
- playbook.yml - using ansible to install prometheus ( monithoring tool) and ansible vault ( for encrypting sensitive information)
Run terraform commands
terraform init
terraform plan
terraform validate ( just to make sure the synthax is right)
terraform apply
and type yes
Resources will be created afterwards
###using kubectl to access the kubernetes cluster### Move the generated Kubeconfig file to ~/.kube/config
mv kubeconfig ~/.kube/config
To verify if worker nodes are created, use the kubectl get nodes command to return a list of the cluster nodes.
kubectl get nodes