Skip to content

Commit

Permalink
Add networkpolicies under /contrib/networkpolicies (kubeflow#2121)
Browse files Browse the repository at this point in the history
* Create .gitkeep

* Add files via upload

* Create OWNERS

* Create README.md

* Delete default-deny-not-istio-system.yaml

* Create default-allow-same-namespace.yaml

* Create centraldashboard.yaml

* Create jupyter-web-app.yaml

* Create katib-ui.yaml

* Create kfserving-models-web-app.yaml

* Create ml-pipeline-ui.yaml

* Update ml-pipeline.yaml

* Create volumes-web-app.yaml

* Update kustomization.yaml

* Update OWNERS
  • Loading branch information
juliusvonkohout authored and kimwnasptd committed Feb 15, 2022
1 parent cc964a7 commit 5538d5e
Show file tree
Hide file tree
Showing 20 changed files with 385 additions and 0 deletions.
1 change: 1 addition & 0 deletions contrib/networkpolicies/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

5 changes: 5 additions & 0 deletions contrib/networkpolicies/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
approvers:
- juliusvonkohout
reviewers:
- juliusvonkohout
- kimwnasptd
8 changes: 8 additions & 0 deletions contrib/networkpolicies/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### 1. Why would a user apply the extra policies?
It is a second line of defence after Istio autorization policies and it protects pods and services that are not protected by Istio

### 2. Effects they will have in the cluster
Please consult the name of and comments in each networkpolicy for further information.

### 3. We should achieve the same with AuthorizationPolicies
But there are components, e.g. Katib that are not secured by istio
21 changes: 21 additions & 0 deletions contrib/networkpolicies/cache-server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: cache-server
namespace: kubeflow
spec:
podSelector:
matchExpressions:
- key: app
operator: In
values:
- cache-server # mutating webhook
# https://www.elastic.co/guide/en/cloud-on-k8s/1.1/k8s-webhook-network-policies.html
# The kubernetes api server must reach the webhook
ingress:
- ports:
- protocol: TCP
port: 8443
policyTypes:
- Ingress

23 changes: 23 additions & 0 deletions contrib/networkpolicies/centraldashboard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: centraldashboard
namespace: kubeflow
spec:
podSelector:
matchExpressions:
- key: app
operator: In
values:
- centraldashboard
ingress:
- from:
- namespaceSelector:
matchExpressions:
- key: kubernetes.io/metadata.name
operator: In
values:
- istio-system
- podSelector: {}
policyTypes:
- Ingress
12 changes: 12 additions & 0 deletions contrib/networkpolicies/default-allow-same-namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: default-allow-same-namespace
namespace: kubeflow
spec:
podSelector: {}
ingress:
- from:
- podSelector: {}
policyTypes:
- Ingress
23 changes: 23 additions & 0 deletions contrib/networkpolicies/jupyter-web-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: jupyter-web-app
namespace: kubeflow
spec:
podSelector:
matchExpressions:
- key: app
operator: In
values:
- jupyter-web-app
ingress:
- from:
- namespaceSelector:
matchExpressions:
- key: kubernetes.io/metadata.name
operator: In
values:
- istio-system
- podSelector: {}
policyTypes:
- Ingress
23 changes: 23 additions & 0 deletions contrib/networkpolicies/katib-controller.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: katib-controller
namespace: kubeflow
spec:
podSelector:
matchExpressions:
- key: katib.kubeflow.org/component
operator: In
values:
- controller # katib mutating webhook to add metrics logger
# https://www.elastic.co/guide/en/cloud-on-k8s/1.1/k8s-webhook-network-policies.html
# The kubernetes api server must reach the webhook
ingress:
- ports: # webhook
- protocol: TCP
port: 8443
# - ports: # metrics
# - protocol: TCP
# port: 8080
policyTypes:
- Ingress
23 changes: 23 additions & 0 deletions contrib/networkpolicies/katib-db-manager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: katib-db-manager
namespace: kubeflow
spec:
podSelector:
matchExpressions:
- key: katib.kubeflow.org/component
operator: In
values:
- db-manager # the metrics loggers write directly to this database
ingress:
- from:
- namespaceSelector:
matchExpressions:
- key: app.kubernetes.io/part-of
operator: In
values:
- kubeflow-profile
- podSelector: {} # allow all pods from the same namespace
policyTypes:
- Ingress
22 changes: 22 additions & 0 deletions contrib/networkpolicies/katib-ui.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: katib-ui
namespace: kubeflow
spec:
podSelector:
matchExpressions:
- key: katib.kubeflow.org/component
operator: In
values:
- ui
ingress:
- from:
- namespaceSelector:
matchExpressions:
- key: kubernetes.io/metadata.name
operator: In
values:
- istio-system
policyTypes:
- Ingress
22 changes: 22 additions & 0 deletions contrib/networkpolicies/kfserving-models-web-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: kfserving-models-web-app
namespace: kubeflow
spec:
podSelector:
matchExpressions:
- key: app.kubernetes.io/component
operator: In
values:
- kfserving-models-web-app
ingress:
- from:
- namespaceSelector:
matchExpressions:
- key: kubernetes.io/metadata.name
operator: In
values:
- istio-system
policyTypes:
- Ingress
21 changes: 21 additions & 0 deletions contrib/networkpolicies/kfserving.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: kfserving
namespace: kubeflow
spec:
podSelector:
matchExpressions:
- key: control-plane
operator: In
values:
- kfserving-controller-manager # mutating webhook
# https://www.elastic.co/guide/en/cloud-on-k8s/1.1/k8s-webhook-network-policies.html
# The kubernetes api server must reach the webhook
ingress:
- ports:
- protocol: TCP
port: 9443
policyTypes:
- Ingress
20 changes: 20 additions & 0 deletions contrib/networkpolicies/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: kubeflow
resources:
- cache-server.yaml
- centraldashboard.yaml
- default-allow-same-namespace.yaml
- jupyter-web-app.yaml
- katib-controller.yaml
- katib-db-manager.yaml
- katib-ui.yaml
- kfserving-models-web-app.yaml
- kfserving.yaml
- metadata-grpc-server.yaml
- minio.yaml
- ml-pipeline-ui.yaml
- ml-pipeline.yaml
- poddefaults.yaml
- seldon.yaml
- volumes-web-app.yaml
24 changes: 24 additions & 0 deletions contrib/networkpolicies/metadata-grpc-server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: metadata-grpc-server
namespace: kubeflow
spec:
podSelector:
matchExpressions:
- key: component
operator: In
values:
- metadata-grpc-server # metadata server
ingress:
- from:
- namespaceSelector:
matchExpressions:
- key: app.kubernetes.io/part-of
operator: In
values:
- kubeflow-profile
- podSelector: {} # allow all pods from the same namespace
policyTypes:
- Ingress

23 changes: 23 additions & 0 deletions contrib/networkpolicies/minio.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: minio
namespace: kubeflow
spec:
podSelector:
matchExpressions:
- key: app
operator: In
values:
- minio # artifact storage
ingress:
- from:
- namespaceSelector:
matchExpressions:
- key: app.kubernetes.io/part-of
operator: In
values:
- kubeflow-profile
- podSelector: {} # allow all pods from the same namespace
policyTypes:
- Ingress
22 changes: 22 additions & 0 deletions contrib/networkpolicies/ml-pipeline-ui.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: ml-pipeline-ui
namespace: kubeflow
spec:
podSelector:
matchExpressions:
- key: app
operator: In
values:
- ml-pipeline-ui
ingress:
- from:
- namespaceSelector:
matchExpressions:
- key: kubernetes.io/metadata.name
operator: In
values:
- istio-system
policyTypes:
- Ingress
28 changes: 28 additions & 0 deletions contrib/networkpolicies/ml-pipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: ml-pipeline
namespace: kubeflow
spec:
podSelector:
matchExpressions:
- key: app
operator: In
values:
- ml-pipeline # just the apiserver
ingress:
- from:
- namespaceSelector:
matchExpressions:
- key: app.kubernetes.io/part-of
operator: In
values:
- kubeflow-profile
- namespaceSelector:
matchExpressions:
- key: kubernetes.io/metadata.name
operator: In
values:
- istio-system
policyTypes:
- Ingress
20 changes: 20 additions & 0 deletions contrib/networkpolicies/poddefaults.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: poddefaults
namespace: kubeflow
spec:
podSelector:
matchExpressions:
- key: app
operator: In
values:
- poddefaults # mutating webhook
# https://www.elastic.co/guide/en/cloud-on-k8s/1.1/k8s-webhook-network-policies.html
# The kubernetes api server must reach the webhook
ingress:
- ports:
- protocol: TCP
port: 4443
policyTypes:
- Ingress
21 changes: 21 additions & 0 deletions contrib/networkpolicies/seldon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: seldon
namespace: kubeflow
spec:
podSelector:
matchExpressions:
- key: control-plane
operator: In
values:
- seldon-controller-manager # validating webhook
# https://www.elastic.co/guide/en/cloud-on-k8s/1.1/k8s-webhook-network-policies.html
# The kubernetes api server must reach the webhook
ingress:
- ports:
- protocol: TCP
port: 4443
policyTypes:
- Ingress

Loading

0 comments on commit 5538d5e

Please sign in to comment.