-
Notifications
You must be signed in to change notification settings - Fork 56
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
feat(testkube): add networkpolicy support #784
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
{{- if .Values.networkPolicy.enabled -}} | ||
# this policy will be assigned to any pod in the namespace | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: testkube-all | ||
namespace: testkube | ||
spec: | ||
podSelector: {} | ||
policyTypes: | ||
- Egress | ||
egress: | ||
- to: | ||
- podSelector: | ||
matchLabels: | ||
app.kubernetes.io/name: api-server | ||
app.kubernetes.io/instance: testkube | ||
ports: | ||
- protocol: TCP | ||
port: {{ index .Values "testkube-api" "service" "port" }} | ||
- to: | ||
- podSelector: | ||
matchLabels: | ||
app: testkube-minio-testkube | ||
ports: | ||
- protocol: TCP | ||
port: {{ index .Values "testkube-api" "storage" "endpoint_port" }} | ||
--- | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: testkube-operator | ||
namespace: testkube | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above comment for selector |
||
control-plane: controller-manager | ||
policyTypes: | ||
- Ingress | ||
ingress: | ||
- ports: | ||
- protocol: TCP | ||
port: 9443 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this also be referenced through a param? |
||
--- | ||
# API must accept connections from everything | ||
# (e.g. kube-proxy, pods in this namespace, external ingress controller) | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: testkube-api-server | ||
namespace: testkube | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
app.kubernetes.io/name: api-server | ||
app.kubernetes.io/instance: testkube | ||
policyTypes: | ||
- Egress | ||
- Ingress | ||
egress: | ||
- to: | ||
- podSelector: | ||
matchLabels: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment for selectors |
||
app.kubernetes.io/name: nats | ||
app.kubernetes.io/instance: testkube | ||
ports: | ||
- protocol: TCP | ||
port: 4222 | ||
- to: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this might need to be dynamic if mongodb is disabled (customer is bringing own mongo) |
||
- podSelector: | ||
matchLabels: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment for selectors, they should be used through a helper funcion (from the mongodb chart?) |
||
app.kubernetes.io/name: mongodb | ||
app.kubernetes.io/instance: testkube | ||
ports: | ||
- protocol: TCP | ||
port: {{ .Values.mongodb.service.port }} | ||
ingress: | ||
- ports: | ||
- protocol: TCP | ||
port: {{ index .Values "testkube-api" "service" "port" }} | ||
--- | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: testkube-minio | ||
namespace: testkube | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
app: testkube-minio-testkube | ||
policyTypes: | ||
- Ingress | ||
ingress: | ||
- ports: | ||
- protocol: TCP | ||
port: {{ index .Values "testkube-api" "storage" "endpoint_port" }} | ||
--- | ||
{{- if .Values.mongodb.enabled -}} | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: testkube-mongodb | ||
namespace: testkube | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
app.kubernetes.io/name: mongodb | ||
app.kubernetes.io/instance: testkube | ||
policyTypes: | ||
- Ingress | ||
ingress: | ||
- from: | ||
- podSelector: | ||
matchLabels: | ||
app.kubernetes.io/instance: testkube | ||
ports: | ||
- protocol: TCP | ||
port: {{ .Values.mongodb.service.port }} | ||
--- | ||
{{- end -}} | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: testkube-nats | ||
namespace: testkube | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
app.kubernetes.io/name: nats | ||
app.kubernetes.io/instance: testkube | ||
policyTypes: | ||
- Ingress | ||
ingress: | ||
- from: | ||
- podSelector: | ||
matchLabels: | ||
app.kubernetes.io/instance: testkube | ||
ports: | ||
- protocol: TCP | ||
port: 4222 | ||
--- | ||
{{- if index .Values "testkube-dashboard" "enabled" -}} | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: testkube-dashboard | ||
namespace: testkube | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
app.kubernetes.io/name: dashboard | ||
app.kubernetes.io/instance: testkube | ||
policyTypes: | ||
- Ingress | ||
ingress: | ||
- ports: | ||
- protocol: TCP | ||
port: {{ index .Values "testkube-dashboard" "service" "port" }} | ||
{{- end -}} | ||
{{- end -}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1084,3 +1084,6 @@ testkube-operator: | |
operator: Equal | ||
value: arm64 | ||
effect: NoSchedule | ||
|
||
networkPolicy: | ||
enabled: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be done similar to how services use a helper method? Example https://github.com/kubeshop/helm-charts/blob/develop/charts/testkube-api/templates/service.yaml#L27
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feel free to refactor to your hearts content
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you assist? :)