Labels
- A label is a key value pair that can be applied to any kubernetnes object
- This can be used for querying objects
- To add labels in manifest, refer metadata section.
- Refer Here for official docs
- manifest
---
apiVersion: v1
kind: Pod
metadata:
name: one
labels:
app: nginx
env: dev
project: learning
spec:
containers:
- name: web
image: nginx
resources:
requests:
cpu: 100m
memory: 10M
limits:
cpu: 500m
memory: 128M
---
apiVersion: v1
kind: Pod
metadata:
name: two
labels:
app: nginx
env: qa
project: learning
spec:
containers:
- name: web
image: nginx
resources:
requests:
cpu: 100m
memory: 10M
limits:
cpu: 500m
memory: 128M
---
apiVersion: v1
kind: Pod
metadata:
name: three
labels:
app: nginx
env: uat
project: learning
spec:
containers:
- name: web
image: nginx
resources:
requests:
cpu: 100m
memory: 10M
limits:
cpu: 500m
memory: 128M

- Once labels are applied we can query them using selectors
-
Selectors are of two types
- Equality Based: Two major operations equals & not equals
- Set Based:
- in
- notin
- exists
- doesnot exists
-
Query using
kubectl get po
kubectl get po -l 'env = dev'
kubectl get po -l 'env in (dev,qa)'
Usecases
- My pod requires some service to be up & then it should start
- types of containers in pod
- How to ensure pods are running
- controller objects
- replica set
- deployments => zero down time & rollbacks
- daemonset
- How to run batch jobs
- How about rather than static replicas i need dynamic => Autoscalers
- Load balancing/Service Interactions
- Service
- Ingress
- Exposing the services to external world
- Loadbalancers
- Port forwarding
- Storage Solutions:
- Persistent Volumes
- Controller:
- Configuration & Secrets
- configmaps
- secrets
- vaults (secret vaults)
- Administrative:
- backup
- upgrade
- Authentication & Authorization
- Network policies
- Manifest => Static YAML , To enable Dyanmic YAML
- GitOps:
- Troubleshooting: (Observability)
- Monitor
- Prometheus & Grafana
- Security:
- Service Mesh