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.labelsfield 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: 80Selectors
Types:
- Equality-based:
=!=
- Set-based:
INNOTINEXISTS
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
Defaultnamespace created automatically and objects placed there- Newer applications install their resources in a different namespace