Kubernetes Handbook
  • Introduction
  • Prerequisites
    • What is Containerization
    • What is Docker
    • Difference between Docker and VM
  • Features of Kubernetes
    • What is Kubernetes
    • Features of Kubernetes - 1
    • Features of Kubernetes - 2
    • Which Tool to Use for Orchestration
  • Architecture
    • Master Node
    • etcd and kubectl
    • Worker Nodes
  • Pods and Nodes
    • Nodes
    • Pods
  • Controllers
    • Benefits of Controllers
    • Kinds of Controllers
  • Minikube
    • What is Minikube
  • Installation and Running (Mac OS)
    • Installation
    • Running Hello World Application
  • Labels Namespaces and Selectors
    • Labels
    • Namespaces
    • Selectors
  • Health Checks Rollouts and Rollbacks
    • Health Checks
    • Rollouts and Rollbacks
  • Config Maps and Secrets
    • Config Maps
    • Secrets
  • Running Jobs
    • How to Run Jobs
  • Dashboard and Debugging
    • Kubernetes Dashboard
    • Debugging
Powered by GitBook
On this page
  • Labels with Selectors
  • Assigning labels to running Pods

Was this helpful?

  1. Labels Namespaces and Selectors

Labels

PreviousRunning Hello World ApplicationNextNamespaces

Last updated 3 years ago

Was this helpful?

  • Labels are key value pairs attached to pods, deployments, services

  • For users to identify attributes of object

  • Unique per object

Labels with Selectors

Labels with selectors let you identify specific set of objects

  • Equality based selector: labels equal/unequal

  • Set based selector: labels in/not in/exists

  • Used with kubectl

$ kubectl create -f helloworld-pod-with-labels.yml
$ kubectl get pods
$ kubectl get pods - -show-labels

Assigning labels to running Pods

$ kubectl label po/helloworld app=myApp - -overwrite

Overwrites the app name

$ kubectl label po/helloworld author=chandrikadeb7 --overwrite

Overwrites author name

$ kubectl label po/helloworld author- 

Deletes the label author

241B
helloworld-pod-with-labels.yml