Skip to content

Commit

Permalink
[coredns] netpol + drop psp
Browse files Browse the repository at this point in the history
  • Loading branch information
jouve committed Sep 12, 2023
1 parent 8d91b23 commit c1ab10e
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 50 deletions.
2 changes: 1 addition & 1 deletion charts/coredns/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: coredns
version: 1.26.1
version: 1.27.0
appVersion: 1.11.1
home: https://coredns.io
icon: https://coredns.io/images/CoreDNS_Colour_Horizontal.png
Expand Down
1 change: 1 addition & 0 deletions charts/coredns/ci/default-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
9 changes: 9 additions & 0 deletions charts/coredns/ci/netpol-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
isClusterService: false
networkPolicy:
enabled: true
ingress:
dns:
peers:
- namespaceSelector:
matchLabels:
toto: tutu
48 changes: 48 additions & 0 deletions charts/coredns/templates/networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{- if .Values.networkPolicy.enabled }}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ template "coredns.fullname" . }}
namespace: {{ .Release.Namespace }}
labels: {{- include "coredns.labels" . | nindent 4 }}
{{- if .Values.customLabels }}
{{ toYaml .Values.customLabels | indent 4 }}
{{- end }}
{{- with .Values.customAnnotations }}
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
spec:
podSelector:
matchLabels:
app.kubernetes.io/instance: {{ .Release.Name | quote }}
{{- if .Values.isClusterService }}
k8s-app: {{ template "coredns.k8sapplabel" . }}
{{- end }}
app.kubernetes.io/name: {{ template "coredns.name" . }}
ingress:
- {{- if not .Values.isClusterService }}
{{- $_ := eq .Values.networkPolicy.ingress.dns.peers nil | ternary "" "-" | required "required value networkPolicy.ingress.dns.peers" }}
from: {{ .Values.networkPolicy.ingress.dns.peers | toYaml | nindent 10 }}
{{- end }}
ports:
- protocol: TCP
port: 53
- protocol: UDP
port: 53
{{- with .Values.networkPolicy.ingress.metrics.peers }}
- from: {{ . | toYaml | nindent 10 }}
ports:
- protocol: TCP
port: 9153
{{- end }}
{{- with .Values.networkPolicy.ingress.rules }}
{{- . | toYaml | nindent 8 }}
{{- end }}
{{- with .Values.networkPolicy.egress.rules }}
egress:
{{- . | toYaml | nindent 8 }}
{{- end }}
policyTypes:
- Ingress
- Egress
{{- end }}
47 changes: 0 additions & 47 deletions charts/coredns/templates/podsecuritypolicy.yaml

This file was deleted.

12 changes: 10 additions & 2 deletions charts/coredns/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ serviceAccount:
rbac:
# If true, create & use RBAC resources
create: true
# If true, create and use PodSecurityPolicy
pspEnable: false
# The name of the ServiceAccount to use.
# If not set and create is true, a name is generated using the fullname template
# name:
Expand Down Expand Up @@ -354,3 +352,13 @@ deployment:
name: ""
## Annotations for the coredns deployment
annotations: {}

networkPolicy:
enabled: false
ingress:
dns:
peers: null
metrics:
peers: []
egress:
rules: []

0 comments on commit c1ab10e

Please sign in to comment.