label selector
A query that picks objects by their labels, such as every pod with app=web; controllers and Services depend on it.
In more detail
A selector is a contract: a Deployment's selector must match the labels in its pod template, or the count never settles. A Service with a selector that matches nothing has no endpoints and times out. On the command line, -l applies a selector to kubectl.
Examples
selector:
matchLabels:
app: webkubectl get pods -l app=webRelated terms
- Kubernetes label — A small key and value pair attached to an object, such as app=web, that other objects and commands use to find it.
- Kubernetes Service — The Kubernetes object that gives a changing set of pods one stable name and address, and spreads traffic across the ready ones.
- Deployment — The Kubernetes object that keeps a chosen number of identical pods running and replaces them gradually when you change their template.
- EndpointSlice — The object that lists the actual pod addresses behind a Service and whether each one is ready.
- NetworkPolicy — A Kubernetes object that controls which pods may send traffic to or receive traffic from which others, by labels, namespaces and IP ranges.
- Kubernetes namespace — A named area inside a cluster that keeps object names apart and groups them for permissions, quotas and policies.
Taught in
- What is GitOps? — Continuous Integration & Continuous Delivery Pipelines
- Rolling Updates and Rollbacks — Continuous Integration & Continuous Delivery Pipelines
- Blue-Green Deployments — Continuous Integration & Continuous Delivery Pipelines
- Rolling Back Blue-Green — Continuous Integration & Continuous Delivery Pipelines
- Generators Write The YAML, You Decide — Certified Kubernetes Administrator (CKA) Exam Prep
- A Service With Nobody Behind It — Certified Kubernetes Administrator (CKA) Exam Prep
- Blocked On Purpose: Opening One Path Through Default Deny — Certified Kubernetes Administrator (CKA) Exam Prep
- Four Faults, Twelve Minutes — Certified Kubernetes Administrator (CKA) Exam Prep
- Helm And Kustomize For Cluster Components — Certified Kubernetes Administrator (CKA) Exam Prep
- Which IP Answers: Pods, Services And NodePorts — Certified Kubernetes Administrator (CKA) Exam Prep
- NetworkPolicy Truth Tables: One Dash Decides — Certified Kubernetes Administrator (CKA) Exam Prep
- Gateway API: A Route Asks, A Gateway Allows — Certified Kubernetes Administrator (CKA) Exam Prep
- Container Logs — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Default Deny, Then Exactly The Doors You Need — Certified Kubernetes Security Specialist (CKS) Exam Prep
- Network Exposure: NodePorts, Host Firewalls And Egress — Certified Kubernetes Security Specialist (CKS) Exam Prep
- Encrypting Pod-to-Pod Traffic: mTLS With Istio And Cilium — Certified Kubernetes Security Specialist (CKS) Exam Prep
- Static Analysis: kubesec And KubeLinter — Certified Kubernetes Security Specialist (CKS) Exam Prep
- Investigating An Attack: One Timeline, Two Logs — Certified Kubernetes Security Specialist (CKS) Exam Prep
- Kubernetes NetworkPolicies & Microsegmentation — Cloud Security & DevSecOps Engineering
- From Docker To Desired State — Kubernetes: Production-Grade Container Orchestration
- Namespaces, Labels And Declarative Manifests — Kubernetes: Production-Grade Container Orchestration
- Deployments, ReplicaSets, Rollouts And Rollback — Kubernetes: Production-Grade Container Orchestration
- DaemonSets And Node Services — Kubernetes: Production-Grade Container Orchestration
- ClusterIP, Selectors, EndpointSlices And DNS — Kubernetes: Production-Grade Container Orchestration
- NodePort, LoadBalancer And ExternalName — Kubernetes: Production-Grade Container Orchestration
- NetworkPolicy And The Consul Service Mesh Boundary — Kubernetes: Production-Grade Container Orchestration
- Troubleshooting: DNS, Empty Endpoints And Broken Routes — Kubernetes: Production-Grade Container Orchestration