0
0
Azurecloud~30 mins

Deploying workloads to AKS in Azure - Mini Project: Build & Apply

Choose your learning style9 modes available
Deploying workloads to AKS
📖 Scenario: You are working as a cloud engineer for a company that wants to deploy a simple web application on Azure Kubernetes Service (AKS). Your task is to create the necessary Kubernetes deployment and service configuration files step-by-step to deploy the application and expose it to the internet.
🎯 Goal: Build a Kubernetes deployment and service YAML configuration to deploy a web application container on AKS and expose it via a LoadBalancer service.
📋 What You'll Learn
Create a Kubernetes deployment YAML with the exact name webapp-deployment
Use the container image nginx:1.23.3 in the deployment
Set the number of replicas to 3
Create a Kubernetes service YAML named webapp-service of type LoadBalancer
Expose port 80 on the service and target port 80 on the pods
💡 Why This Matters
🌍 Real World
Deploying containerized applications on AKS is a common task for cloud engineers to make applications scalable and accessible.
💼 Career
Understanding how to write Kubernetes deployment and service YAML files is essential for roles like DevOps engineer, cloud engineer, and site reliability engineer.
Progress0 / 4 steps
1
Create the initial deployment YAML
Create a Kubernetes deployment YAML named webapp-deployment with 3 replicas using the container image nginx:1.23.3. Set the container port to 80.
Azure
Need a hint?

Start with apiVersion: apps/v1 and kind: Deployment. Use replicas: 3 and specify the container image and port inside spec.template.spec.containers.

2
Add labels and selectors for the deployment
Add the label app: webapp to both the deployment's metadata.labels and the pod template's metadata.labels. Also add a selector.matchLabels with app: webapp to the deployment spec.
Azure
Need a hint?

Labels help Kubernetes know which pods belong to this deployment. Add app: webapp under metadata.labels and template.metadata.labels. Also add the same label under selector.matchLabels.

3
Create the service YAML to expose the deployment
Create a Kubernetes service YAML named webapp-service of type LoadBalancer. It should select pods with label app: webapp and expose port 80 on the service, targeting port 80 on the pods.
Azure
Need a hint?

Use kind: Service with type: LoadBalancer. The selector must match the deployment's pod label app: webapp. Expose port 80 and target port 80.

4
Add final metadata and comments
Add a comment at the top of the YAML file stating # Kubernetes deployment and service for webapp. Also add a label environment: production under the deployment's metadata.labels.
Azure
Need a hint?

Comments start with #. Add the comment at the very top. Add the label environment: production under metadata.labels in the deployment.