networkpolicy.yaml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. {{- if .Values.networkPolicy.enabled }}
  2. kind: NetworkPolicy
  3. apiVersion: networking.k8s.io/v1
  4. metadata:
  5. name: {{ include "opentelemetry-collector.fullname" . }}
  6. namespace: {{ template "opentelemetry-collector.namespace" . }}
  7. labels:
  8. {{- include "opentelemetry-collector.labels" . | nindent 4 }}
  9. {{- if .Values.networkPolicy.annotations }}
  10. annotations:
  11. {{- range $key, $value := .Values.networkPolicy.annotations }}
  12. {{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
  13. {{- end }}
  14. {{- end }}
  15. spec:
  16. podSelector:
  17. matchLabels:
  18. {{- include "opentelemetry-collector.selectorLabels" . | nindent 6 }}
  19. {{- include "opentelemetry-collector.component" . | nindent 6 }}
  20. ingress:
  21. - ports:
  22. {{- range $port := .Values.ports }}
  23. {{- if $port.enabled }}
  24. - port: {{ $port.containerPort }}
  25. protocol: {{ $port.protocol }}
  26. {{- end }}
  27. {{- end }}
  28. {{- if .Values.networkPolicy.allowIngressFrom }}
  29. from:
  30. {{- toYaml .Values.networkPolicy.allowIngressFrom | nindent 8 }}
  31. {{- end }}
  32. {{- if .Values.networkPolicy.extraIngressRules }}
  33. {{- toYaml .Values.networkPolicy.extraIngressRules | nindent 4 }}
  34. {{- end }}
  35. {{- if .Values.networkPolicy.egressRules }}
  36. egress:
  37. {{- toYaml .Values.networkPolicy.egressRules | nindent 4 }}
  38. {{- end }}
  39. {{- end }}