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

Add the networkpolicies to cicd tests #2718

Closed
7 tasks done
Tracked by #2763
juliusvonkohout opened this issue May 16, 2024 · 13 comments
Closed
7 tasks done
Tracked by #2763

Add the networkpolicies to cicd tests #2718

juliusvonkohout opened this issue May 16, 2024 · 13 comments
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@juliusvonkohout
Copy link
Member

juliusvonkohout commented May 16, 2024

Validation Checklist

  • Is this a Kubeflow issue?
  • Are you posting in the right repository ?
  • Did you follow the installation guide https://github.com/kubeflow/manifests?tab=readme-ov-file ?
  • Is the issue report properly structured and detailed with version numbers?
  • Is this for Kubeflow development ?
  • Would you like to work on this issue?
  • Join our slack channel using wg-manifests.

Version

master

Describe your issue

We want them especially for the model registry @lampajr

Steps to reproduce the issue

No bug, just an enhancement

Put here any screenshots or videos (optional)

No response

@AndersBennedsgaard
Copy link
Contributor

Currently the CI pipeline uses KinD with its native KindNet CNI. This does not support enforcing NetworkPolicies (it might in the future, according to kubernetes-sigs/kind#842), so we will have to install a separate CNI for this such as Calico. It might also be possible to use the Istio CNI since we already use this: https://github.com/kubeflow/manifests/tree/master/common/istio-cni-1-22

As an alternative we could convert all KinD usage to K3d, since that supports netpols out of the box (using Flannel CNI). It is (in my opinion) also easier to use, since it supports Ingress and is in general just easier to configure

@hansinikarunarathne
Copy link
Member

hansinikarunarathne commented Jul 27, 2024

@juliusvonkohout can you explain this issue bit more and the exact place where we use KinD in manifest?

@hansinikarunarathne
Copy link
Member

I installed the kubeflow in my machine. And when I checked there were multiple network policies are there. And as far as I know Istio CNI supports network policies. Since istio is currently intergrated with the kind cluster, do we need a different plugin? And if so, are the existing network policies not working now?

@juliusvonkohout
Copy link
Member Author

I installed the kubeflow in my machine. And when I checked there were multiple network policies are there. And as far as I know Istio CNI supports network policies. Since istio is currently intergrated with the kind cluster, do we need a different plugin? And if so, are the existing network policies not working now?

Please Test whether the networkpolicies have any effect. You can do so with a pod and curl.

@juliusvonkohout juliusvonkohout linked a pull request Jul 30, 2024 that will close this issue
@hansinikarunarathne
Copy link
Member

I installed the kubeflow in my machine. And when I checked there were multiple network policies are there. And as far as I know Istio CNI supports network policies. Since istio is currently intergrated with the kind cluster, do we need a different plugin? And if so, are the existing network policies not working now?

Please Test whether the networkpolicies have any effect. You can do so with a pod and curl.

@AndersBennedsgaard @juliusvonkohout
I created a new namespace test and enabled Istio for that namespace. Then create an nginx pod, service, and network policy only to allow traffic from the nginx namespace. and busybox pod on the default namespace. I tried to curl from the busybox pod. So, it does not allow us to do so. Give output like the one below

RBAC: access denied

Therefore networkpolicies work with isto. We don't need an external calico plugin to activate networkpolicies. So, we can close the PR #2820

@juliusvonkohout
Copy link
Member Author

juliusvonkohout commented Aug 12, 2024

I installed the kubeflow in my machine. And when I checked there were multiple network policies are there. And as far as I know Istio CNI supports network policies. Since istio is currently intergrated with the kind cluster, do we need a different plugin? And if so, are the existing network policies not working now?

Please Test whether the networkpolicies have any effect. You can do so with a pod and curl.

@AndersBennedsgaard @juliusvonkohout I created a new namespace test and enabled Istio for that namespace. Then create an nginx pod, service, and network policy only to allow traffic from the nginx namespace. and busybox pod on the default namespace. I tried to curl from the busybox pod. So, it does not allow us to do so. Give output like the one below

RBAC: access denied

Therefore networkpolicies work with isto. We don't need an external calico plugin to activate networkpolicies. So, we can close the PR #2820

Are you sure that this is not done by a default authorizationpolicy? did you make sure that nginx does not run with an istio proxy? did you test whether it works if you allow it in the networkpolicy?

@AndersBennedsgaard
Copy link
Contributor

Yes, the RBAC: access denied is an Istio message from AuthorizationPolicies or other Istio rules. If it was a NetworkPolicy, you would receive a timeout. So I think this only works because both of the pods are Istio-enabled and is under some Istio policy. Istio does not handle networking between services that does not have an Istio sidecar, so the Istio CNI is not enough.

I actually found somewhere that the Istio CNI still requires a network plugin (like Calico), for handling the networking necessary for NetworkPolicies and other things. So we still need a network plugin

@hansinikarunarathne
Copy link
Member

I installed the kubeflow in my machine. And when I checked there were multiple network policies are there. And as far as I know Istio CNI supports network policies. Since istio is currently intergrated with the kind cluster, do we need a different plugin? And if so, are the existing network policies not working now?

Please Test whether the networkpolicies have any effect. You can do so with a pod and curl.

@AndersBennedsgaard @juliusvonkohout I created a new namespace test and enabled Istio for that namespace. Then create an nginx pod, service, and network policy only to allow traffic from the nginx namespace. and busybox pod on the default namespace. I tried to curl from the busybox pod. So, it does not allow us to do so. Give output like the one below

RBAC: access denied

Therefore networkpolicies work with isto. We don't need an external calico plugin to activate networkpolicies. So, we can close the PR #2820

Are you sure that this is not done by a default authorizationpolicy? did you make sure that nginx does not run with an istio proxy? did you test whether it works if you allow it in the networkpolicy?

Actually procedure I followed is,

  1. create a test namespace with the Istio enabled
    kubectl create namespace test
    kubectl label namespace test istio-injection=enabled

  2. Create an NGINX pod in that namespace
    kubectl run nginx --image=nginx --labels app=nginx --namespace test --expose --port 80

  3. Create busybox pod in default namespace
    kubectl run busybox --rm -ti --image=alpine -- /bin/sh

  4. And create a network policy that does not allow traffic from other namespaces.

  5. curl to nginx pod from busybox. Then it gives RBAC denied .

So due to enabling Istio in test namespace it does run with the Istio proxy pod
image
So basically it denied because of that reason.

Therefore, we have to add external plugin for managing network policies. I will do so and update you

@aojea
Copy link

aojea commented Aug 16, 2024

kind has released 0.24 that includes network policies https://github.com/kubernetes-sigs/kind/releases/tag/v0.24.0

@juliusvonkohout
Copy link
Member Author

juliusvonkohout commented Aug 16, 2024

kind has released 0.24 that includes network policies https://github.com/kubernetes-sigs/kind/releases/tag/v0.24.0

@hansinikarunarathne this might make your life easier :-D
We can also upgrade the Kubernetes version if necessary.

@hansinikarunarathne
Copy link
Member

kind has released 0.24 that includes network policies https://github.com/kubernetes-sigs/kind/releases/tag/v0.24.0

@hansinikarunarathne this might make your life easier :-D We can also upgrade the Kubernetes version if necessary.

Yes, I checked on it. I will update the Kubernetes version and Kind installation version. I will create a new PR instead of making changes to #2820

@hansinikarunarathne
Copy link
Member

hansinikarunarathne commented Aug 16, 2024

We can close the PR #2820 and merge the PR #2843

@juliusvonkohout if you have any suggestions let me know

@juliusvonkohout
Copy link
Member Author

juliusvonkohout commented Aug 26, 2024

Solved in #2843

@hansinikarunarathne please link PRs to issues on the right hand side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants