Files
charts/bitnami/rabbitmq-cluster-operator/templates/messaging-topology-operator/networkpolicy.yaml
T
58cbc8786e [bitnami/rabbitmq-cluster-operator] Set network policy properly for metrics (#36270)
* fix: set metrics service port correctly

Signed-off-by: Sam Lin <maxisam@gmail.com>
Signed-off-by: Sam Lin <saml@millerslab.com>
Signed-off-by: Sam Lin <maxisam@gmail.com>

* fix: set mertics port properly

Signed-off-by: Sam Lin <saml@millerslab.com>
Signed-off-by: Sam Lin <maxisam@gmail.com>

* Update Chart.yaml

Signed-off-by: Sam Lin <saml@millerslab.com>
Signed-off-by: Sam Lin <maxisam@gmail.com>

* Update CHANGELOG.md

Signed-off-by: Bitnami Bot <bitnami.bot@broadcom.com>
Signed-off-by: Sam Lin <saml@millerslab.com>
Signed-off-by: Sam Lin <maxisam@gmail.com>

* Update CHANGELOG.md

Signed-off-by: Bitnami Bot <bitnami.bot@broadcom.com>

* Update CHANGELOG.md

Signed-off-by: Bitnami Bot <bitnami.bot@broadcom.com>

---------

Signed-off-by: Sam Lin <maxisam@gmail.com>
Signed-off-by: Sam Lin <saml@millerslab.com>
Signed-off-by: Bitnami Bot <bitnami.bot@broadcom.com>
Co-authored-by: Bitnami Bot <bitnami.bot@broadcom.com>
2025-11-11 09:55:45 +01:00

99 lines
4.2 KiB
YAML

{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if .Values.msgTopologyOperator.networkPolicy.enabled }}
kind: NetworkPolicy
apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }}
metadata:
name: {{ template "rmqco.msgTopologyOperator.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: messaging-topology-operator
app.kubernetes.io/part-of: rabbitmq
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.msgTopologyOperator.podLabels .Values.commonLabels ) "context" . ) }}
podSelector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
app.kubernetes.io/component: messaging-topology-operator
app.kubernetes.io/part-of: rabbitmq
policyTypes:
- Ingress
- Egress
{{- if .Values.msgTopologyOperator.networkPolicy.allowExternalEgress }}
egress:
- {}
{{- else }}
egress:
- ports:
# Allow dns resolution
- port: 53
protocol: UDP
- port: 53
protocol: TCP
# Allow rabbitmq api
- port: 15672
protocol: TCP
# Allow access to kube-apiserver
{{- range $port := .Values.msgTopologyOperator.networkPolicy.kubeAPIServerPorts }}
- port: {{ $port }}
{{- end }}
# RabbitMQCluster instances have the label app.kubernetes.io/component: rabbitmq
- to:
- podSelector:
matchLabels:
app.kubernetes.io/component: rabbitmq
{{- if not .Values.msgTopologyOperator.watchAllNamespaces }}
{{- $watchNamespaces := default (list (include "common.names.namespace" .)) .Values.msgTopologyOperator.watchNamespaces }}
namespaceSelector:
matchExpressions:
- key: namespace
operator: In
values:
{{- range $namespace := $watchNamespaces }}
- {{ $namespace }}
{{- end }}
{{- end }}
{{- if .Values.msgTopologyOperator.networkPolicy.extraEgress }}
{{- include "common.tplvalues.render" ( dict "value" .Values.msgTopologyOperator.networkPolicy.extraEgress "context" $ ) | nindent 4 }}
{{- end }}
{{- end }}
ingress:
- ports:
{{/* Webhook port is hardcoded in the operator code */}}
- port: 9443
{{- if .Values.msgTopologyOperator.metrics.service.enabled }}
- port: {{ .Values.msgTopologyOperator.containerPorts.metrics }}
{{- end }}
{{- if not .Values.msgTopologyOperator.networkPolicy.allowExternal }}
from:
- podSelector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 14 }}
app.kubernetes.io/part-of: rabbitmq
- podSelector:
matchLabels:
{{ template "rmqco.msgTopologyOperator.fullname" . }}-client: "true"
{{- if .Values.msgTopologyOperator.networkPolicy.ingressNSMatchLabels }}
- namespaceSelector:
matchLabels:
{{- range $key, $value := .Values.msgTopologyOperator.networkPolicy.ingressNSMatchLabels }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- if .Values.msgTopologyOperator.networkPolicy.ingressNSPodMatchLabels }}
podSelector:
matchLabels:
{{- range $key, $value := .Values.msgTopologyOperator.networkPolicy.ingressNSPodMatchLabels }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.msgTopologyOperator.networkPolicy.extraIngress }}
{{- include "common.tplvalues.render" ( dict "value" .Values.msgTopologyOperator.networkPolicy.extraIngress "context" $ ) | nindent 4 }}
{{- end }}
{{- end }}