What is Labels in AKS manifest file?

In an AKS (Azure Kubernetes Service) manifest — which is just a standard Kubernetes manifest — a label is a key-value pair attached to Kubernetes objects (like pods, deployments, services, etc.) to organize and select them.

🔖 What is a Label?

Labels are metadata that help you identify and group resources in Kubernetes.

If we dont add any key and value in any pod then by default key is RUN and value is Pod name.

You are a DevOps engineer at a company that runs:

Real-Life Scenario

  • 2 environments: staging and production
  • 3 teams: payments, auth, and reporting
  • Each service has its own pods, services, and deployments

You need a way to:

  • Identify which resources belong to which team
  • Deploy services only to specific environments
  • Set up monitoring, cost tracking, or network policies based on team or environment

Kubernetes Manifest with Labels (Real Example)

Real World Use Cases for These Labels

✅ 1. Routing Traffic via Service

👉 This ensures only the pods in production for payments get traffic.

✅ 2. Cost Management & Reporting

Tools like Kubecost, Azure Monitor, or Datadog use labels to break down billing:

kubectl get pods –all-namespaces -l team=payments

You could analyze how much the payments team spends compared to auth.

3. Security Rules (NetworkPolicies)

You might define a rule like:

“Only frontend pods with label tier=frontend can talk to backend pods with tier=backend and env=staging

✅ 4. Helm or Flux Deployments

If using FluxCD, labels like:

allow GitOps tooling to track and manage deployments cleanly.

Example: Deployment with Labels

PurposeDescription
SelectionServices, deployments, and other controllers use matchLabels to find target pods.
OrganizationHelps group resources (e.g., by app, team, environment).
Monitoring & LoggingTools like Prometheus, Fluent Bit, etc., use labels for filtering data.
Cost ManagementYou can tag workloads by environment or project.

Leave a Comment

Your email address will not be published. Required fields are marked *