Monday, May 11, 2020

AZ and kubectl commands to save a day

kubectl commands run in a context of Azure account. On a fresh machine, one needs to first install az command line and login to azure, with an azure username (in many companies it is a sys account).

az login

when you run

az account show

You should see something similar to:

{ "environmentName": "AzureCloud", "homeTenantId": "ced47777-d73a-4514-a74d-63af7885ff7d", "id": "a75c7777-66c1-4373-a0f3-859abaefcccc", "isDefault": true, "managedByTenants": [], "name": "Company - Development - DEV", "state": "Enabled", "tenantId": "ccc47db0-d73a-4514-a74d-63af7885ff7d", "user": { "name": "ME@mycompany.com", "type": "user" } }

name property is important because it is an active subscription against which kubectl commands will run. You can change it by running:

az account set --subscription "Company - Production - LIVE"

you can pull resource group to be able to manage it, by running:

az aks get-credentials --name platform-aks-dev-ne --resource-group platform-aks-dev-rg-ne

now you are able to manage all pods, by running:

kubectl get pods

or

kubectl get pods -n foo-dev

where foo-dev is a namespace. To get all events you can run

kubectl get events --namespace foo-dev

No comments: