- {
- "id": "/subscriptions/<guid>/resourceGroups/myResourceGroup",
- "location": "eastus",
- "managedBy": null,
- "name": "myResourceGroup",
- "properties": {
- "provisioningState": "Succeeded"
- },
- "tags": null
- }
Step 4 :
Create Azure Kubernetes Cluster
Run the code
- az aks create --resource-group myResourceGroup --name myAKSCluster --node-count 1 --enable-addons monitoring –generate-ssh-keys
Step 5:
Connect to the Cluster
Run the code
Then, run the code
- az aks get-credentials --resource-group myResourceGroup --name myAKSCluster
(This command downloads credentials and configures the Kubernetes CLI)
(This command is to return a list of the cluster nodes.)
You get the following output :
NAME STATUS ROLES AGE VERSION
aks-nodepool1-31718369-0 Ready agent 6m44s v1.12.8
- NAME STATUS ROLES AGE VERSION
- aks-nodepool1-31718369-0 Ready agent 6m44s v1.12.8
Step 6:
Run the application
- apiVersion: apps/v1
- kind: Deployment
- metadata:
- name: azure-vote-back
- spec:
- replicas: 1
- selector:
- matchLabels:
- app: azure-vote-back
- template:
- metadata:
- labels:
- app: azure-vote-back
- spec:
- nodeSelector:
- "beta.kubernetes.io/os": linux
- containers:
- - name: azure-vote-back
- image: redis
- resources:
- requests:
- cpu: 100m
- memory: 128Mi
- limits:
- cpu: 250m
- memory: 256Mi
- ports:
- - containerPort: 6379
- name: redis
- ---
- apiVersion: v1
- kind: Service
- metadata:
- name: azure-vote-back
- spec:
- ports:
- - port: 6379
- selector:
- app: azure-vote-back
- ---
- apiVersion: apps/v1
- kind: Deployment
- metadata:
- name: azure-vote-front
- spec:
- replicas: 1
- selector:
- matchLabels:
- app: azure-vote-front
- template:
- metadata:
- labels:
- app: azure-vote-front
- spec:
- nodeSelector:
- "beta.kubernetes.io/os": linux
- containers:
- - name: azure-vote-front
- image: microsoft/azure-vote-front:v1
- resources:
- requests:
- cpu: 100m
- memory: 128Mi
- limits:
- cpu: 250m
- memory: 256Mi
- ports:
- - containerPort: 80
- env:
- - name: REDIS
- value: "azure-vote-back"
- ---
- apiVersion: v1
- kind: Service
- metadata:
- name: azure-vote-front
- spec:
- type: LoadBalancer
- ports:
- - port: 80
- selector:
- app: azure-vote-front
Step 7 :
Deploy the application
- kubectl apply -f azure-vote.yaml
You get the following output:
- deployment "azure-vote-back" created
- service "azure-vote-back" created
- deployment "azure-vote-front" created
- service "azure-vote-front" created
Step 8:
Test the application
- kubectl get service azure-vote-front –watch
You get the following output :
EXTERNAL-IP as pending.
- NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
- azure-vote-front LoadBalancer 10.0.37.27 <pending> 80:30572/TCP 6s
EXTERNAL-IP address changes from pending to an actual public IP address, press CTRL-C
You get the following output :
- azure-vote-front LoadBalancer 10.0.37.27 52.179.23.131 80:30572/TCP 2m
To see the Azure Vote app in action, open a web browser to the external IP address of your service.
Step 9 :
Delete the cluster
Use command
- az group delete --name myResourceGroup --yes --no-wait
Conclusion
That’s all. We have learned about deploying an Azure Kubernetes Service (AKS) cluster using the Azure CLI (Command Line Interface). I hope you understood how to deploy an Azure Kubernetes Service cluster using the Azure CLI on the Azure portal.