kubezero/charts/kubezero-metrics/charts/kube-prometheus-stack/charts/grafana/templates/networkpolicy.yaml

53 lines
1.4 KiB
YAML
Raw Normal View History

2021-12-09 18:03:55 +00:00
{{- if .Values.networkPolicy.enabled }}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ template "grafana.fullname" . }}
namespace: {{ template "grafana.namespace" . }}
labels:
{{- include "grafana.labels" . | nindent 4 }}
{{- with .Values.labels }}
{{ toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.annotations }}
2021-12-09 18:03:55 +00:00
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
2021-12-09 18:03:55 +00:00
spec:
2022-08-24 15:13:39 +00:00
policyTypes:
{{- if .Values.networkPolicy.ingress }}
- Ingress
{{- end }}
{{- if .Values.networkPolicy.egress.enabled }}
- Egress
{{- end }}
2021-12-09 18:03:55 +00:00
podSelector:
matchLabels:
{{- include "grafana.selectorLabels" . | nindent 6 }}
2022-08-24 15:13:39 +00:00
{{- if .Values.networkPolicy.egress.enabled }}
egress:
- ports:
{{ .Values.networkPolicy.egress.ports | toJson }}
{{- end }}
{{- if .Values.networkPolicy.ingress }}
2021-12-09 18:03:55 +00:00
ingress:
- ports:
- port: {{ .Values.service.targetPort }}
{{- if not .Values.networkPolicy.allowExternal }}
from:
- podSelector:
matchLabels:
{{ template "grafana.fullname" . }}-client: "true"
{{- with .Values.networkPolicy.explicitNamespacesSelector }}
- namespaceSelector:
{{- toYaml . | nindent 12 }}
{{- end }}
2021-12-09 18:03:55 +00:00
- podSelector:
matchLabels:
{{- include "grafana.labels" . | nindent 14 }}
role: read
{{- end }}
2022-08-24 15:13:39 +00:00
{{- end }}
2021-12-09 18:03:55 +00:00
{{- end }}