Exercise: roll out a simple deployment to set up a hosted service

  • Create a deployment.yaml manifest
    • Deploy the Hello Kubernetes container from Docker Hub
    • Label the pods
      • In your spec.template for the deployment you can attach an app label:
        metadata:
          labels:
          app: my-kubernetes-app
        
    • Run the deployment using kubectl
      • kubectl apply -f deployment.yaml
    • Verify the pods have been deployed successfully
      • kubectl get pods
      • kubectl get deployments
  • Create a service.yaml manifest to deploy the service
    • Guidance on authoring service manifests
    • Use the label from earlier to identify the pods that compose your service.
      • In your spec.selector you can refer to the label you created earlier:
          app: my-kubernetes-app
        
  • Test the service using a web browser.

This exercise builds on many of the previous labs for Docker and Terraform, parts 1, 2 and 3. If you’re attempting these exercises without completing the previous labs, you might need to use this Terraform Azure AKS solution to build a Kubernetes cluster to experiment on.

The solution to the ‘Kubernetes deployment and service’ exercise is available as a kubectl/YAML solution as part of our open-source Devops-Workstream.


Leave a comment