I filched these two gems from a much smarter person and am re-posting them here ...
The first relates to Pod labels which, to be honest, I've not paid too much attention.
The original context was to use kubectl to retrieve the IP address of Pods with a specific Label, using nginx as an example.
I've built upon these using Calico Node as an example ...
So I've got two Calico Node pods running inside my cluster: -
kube-system calico-node-kwj42 1/1 Running 0 13d
If I describe each of those Pods, I can retrieve their Labels ...
kubectl describe pod calico-node-jd867 --namespace kube-system
k8s-app=calico-node
pod-template-generation=1
kubectl describe pod calico-node-kwj42 --namespace kube-system
k8s-app=calico-node
pod-template-generation=1
Armed with the Labels, I can query just for Pods using one of those Labels e.g.
kubectl get pods --all-namespaces --selector k8s-app=calico-node
kube-system calico-node-jd867 1/1 Running 3 13d
kube-system calico-node-kwj42 1/1 Running 0 13d
No comments:
Post a Comment