To add a label to a pod in Kubernetes, you can use the following command:
kubectl label pods <pod-name> <label-key>=<label-value>
Example
If you want to add a label environment with the value production to a pod named nginx-deployment-xxx-yyy, you would run:
kubectl label pods nginx-deployment-xxx-yyy environment=production
Notes
- Replace
<pod-name>with the actual name of your pod. - You can add multiple labels by separating them with spaces.
If you have any more questions or need further assistance, feel free to ask!
