-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarification of prerequisite? #166
Comments
@Guitarkalle please link to the documentation snippet you are referring to |
Sorry.. Added the link to the original post |
Ah, this is a Network Policy question. Moving to Network Policy agent repo |
@Guitarkalle I did some digging here, and the service prerequisite that you are referring to is required to make sure that the service IP shows up in the So when you define a NetworkPolicy to match against a pod selector, the controller reconciles that pod against any service IPs that may need to be added: https://github.com/aws/amazon-network-policy-controller-k8s/blob/main/pkg/resolvers/endpoints.go#L89 In order for the match to happen, the controller validates a few things: https://github.com/aws/amazon-network-policy-controller-k8s/blob/main/pkg/resolvers/endpoints.go#L368:
So the implication of the ports not matching is that the Service IP may be missing from the PolicyEndpoint object. The upstream Kubernetes documentation in this space can be vague, so I think the AWS doc is trying to be explicit and strict to prevent unexpected behavior. Hopefully this answers your question, but please let me know if any part is still confusing. |
Hello @jdn5126 Thanks for the reply. A few more questions if you don't mind. Reading the code, this is only an issue if your networkpolicies are filtering using port I guess? If you omit ports in the networkpolicy the "matching service port" code doesn't run? Maybe I am misunderstanding but in this code: https://github.com/aws/amazon-network-policy-controller-k8s/blob/b2055b4430aaee064375c44ab3c5e63021c97cf1/pkg/k8s/service_utils.go#L13
The implication of this is that traffic could be blocked I guess since the service IP would not be allowed? In general it feels that many third party services could cause issues here since it's not that uncommon to have different serviceport and targetport as well as named ports? Is there a way on EKS to view the network policy agent logs to find if any of these issues exist? |
@Guitarkalle Your understanding seems correct to me. I think this is written as a "requirement" just to reduce complexity and the opportunity for confusion.
Correct, traffic would be blocked if the As for logs, they are written to |
Thanks for the answers. I will close this one |
What happened:
I'm wondering what this requirement really means?
Source: https://docs.aws.amazon.com/eks/latest/userguide/cni-network-policy.html#cni-network-policy-considerations (bullet point aws/amazon-vpc-cni-k8s#5)
So port and targetPort cannot be different in the services? What happens if they are, what are the implications of this?
I tested enabling this feature in the CNI and it seems to work OK even if some of my services have different target ports.
Environment:
kubectl version
): 1.27cat /etc/os-release
): Amazon linux2uname -a
): 5.10The text was updated successfully, but these errors were encountered: