AKS with Kubernetes Cheat-sheet

AKS with Kubernetes Cheat-sheet

My work planned to move all our services and website to Kubernetes for better availability, after digging Kubernetes for couple of days I've organized some basic commands.

First of all, there is no GUI interface of Kubernetes with AKS while I'm writing this, so all the commands requires you have atleast basic CLI knowledge.

Login Azure ACR CLI

$ az acr login -n <azure container registry name>

Use AZ AKS CLI To Install kubectl

$ az aks install-cli

Connect AKS CLI With kubectl

INPUT

$ az aks get-credentials -g <resource group name> -n <aks name>

Expected Output

Merged "lxz-aks" as current context in %HOME%\.kube\config

Make Sure AKS CLI Is Connected With kubectl

Input

$ kubectl get nodes

Expected Output

NAME                               STATUS   ROLES   AGE   VERSION
aks-nodepool-38987377-vmss000000   Ready    agent   5d    v1.20.9

Use kubectl To Update Image Version

If -n or --namespace is not provided, default namespace will be applied by default.

$ kubectl set image deployment [-n/--namespace] <deployment> <container>=<repo url>/<repo name>:<tag>

INPUT

$ kubectl set image deployment <deployment> <container>=<acr url>.azurecr.io/<image>:<tag>

Expected Output

If return message is like down below, please provied -n with desired namespace.

No resources found in default namespace.

Message shown if update is success.

deployment.apps/<deployment name> image updated

If there is no message return, which means image has not been modified.

Restart Pod

If return message is like down below, please provied -n with desired namespace.

$ kubectl rollout restart [-n/--namespace] <resource type> <resource name>

INPUT

$ kubectl rollout restart -n <namespace> deployment <deployment name>

Expected Output

deployment.apps/<deployment name> restarted