[bitnami/flux] feat: 🔒 Allow limiting the scope to the deployed namespace (#22254)

Signed-off-by: Javier Salmeron Garcia <jsalmeron@vmware.com>
Signed-off-by: Javier J. Salmerón-García <jsalmeron@vmware.com>
This commit is contained in:
Javier J. Salmerón-García
2024-01-19 10:44:57 +01:00
committed by GitHub
parent 4f1eacc079
commit 5d838d32b9
15 changed files with 140 additions and 41 deletions

View File

@@ -4,15 +4,19 @@ SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if and .Values.imageReflectorController.enabled .Values.imageReflectorController.rbac.create }}
{{- $bindingKind := ternary "ClusterRoleBinding" "RoleBinding" .Values.imageReflectorController.watchAllNamespaces }}
{{- $versionLabel := dict "app.kubernetes.io/version" ( include "common.images.version" ( dict "imageRoot" .Values.imageReflectorController.image "chart" .Chart ) ) }}
{{- $labels := include "common.tplvalues.merge" ( dict "values" ( list .Values.commonLabels $versionLabel ) "context" . ) }}
kind: ClusterRoleBinding
kind: {{ $bindingKind }}
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
metadata:
name: {{ printf "%s-manager" (include "flux.image-reflector-controller.fullname.namespace" .) | trunc 63 | trimSuffix "-" }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
app.kubernetes.io/part-of: flux
app.kubernetes.io/component: image-reflector-controller
{{- if not .Values.imageReflectorController.watchAllNamespaces }}
namespace: {{ include "common.names.namespace" . | quote }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
@@ -25,13 +29,16 @@ subjects:
name: {{ template "flux.image-reflector-controller.serviceAccountName" . }}
namespace: {{ include "common.names.namespace" . | quote }}
---
kind: ClusterRoleBinding
kind: {{ $bindingKind }}
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
metadata:
name: {{ printf "%s-imagepolicy-editor" (include "flux.image-reflector-controller.fullname.namespace" .) | trunc 63 | trimSuffix "-" }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
app.kubernetes.io/part-of: flux
app.kubernetes.io/component: image-reflector-controller
{{- if not .Values.imageReflectorController.watchAllNamespaces }}
namespace: {{ include "common.names.namespace" . | quote }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
@@ -44,13 +51,16 @@ subjects:
name: {{ template "flux.image-reflector-controller.serviceAccountName" . }}
namespace: {{ include "common.names.namespace" . | quote }}
---
kind: ClusterRoleBinding
kind: {{ $bindingKind }}
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
metadata:
name: {{ printf "%s-imagepolicy-viewer" (include "flux.image-reflector-controller.fullname.namespace" .) | trunc 63 | trimSuffix "-" }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
app.kubernetes.io/part-of: flux
app.kubernetes.io/component: image-reflector-controller
{{- if not .Values.imageReflectorController.watchAllNamespaces }}
namespace: {{ include "common.names.namespace" . | quote }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
@@ -64,13 +74,16 @@ subjects:
namespace: {{ include "common.names.namespace" . | quote }}
---
kind: ClusterRoleBinding
kind: {{ $bindingKind }}
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
metadata:
name: {{ printf "%s-imagerepository-editor" (include "flux.image-reflector-controller.fullname.namespace" .) | trunc 63 | trimSuffix "-" }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
app.kubernetes.io/part-of: flux
app.kubernetes.io/component: image-reflector-controller
{{- if not .Values.imageReflectorController.watchAllNamespaces }}
namespace: {{ include "common.names.namespace" . | quote }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
@@ -83,13 +96,16 @@ subjects:
name: {{ template "flux.image-reflector-controller.serviceAccountName" . }}
namespace: {{ include "common.names.namespace" . | quote }}
---
kind: ClusterRoleBinding
kind: {{ $bindingKind }}
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
metadata:
name: {{ printf "%s-imagerepository-viewer" (include "flux.image-reflector-controller.fullname.namespace" .) | trunc 63 | trimSuffix "-" }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
app.kubernetes.io/part-of: flux
app.kubernetes.io/component: image-reflector-controller
{{- if not .Values.imageReflectorController.watchAllNamespaces }}
namespace: {{ include "common.names.namespace" . | quote }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}

View File

@@ -115,7 +115,7 @@ spec:
args: {{- include "common.tplvalues.render" (dict "value" .Values.imageReflectorController.args "context" $) | nindent 12 }}
{{- else }}
args:
- --watch-all-namespaces
- --watch-all-namespaces={{ .Values.imageReflectorController.watchAllNamespaces }}
{{- if .Values.imageReflectorController.image.debug }}
- --log-level=debug
{{- else }}