Skip to content
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

NetworkPolicy with matchExpressions is not applied to matching pods #2006

Closed
minrk opened this issue Dec 4, 2020 · 15 comments
Closed

NetworkPolicy with matchExpressions is not applied to matching pods #2006

minrk opened this issue Dec 4, 2020 · 15 comments

Comments

@minrk
Copy link

minrk commented Dec 4, 2020

What happened:

NetworkPolicy with matchExpressions is not applied to matching pods

What you expected to happen:

NetworkPolicy with matchExpressions is applied to matching pods

How to reproduce it (as minimally and precisely as possible):

  1. create a network policy with:
    matchExpressions:
      - key: component
        operator: In
        values:
          - first-value
          - second-value
  1. create a pod with:
labels:
  component: first-value
  1. verify whether network policy is applied. It will not be.

I used this policy to deny-all egress:

spec:
  egress: []
  podSelector:
    matchExpressions:
    - key: component
      operator: In
      values:
      - first-value
      - second-value
  policyTypes:
  - Egress

and tested with curl https://example.com. It should be blocked. If the policy is applied, it is blocked. If the policy is not applied, it is not blocked. Interestingly, if matchExpressions values list has only one item, it is applied correctly. But if there are two or more items, matching pods are not considered to be matching pods, and no restrictions are applied. matchLabels and other selectors are applying as expected.

Anything else we need to know?:

Environment:

  • Kubernetes version (use kubectl version): v1.16.10
  • Size of cluster (how many worker nodes are in the cluster?): 6
  • General description of workloads in the cluster (e.g. HTTP microservices, Java app, Ruby on Rails, machine learning, etc.) web app: running https://mybinder.org via https://github.com/juptyerhub/mybinder.org-deploy, but I think any cluster running azure-npm will have this issue
  • Others: azure-npm image: mcr.microsoft.com/containernetworking/azure-npm:v1.1.8

original discovery of the issue: jupyterhub/mybinder.org-deploy#1468

@ghost ghost added the triage label Dec 4, 2020
@ghost
Copy link

ghost commented Dec 4, 2020

Hi minrk, AKS bot here 👋
Thank you for posting on the AKS Repo, I'll do my best to get a kind human from the AKS team to assist you.

I might be just a bot, but I'm told my suggestions are normally quite good, as such:

  1. If this case is urgent, please open a Support Request so that our 24/7 support team may help you faster.
  2. Please abide by the AKS repo Guidelines and Code of Conduct.
  3. If you're having an issue, could it be described on the AKS Troubleshooting guides or AKS Diagnostics?
  4. Make sure your subscribed to the AKS Release Notes to keep up to date with all that's new on AKS.
  5. Make sure there isn't a duplicate of this issue already reported. If there is, feel free to close this one and '+1' the existing issue.
  6. If you have a question, do take a look at our AKS FAQ. We place the most common ones there!

@ghost
Copy link

ghost commented Dec 6, 2020

Triage required from @Azure/aks-pm

@ghost
Copy link

ghost commented Dec 11, 2020

Action required from @Azure/aks-pm

@ghost ghost added the Needs Attention 👋 Issues needs attention/assignee/owner label Dec 11, 2020
@ghost
Copy link

ghost commented Dec 27, 2020

Issue needing attention of @Azure/aks-leads

7 similar comments
@ghost
Copy link

ghost commented Jan 11, 2021

Issue needing attention of @Azure/aks-leads

@ghost
Copy link

ghost commented Jan 26, 2021

Issue needing attention of @Azure/aks-leads

@ghost
Copy link

ghost commented Feb 10, 2021

Issue needing attention of @Azure/aks-leads

@ghost
Copy link

ghost commented Feb 25, 2021

Issue needing attention of @Azure/aks-leads

@ghost
Copy link

ghost commented Mar 13, 2021

Issue needing attention of @Azure/aks-leads

@ghost
Copy link

ghost commented Mar 28, 2021

Issue needing attention of @Azure/aks-leads

@ghost
Copy link

ghost commented Apr 12, 2021

Issue needing attention of @Azure/aks-leads

@miwithro
Copy link
Contributor

@minrk have you upgraded your cluster? If not, can you upgrade to the the latest and try the config again?

@ghost ghost added action-required and removed action-required Needs Attention 👋 Issues needs attention/assignee/owner labels Apr 12, 2021
@ghost
Copy link

ghost commented Apr 14, 2021

Triage required from @Azure/aks-pm

@minrk
Copy link
Author

minrk commented Apr 15, 2021

@miwithro we had to teardown our cluster and start again with calico, which has the right behavior. We no longer have a cluster with azure-npm to test with.

@paulgmiller
Copy link
Member

@mirnk @miwithro clsing this in favor of #851 above.

@ghost ghost locked as resolved and limited conversation to collaborators May 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants