Pod Labels and Annotations
What You'll Learn
You'll discover how to use labels to organize and select Pods, and annotations to attach metadata for documentation and tooling.
Labels: Organization Through Key-Value Pairs
Labels are key-value pairs attached to Pods (and other Kubernetes objects) that help you organize and select resources. Think of labels like tags on items in a warehouse—you might tag boxes by department, project, or priority so you can quickly find what you need.
Common label examples:
apiVersion: v1
kind: Pod
metadata:
name: my-app-pod
labels:
app: frontend
environment: production
version: v1.2.0
Labels enable powerful selection. You can query all Pods with app=frontend or environment=production using label selectors (as you learned earlier). This becomes essential when Services, Deployments, or other controllers need to identify which Pods they manage.
Annotations: Non-Identifying Metadata
Annotations store metadata that doesn't identify or select objects. They're for information that tools, humans, or systems need but won't use for grouping resources. Think of annotations as sticky notes with extra details that don't affect how you categorize items.
apiVersion: v1
kind: Pod
metadata:
name: my-app-pod
annotations:
description: "Handles user authentication"
contact: "team-auth@company.com"
build-version: "sha256:abc123..."
Use annotations for build information, contact details, documentation links, configuration hints for monitoring tools, or any descriptive data.
Labels vs Annotations
- Labels: Structured, queryable, used for selection (max 63 chars for values)
- Annotations: Unstructured, not queryable, purely informational (no size limit)
Key Takeaway: Labels organize and select Pods using structured key-value pairs for operational purposes, while annotations store arbitrary metadata for documentation and tooling without affecting resource selection.