Q.For this question, please set the context to cluster1 by running:
kubectl config use-context cluster1
One of the nginx based pod called cyan-pod-cka28-trb is running under cyan-ns-cka28-trb namespace and it is exposed within the cluster using cyan-svc-cka28-trb service.
This is a restricted pod so a network policy called cyan-np-cka28-trb has been created in the same namespace to apply some restrictions on this pod.
Two other pods called cyan-white-cka28-trb1 and cyan-black-cka28-trb are also running in the default namespace.
The nginx based app running on the cyan-pod-cka28-trb pod is exposed internally on the default nginx port (80).
Expectation: This app should only be accessible from the cyan-white-cka28-trb1 pod.
Problem: This app is not accessible from anywhere.
Troubleshoot this issue and fix the connectivity as per the requirement listed above.
Note: You can exec into cyan-white-cka28-trb and cyan-black-cka28-trb pods and test connectivity using the curl utility.
You may update the network policy, but make sure it is not deleted from the cyan-ns-cka28-trb namespace.
one doubt here why have you kept egress port to be 8080. Shouldn’t it be 80 as the cyan-pod-cka28-trb is exposed on port 80 as mentioned in the question.
Also, everything is same but still i am not able to access svc from cyan-white.
Can you pls check my netpol file, i dont understand why it is not working
I did exactly the same but it didn’t work. The nslookup for the “cyan-svc”.“cyan-ns”.svc.cluster.local also returns NXDOMAIN from the cyan-white pod. please advise
Please revisit the write-up in the post above. There is updated information in there about an intermittent bug - which can be worked around if you learned the manual scheduling topic well
@robertointernet The key thing to remember here is that - adds a new rule, and all the rules are OR-ed together. So if rule 1 allows (namespace selector without pod constraint), OR rule 2 allows (pod selector without namespace constraint), then it’s allow.
Multiple components of a single rule are AND-ed - so must match the pod selector AND the namespace selector to allow. Thus a rule must contain both namespace and pod selectors if you want to allow certain pods only from a given namespace. Then you can add more rules with both in to allow also some pods from another namespace etc.
Get this ingrained and you will nail all pod-based netpol questions which to be fair are most of them!
Once again to everyone, be aware of the intermittent bug in this lab, which is detailed in the solution write-up posted above.