Hi When creating deployment, can I use the flag -l to create labels ? It seems i . . .

Edmund Kueh:
Hi When creating deployment, can I use the flag -l to create labels ? It seems its not possible to use -l with deployment…Can someone explain if I can use the -l flag with all Kubernetes construct like pods, svc, deployments and etc ?

Md Ishaq R:
-l flag is used for selectors not for labels

Edmund Kueh:
Does this mean I cannot add labels imperatively ?

Edmund Kueh:
@Tej_Singh_Rana can you clarify this ?

kiliev:
I would guess that deployment does not support labelling during Imperative creation. Try kubectl label deployment my-deployment key=value

kiliev:
After creating

kiliev:
Or —dry-run=client -o yaml and then use “sed” to replace the default created label everywhere like this sed -i ‘s/app=your-app/key=value/g’ YourYamlFile.yml (or in VI editor with :%s - replace all)

Edmund Kueh:
@kiliev Labelling only works imperatively with pods…Thanks for your advise