Labels

  • Key/Value Pairs that are attached to objects like pods, services and deployments.
  • They are for kubernetes users to identify attributes for objects.
  • Labels are defined in metadata.labels field for the k8s object
apiVersion: v1
kind: Pod
metadata:
  name: label-demo
  labels:
    environment: production
    app: nginx
spec:
  containers:
  - name: nginx
    image: nginx:1.14.2
    ports:
    - containerPort: 80

Selectors

Types:

  • Equality-based:
    • =
    • !=
  • Set-based:
    • IN
    • NOTIN
    • EXISTS

Labels and Selectors are used in kubectl command

Namespaces

  • Great for large enterprises
  • Allows teams to access resources, with accountability. For eg. Order Status Team, Catalog Team etc.
  • provides scope for (object) names - names must be unique in a namespace
  • Default namespace created automatically and objects placed there
  • Newer applications install their resources in a different namespace