Skip to content

Commit

Permalink
Make PodSecurityPolicy name unique in k8s cluster when rbac.limit_to_…
Browse files Browse the repository at this point in the history
…namespace is true (#224)

- allows having multiple Pulsar clusters in different K8S namespaces but having the same helm release name
  - PodSecurityPolicy is a cluster-level-resource and name would collide without this change
  • Loading branch information
frankjkelly authored Feb 4, 2022
1 parent dd0e6d8 commit 9613ee0
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion charts/pulsar/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ apiVersion: v2
appVersion: "2.7.4"
description: Apache Pulsar Helm chart for Kubernetes
name: pulsar
version: 2.7.10
version: 2.7.11
home: https://pulsar.apache.org
sources:
- https://github.com/apache/pulsar
Expand Down
5 changes: 4 additions & 1 deletion charts/pulsar/templates/autorecovery-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ subjects:
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
{{- if .Values.rbac.limit_to_namespace }}
name: "{{ template "pulsar.fullname" . }}-{{ .Values.autorecovery.component }}-{{ template "pulsar.namespace" . }}"
{{- else}}
name: "{{ template "pulsar.fullname" . }}-{{ .Values.autorecovery.component }}"
namespace: {{ template "pulsar.namespace" . }}
{{- end}}
spec:
readOnlyRootFilesystem: false
privileged: false
Expand Down
5 changes: 4 additions & 1 deletion charts/pulsar/templates/bookkeeper-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ subjects:
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
{{- if .Values.rbac.limit_to_namespace }}
name: "{{ template "pulsar.fullname" . }}-{{ .Values.bookkeeper.component }}-{{ template "pulsar.namespace" . }}"
{{- else}}
name: "{{ template "pulsar.fullname" . }}-{{ .Values.bookkeeper.component }}"
namespace: {{ template "pulsar.namespace" . }}
{{- end}}
spec:
readOnlyRootFilesystem: false
privileged: false
Expand Down
5 changes: 4 additions & 1 deletion charts/pulsar/templates/broker-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,11 @@ subjects:
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
{{- if .Values.rbac.limit_to_namespace }}
name: "{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}-{{ template "pulsar.namespace" . }}"
{{- else}}
name: "{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}"
namespace: {{ template "pulsar.namespace" . }}
{{- end}}
spec:
readOnlyRootFilesystem: false
privileged: false
Expand Down
5 changes: 4 additions & 1 deletion charts/pulsar/templates/proxy-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ subjects:
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
{{- if .Values.rbac.limit_to_namespace }}
name: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}-{{ template "pulsar.namespace" . }}"
{{- else}}
name: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}"
namespace: {{ template "pulsar.namespace" . }}
{{- end}}
spec:
readOnlyRootFilesystem: false
privileged: false
Expand Down
5 changes: 4 additions & 1 deletion charts/pulsar/templates/toolset-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ subjects:
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
{{- if .Values.rbac.limit_to_namespace }}
name: "{{ template "pulsar.fullname" . }}-{{ .Values.toolset.component }}-{{ template "pulsar.namespace" . }}"
{{- else}}
name: "{{ template "pulsar.fullname" . }}-{{ .Values.toolset.component }}"
namespace: {{ template "pulsar.namespace" . }}
{{- end}}
spec:
readOnlyRootFilesystem: false
privileged: false
Expand Down
7 changes: 5 additions & 2 deletions charts/pulsar/templates/zookeeper-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ subjects:
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: "{{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}"
namespace: {{ template "pulsar.namespace" . }}
{{- if .Values.rbac.limit_to_namespace }}
name: "{{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}-{{ template "pulsar.namespace" . }}"
{{- else}}
name: "{{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}"
{{- end}}
spec:
readOnlyRootFilesystem: false
privileged: false
Expand Down

0 comments on commit 9613ee0

Please sign in to comment.