Estimated time: 20 minutes for task
Create a Kubernetes manifest and deploy it to an Azure Kubernetes service.
For this requirement you will create a manifest file to deploy the custom image stored in your ACR. You will deploy three instances of the container with a load balanced front end.
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: pythonserver
spec:
replicas: 3
template:
metadata:
labels:
app: pythonserver
spec:
nodeSelector:
"beta.kubernetes.io/os": linux
containers:
- name: service
image: <your ACR server>/taskimage:1.0
ports:
- containerPort: 80
resources:
requests:
cpu: 250m
limits:
cpu: 500m
---
apiVersion: v1
kind: Service
metadata:
name: service-endpoint
spec:
type: LoadBalancer
ports:
- port: 80
selector:
app: pythonserver
Note: Be sure to use your ACR server name for the image attribute. Also, be very careful with indentation, yaml is a bit picky.
For this requirement you will use the Kubernetes CLI (kubectl) to deploy your manifest file. The steps below assume you are using the Azure bash cloud shell to complete the requirement. If you have both the Azure CLI and the Kubernetes CLI installed locally, you can complete the requirement locally.
az aks get-credentials -n kubernetes -g 'task-kubernetes'
kubectl apply -f ./task-kube-app.yaml
For this requirement you will monitor the kubernetes service to verify that the pods are running and that the service gets a public IP address. You will then browse to the public IP address and confirm that you get the expected result.
kubectl get pod
kubectl get service service-endpoint --watch
Note: Once the public IP shows up, press Ctrl-C to step watching.
Note: Refreshing the page should return a different result. Each pod (instance) is assigned a different host name and the service will "round-robin" between them.
Note: Other tasks use a virtual machine with Docker installed and this registry. If you plan on completing other container related exercises, you may want to de-allocate the virtual machine rather than removing it, likewise you may not want to delete the registry yet.
Having trouble completing this task? View the demonstration video to see how to do it.