Deploy to Azure Kubernetes Service Cluster (AKS)

This example is done using Azure Cloud Shell but you can just use azcli.

create deployment.yaml

# deployment.yaml
apiVersion: apps/v1 # api resource where this workload resides
kind: Deployment # kind of workload we are creating
metadata:
  name: contoso-website # name of deployment
spec:
  selector: # Define the wrapping strategy
    matchLabels: # Match all pods with the defined labels
      app: contoso-website # Labels follow the `name: value` template
  template: # This is the template of the pod inside the deployment
    metadata:
      labels: # allows deployments to find and group pods
        app: contoso-website
    spec:
      nodeSelector:
        kubernetes.io/os: linux
      containers: # this is where we define all containers
        - image: mcr.microsoft.com/mslearn/samples/contoso-website
          name: contoso-website
          resources: # specify minimum and max resources app is allowed to use from cluster
            requests:
              cpu: 100m
              memory: 128Mi
            limits:
              cpu: 250m
              memory: 256Mi
          ports:
            - containerPort: 80 # this container exposes port 80
              name: http

Apply the Manifest

kubectl apply -f ./deployment.yaml

Example output: deployment.apps/contoso-website created

Check if deployment succeeded

kubectl get deploy contoso-website

Example output:

NAME              READY   UP-TO-DATE   AVAILABLE   AGE
contoso-website   0/1     1            0           16s

Check if pod running

kubectl get pods

Example output:

NAME                               READY   STATUS    RESTARTS   AGE
contoso-website-7c58c5f699-r79mv   1/1     Running   0          63s