k8s

K8s Selectors and Labels

January 15, 2022  -   3 mins read time -   514 words -  garrardkitchen

kubernetes, k8s, deployment, pod, replicaset, selectors, equality-based, set-based, kubectl

Right, what’s the deal with all the labels and metadata in a Deployment manifest?!!!! Take this example: apiVersion: apps/v1 kind: Deployment metadata: namespace: default name: nginx-deployment labels: app: nginx spec: replicas: 3 selector: matchLabels: app: nginx foo: baa template: metadata: labels: app: nginx foo: baa spec: containers: - name: nginx image: nginx:1.14.2 ports: - containerPort: 80 Here, we see metadata twice, and also there’s mention of matchLabels in selector??? What does it all mean? ...