AKS/Kubernetes/HELM Cheat Sheet

Switch Azure subscription
az account set --subscription {subscription_id}
Switch AKS credentials
az account set --subscription {subscription_id}
Display current context
kubectl config current-context
List all contexts
kubectl config get-contexts
Switch current context
kubectl config use-context {context_name}
Delete context
kubectl config delete-context {context_name}
Rename context
kubectl config rename-context {old_context_name} {new_context_name}
Display logs from a container
kubectl logs -l {deployment_label}
Display logs from an init container (db migration)
kubectl logs -l {deployment_label} -c {init_container_name}
Display all deployments
helm ls -a
Display information related to deployment
helm get all {deployment_name}
Display deployment status
helm status {deployment_name}
Restart deployment
kubectl rollout restart deployment {deployment_name}
List all pods in namespace
kubectl get pods -n {namespace_name}
Display values for helm deployments
helm get values {deployment_name}
Delete workload from k8 cluster
kubectl delete deployment.apps {workload_name}
Delete service from k8 cluster
kubectl delete service {service_name}
Create deployment using YAML file
kubectl create -f {file_name}

Delete deployment using YAML file

kubectl delete -f {file_name}

Run command on pod in a cluster

kubectl exec -ti {pod_name}

Display pod status

kubectl describe pod {deployment_name}

Get shell to a pod

kubectl exec --stdin --tty {deployment_name} -- /bin/bash

Execute command on pod

docker exec {deployment_name} {command_text}

Show resource labels

kubectl get {resource_name} --show-labels

Stop deployment in a Kubernetes pod

kubectl scale --replicas=0 {deployment_name}

Get all deployments in namespace

kubectl get deployment -n {namespace_name}