-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add network policies for Harbor
- Loading branch information
Showing
3 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
charts/substra-backend/templates/network-task-deny-all.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Deny ALL networking in launched substra ml task | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: {{ template "substra.fullname". }}-deny-ingress | ||
labels: | ||
{{ include "substra.labels" . | nindent 4 }} | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
substra.ai/pod-type: compute-task | ||
policyTypes: | ||
- Ingress | ||
- Egress |
25 changes: 25 additions & 0 deletions
25
charts/substra-backend/templates/networkpolicy-registry-remote.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{{- if not .Values.containerRegistry.local }} | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: {{ template "substra.name". }}-registry-remote-egress | ||
spec: | ||
egress: | ||
- to: | ||
- ipBlock: | ||
cidr: 0.0.0.0/0 | ||
{{- if not .Values.server.allowLocalRequests }} | ||
except: | ||
- 10.0.0.0/8 | ||
- 192.168.0.0/16 | ||
- 172.16.0.0/20 | ||
{{- end }} | ||
ports: | ||
- protocol: TCP | ||
port: {{ .Values.containerRegistry.port }} | ||
podSelector: | ||
matchLabels: | ||
role-registry-client: 'true' | ||
policyTypes: | ||
- Egress | ||
{{- end }} |
77 changes: 77 additions & 0 deletions
77
charts/substra-backend/templates/networkpolicy-registry.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
{{- if .Values.containerRegistry.local }} | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: {{ template "substra.name". }}-registry-ingress | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
app: docker-registry | ||
policyTypes: | ||
- Ingress | ||
ingress: | ||
- from: | ||
- podSelector: | ||
matchLabels: | ||
app.kubernetes.io/part-of: {{ template "substra.name" . }} | ||
role-registry-client: 'true' | ||
# kaniko-function-xx send requests through the service, which changes the IP address calling the registry, preventing | ||
# to connect as the connection doesn't come directly from the pod | ||
- ipBlock: | ||
cidr: 10.0.0.0/8 | ||
ports: | ||
- protocol: TCP | ||
port: {{ .Values.containerRegistry.port }} | ||
# Nodeport range | ||
- protocol: TCP | ||
port: 30000 | ||
endPort: 32767 | ||
--- | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: {{ template "substra.name". }}-registry-egress | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
app.kubernetes.io/part-of: {{ template "substra.name" . }} | ||
role-registry-client: 'true' | ||
policyTypes: | ||
- Egress | ||
egress: | ||
- to: | ||
- podSelector: | ||
matchLabels: | ||
app: docker-registry | ||
ports: | ||
- protocol: TCP | ||
port: {{ .Values.containerRegistry.port }} | ||
# Nodeport range | ||
- protocol: TCP | ||
port: 30000 | ||
endPort: 32767 | ||
--- | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: {{ template "substra.name". }}-registry-kaniko-egress | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
app.kubernetes.io/component: substra-compute | ||
role-registry-client: 'true' | ||
policyTypes: | ||
- Egress | ||
egress: | ||
- to: | ||
- podSelector: | ||
matchLabels: | ||
app: docker-registry | ||
ports: | ||
- protocol: TCP | ||
port: {{ .Values.containerRegistry.port }} | ||
# Nodeport range | ||
- protocol: TCP | ||
port: 30000 | ||
endPort: 32767 | ||
{{- end }} |