az terraform git kubectl cheat sheet

To log in into the az module

az login

To List Available Subscriptions –

az account list -o table --all

you can see az login is going to a default subscription

To Set a Specific Subscription copy the subscription ID and set it.

az account set --subscription e08f63cf-xxxx-44e3-ba41-xxxxxxx

Creating a test resource group using az command in UAE north for example –

RESOURCEGROUP=testaks
az group create -n $RESOURCEGROUP -l uaenorth

Login to test aks cluster for example

az aks get-credentials --admin --name akscluster --resource-group testaks

To get nodes / pods / describe the pod / get services

kubectl get nodes
kubectl get pods
kubectl describe pods
kubectl get services

Test asp net app YAML file with the integrated application gateway

 kubectl apply -f https://raw.githubusercontent.com/Azure/application-gateway-kubernetes-ingress/master/docs/examples/aspnetapp.yaml 

Yaml file backup

apiVersion: v1
kind: Pod
metadata:
name: aspnetapp
labels:
app: aspnetapp
spec:
containers:
- image: "mcr.microsoft.com/dotnet/core/samples:aspnetapp"
name: aspnetapp-image
ports:
- containerPort: 80
protocol: TCP

---

apiVersion: v1
kind: Service
metadata:
name: aspnetapp
spec:
selector:
app: aspnetapp
ports:
- protocol: TCP
port: 80
targetPort: 80

---

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: aspnetapp
annotations:
kubernetes.io/ingress.class: azure/application-gateway
spec:
rules:
- http:
paths:
- path: /
backend:
serviceName: aspnetapp
servicePort: 80

To get inside Pod

kubectl exec -it aspnetapp -- /bin/bash

To delete the pod

kubectl delete pods

az login via proxy

$env:HTTPS_PROXY='195.229.203.94:10391'

Git to work via proxy –

git config --global http.proxy http://195.229.203.94:10391

Initial Git Config


git config --global user.name "Sathesh Manoharan"
git config --global user.email info@azure365pro.com

Terraform Init

Init – Run from ACF Folder – PS C:\repo\ACF> when your main.tf file is

terraform init .\Workloads\subs-conn-prod\infrastructure\1.0\

Plan from workspace folder – C:\repo\workspaces>

terraform plan -out plan.tfplan -var-file ..\ACF\Workloads\subs-prod\infrastructure\1.0\input_variables.tfvar ..\ACF\Workloads\subs-prod\infrastructure\1.0\

Git Sample commands –

git pull
git add * or git add.
git commit
git push

To use a remote state from local computer

terraform {
backend "azurerm" {
resource_group_name = "az-azure365pro-iac-rg"
storage_account_name = "azazure365proiacsta"
container_name = "subs-prod"
key = "infrastructure-sub-prod.tfstate"
access_key = "9qyXAiYxxxxxxxxxxxeirLlKBXCZ3PAlKnuXYYxxxxxxxxxxxxxSphy+pj6fCMP2QSLaDfmuY1f2T0BjgQ=="
}
}

Key Vault Secret Config using AZ commands

az keyvault secret set --vault-name az-azure365pro-tf-kv --name sp-client-id --value xxxxx-19e2-4b37-bd22-48d364a7ab80
az keyvault secret set --vault-name az-azure365pro-tf-kv --name sp-client-secret --value xxxxxxxx~~hKZMB6Wa0j0xxx.1OCts65
az keyvault secret set --vault-name az-azure365pro-tf-kv --name sp-tenant-id --value xxxxxxx-9352-4fa4-xxxx-112da2837c29
az keyvault secret set --vault-name az-azure365pro-tf-kv --name sp-subscription-id --value xxxxxx-b524-46f9-aa1a-3c583ee00d65</pre>

az keyvault secret set --vault-name az-azure365pro-tf-kv --name sp-key-1 --value xxxxxx-b524-46f9-aa1a-xxxxxxxxx
az keyvault secret set --vault-name az-azure365pro-tf-kv --name sp-key-2 –value xxxxxxxxxxxxxxxxxxxxMirqY58sJAdB0bwFLPogQt/95cWWPnbwnpCbYtUnvxMYJ+c/Q==

Storage Accounts Recommended Configuration –

  • Turn ON No Delete locks
  • Turn ON Versioning
  • Turn on Soft delete for 60 days
  • Turn on Point in time restore for containers

About Satheshwaran Manoharan

Satheshwaran Manoharan is an Microsoft Office Server and Services MVP , Publisher of Azure365pro.com. Specialized in Office365 / Microsoft Exchange / Virtualization , Sathesh is an Messaging Expert supporting/Designing/Deploying many medium size businesses to large enterprises when it comes to Corporate messaging and Virtualization Infrastructure

Check Also

az Git Terraform configs to work behind Proxy

Let’s see how to configure proxy for az Git and Terraform behind an authenticated proxy …

Leave a Reply

Your email address will not be published.