rancher-partner-charts/charts/kubecost/cost-analyzer/2.2.3/templates/cost-analyzer-network-polic...

48 lines
1.4 KiB
YAML

{{- if .Values.networkPolicy -}}
{{- if .Values.networkPolicy.costAnalyzer.enabled -}}
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: {{ template "cost-analyzer.fullname" . }}
{{- if .Values.networkPolicy.costAnalyzer.annotations }}
annotations:
{{ toYaml .Values.networkPolicy.costAnalyzer.annotations | indent 4}}
{{- end }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- if .Values.networkPolicy.costAnalyzer.additionalLabels }}
{{ toYaml .Values.networkPolicy.costAnalyzer.additionalLabels | indent 4 }}
{{- end }}
spec:
podSelector:
matchLabels:
{{- include "cost-analyzer.selectorLabels" . | nindent 6 }}
policyTypes:
{{- if .Values.networkPolicy.costAnalyzer.ingressRules }}
- Ingress
{{- end }}
{{- if .Values.networkPolicy.costAnalyzer.egressRules }}
- Egress
{{- end }}
{{- if .Values.networkPolicy.costAnalyzer.egressRules }}
egress:
{{- range $rule := .Values.networkPolicy.costAnalyzer.egressRules }}
- to:
{{ toYaml $rule.selectors | indent 7 }}
ports:
{{ toYaml $rule.ports | indent 9 }}
{{- end }}
{{- end }}
{{- if .Values.networkPolicy.costAnalyzer.ingressRules }}
ingress:
{{- range $rule := .Values.networkPolicy.costAnalyzer.ingressRules }}
- from:
{{ toYaml $rule.selectors | indent 7 }}
ports:
{{ toYaml $rule.ports | indent 9 }}
{{- end }}
{{- end }}
{{- end -}}
{{- end -}}