Namespaces and Labels for Organization
Organize cluster resources using namespaces for isolation and labels plus selectors for grouping and querying objects.
Namespaces and Labels for Organization is a free DevOps Bootcamp lesson on CoddyKit. This is lesson 4 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, and your progress syncs across the web and the CoddyKit app. The DevOps Bootcamp course includes 4 lessons in total.
Why Organize?
A real cluster runs many apps from many teams. Namespaces and labels are Kubernetes built-in tools for keeping all those objects tidy and queryable.
What Is a Namespace?
A namespace is a virtual cluster inside your cluster. Resource names must be unique within a namespace, but the same name can repeat across namespaces.
Default Namespaces
Every cluster ships with a few: default (where your objects land unless told otherwise), kube-system (cluster components), and kube-public.
kubectl get namespacesCreating a Namespace
Make a new namespace to separate, say, a team or an environment.
kubectl create namespace team-aWorking in a Namespace
Target a namespace per command with -n, or set a default for your context so you stop repeating the flag.
kubectl get pods -n team-aNamespaces Are Not Full Isolation
Namespaces scope names and enable quotas and RBAC, but by themselves they do not isolate network traffic - you add NetworkPolicies for that.
What Are Labels?
Labels are key/value pairs attached to objects. They carry meaning for users - like app: web or env: prod - and power grouping.
metadata:
labels:
app: web
env: prodAdding Labels with kubectl
Attach a label to an existing object on the fly.
kubectl label pod nginx tier=frontendSelecting by Label
Query objects by label with -l. This is how you act on whole groups at once.
kubectl get pods -l app=web,env=prodSelectors Wire Things Together
Labels are not just for humans: Services and Deployments use label selectors to find the Pods they manage. This loose coupling is core to Kubernetes.
selector:
matchLabels:
app: webAnnotations vs Labels
Annotations also store key/value data, but for non-identifying metadata (build info, tooling hints) and are not used by selectors.
Quick Check
What is the difference between labels and namespaces?
Recap
You can now keep a cluster organized:
- Namespaces scope names and enable quotas/RBAC; target them with
-n - Labels are key/value tags; query with
-l - Selectors link Services and Deployments to Pods
- Annotations hold non-identifying metadata
These primitives scale from one app to a busy multi-team cluster.
Learn DevOps Bootcamp with an AI tutor — free
Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.
- Courses
- 142
- Lessons
- 568
Frequently Asked Questions
Is the “Namespaces and Labels for Organization” lesson free?
Yes — any 3 lessons of the DevOps Bootcamp learning path, including “Namespaces and Labels for Organization”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The DevOps Bootcamp course includes 4 lessons in total.
What will I learn in “Namespaces and Labels for Organization”?
Organize cluster resources using namespaces for isolation and labels plus selectors for grouping and querying objects. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start DevOps Bootcamp?
No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 4 of 4.
How long does the “Namespaces and Labels for Organization” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this DevOps Bootcamp lesson?
Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Kubernetes Architecture
- Pods: The Smallest Units
- kubectl Commands Essentials
- Namespaces and Labels for Organization