Pod with same label keys

Is it possible to have a pod with label and with the same key but different values.For example, app=db and app=web.
In CKAD exam, I came across a question where 2 network policies need to select the same pod but cannot edit the policies. One network policy had podselector as app=db whereas other had app=web

hi @vikrammsaini,

Labels are a map[string]string so you are correct, this is not possible.

Hi ,

May be the solution is to spin up two pods each with different app code but the containers and code remain the same

I just took the CKAD and had the same question…I was unable to add both labels to the pod so that it would be selected by both network policies. What I ended up doing was only using 1 network policy and I modified the labels of the pods that the ingress and egress was set to select to both use that same label. Not sure if I will get credit for it but I didnt know another way to do it. I didnt modify the network polices as the question stated.

I also had this question in the exam and did not know how to solve it. We have two network policies, one with podSelector app=storage and the other one with podSelector app=proxy. We are not allowed to change the policies or create new ones. We have a pod where both of them should be applied to, but how would you do this? This does not seem to be possible? Does someone have an idea how to solve this?