Note: A number of resources created in this demo have names that must be globally unique (e.g. ACR endpoints). In those cases the commands will include a placeholder value noted within angle brackets <> to signal that a value specific to your environment needs to be provided.
Note: If you already have ssh keys in your home directory, then you should use those keys on the command line rather then allowing the CLI to create new keys which will overwrite any existing keys in your home/.ssh directory.
The following steps will create the Kubernetes cluster using command line commands:
If you don’t have it installed locally, follow the guide here to install Azure CLI v2 on your local machine.
NOTE: For simplicity’s sake, we will use the same name for the Resource Group and the DNS Prefix. To prevent DNS name collisions, make sure to suffix RESOURCE_GROUP with your username. e.g. RESOURCE_GROUP=my-k8s-cluster-thfalgou
RESOURCE_GROUP=my-k8s-cluster-<USER>
az group create --name $RESOURCE_GROUP --location southcentralus
az acs create --name $RESOURCE_GROUP --resource-group $RESOURCE_GROUP --orchestrator-type Kubernetes --dns-prefix $RESOURCE_GROUP --generate-ssh-keys
The above command will use ACS to create a new Kubernetes cluster named “my-k8-cluster” within the newly created resource group. The orchestrator-type parameter indicates to ACS that you are creating a kubernetes cluster with a dns parameter and to generate new ssh keys and service principals.
If not already installed, you can use the cli to install the k8 command line utility (kubectl).
Note: On Windows you need to have opened the command windows with Administrator rights as the installation tries write the program to “C:\Program Files\kubectl.exe”. You may also have to add “C:\Program Files” to your PATH
az acs kubernetes install-cli
The kubectl application requires configuration data which includes the cluster endpoint and credentails. The credentails are created on the cluster admin server during installation and can be downloaded to your machine using the get-credential subcommand.
az acs kubernetes get-credentials --resource-group=$RESOURCE_GROUP --name=$RESOURCE_GROUP
After downloading the cluster configuration you should be able to connect to the cluster using kubectl. For example the cluster-info command will show details about your cluster.
kubectl cluster-info