Skip to content

Commit d4401e1

Browse files
Merge pull request #69 from signadot/cluster-config-allowed-namespaces
Include Allowed Namespaces in Cluster Config
2 parents 7e5948f + 5909b77 commit d4401e1

File tree

6 files changed

+31
-17
lines changed

6 files changed

+31
-17
lines changed

signadot/operator/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ kubectl delete ns signadot
6666
| `serviceLabels` | Labels to add to all deployed `Service` objects | `{}` |
6767
| `serviceAnnotations` | Annotations to add to all deployed `Service` objects | `{}` |
6868

69+
### Controller Manager parameters
70+
71+
| Name | Description | Default |
72+
| ------------------------------- | --------------------------------------------------------------------------- | ------- |
73+
| `allowedNamespaces` | Restrict the namespaces in which `signadot-controller-manager` will operate | `[]` |
74+
| `sandboxTrafficManager.enabled` | Whether to enable the sandbox traffic manager sidecar on forked workloads | `true` |
75+
76+
6977
### Image customization parameters
7078

7179
The parameters in the table below allow one to specify image names for the
@@ -120,7 +128,6 @@ style resources and are not needed in an installation which uses the new
120128
| `jobExecutorProxy.image` | Job Executor Proxy container image override | `signadot/job-executor-proxy:vX.Y.Z` |
121129
| `jobExecutorProxy.imagePullPolicy` | Job Executor Proxy container image pull policy | `IfNotPresent` |
122130
| `jobExecutorProxy.imagePullSecret` | Job Executor Proxy container image pull secret | `""` |
123-
| `sandboxTrafficManager.enabled` | Whether to enable the sandbox traffic manager sidecar on forked workloads | `true` |
124131
| `sandboxTrafficManager.init.Image` | Sandbox traffic manager sidecar image override | `signadot/sandbox-traffic-manager:vX.Y.Z` |
125132
| `sandboxTrafficManager.init.ImagePullPolicy` | Sandbox traffic manager sidecar image pull policy | `IfNotPresent` |
126133
| `sandboxTrafficManager.init.ImagePullSecret` | Sandbox traffic manager sidecar image pull secret | `""` |

signadot/operator/templates/_helpers.tpl

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
12
{{/*
23
cluster config template
34
*/}}
45
{{- define "compileClusterConfig" -}}
6+
{{- $allowedNamespaces := (include "getAllowedNamespaces" . | fromJsonArray) -}}
7+
allowedNamespaces: {{ if gt (len $allowedNamespaces) 0 }}{{ printf "\n" }}{{ toYaml $allowedNamespaces | indent 2}}{{- else -}}[]{{- end }}
58
routing:
69
istio:
710
enabled: {{ if and (hasKey .Values "istio") (hasKey .Values.istio "enabled") -}}{{ toString .Values.istio.enabled }}{{- else -}}false{{- end }}
@@ -15,4 +18,20 @@ trafficCapture:
1518
enabled: {{ if and (hasKey .Values "trafficCapture") (hasKey .Values.trafficCapture "enabled") -}}{{ toString .Values.trafficCapture.enabled }}{{- else -}}true{{- end }}
1619
requestHeadersElide: {{ with .Values }}{{ with .trafficCapture }}{{ with .requestHeadersElide }}{{ printf "\n" }}{{ toYaml . | indent 4}}{{- else -}}[]{{- end }}{{- else -}}[]{{- end }}{{- else -}}[]{{- end }}
1720
responseHeadersElide: {{ with .Values }}{{ with .trafficCapture }}{{ with .responseHeadersElide }}{{ printf "\n" }}{{ toYaml . | indent 4}}{{- else -}}[]{{- end }}{{- else -}}[]{{- end }}{{- else -}}[]{{- end }}
18-
{{- end -}}
21+
{{- end -}}
22+
23+
24+
{{/*
25+
get allowed namespaces
26+
*/}}
27+
{{- define "getAllowedNamespaces" -}}
28+
{{- if .Values.allowedNamespaces }}
29+
{{- $userNamespaces := .Values.allowedNamespaces -}}
30+
{{- if not (has "signadot" $userNamespaces) }}
31+
{{- $userNamespaces = append $userNamespaces "signadot" -}}
32+
{{- end }}
33+
{{- $userNamespaces | toJson -}}
34+
{{- else -}}
35+
[]
36+
{{- end }}
37+
{{- end }}

signadot/operator/templates/allowed_namespaces.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Bind the ClusterRole containing namespaced permissions to the
22
# controller-manager's ServiceAccount only in the specified namespaces.
3-
{{ range $namespace := .Values.allowedNamespaces }}
3+
{{- $allowedNamespaces := (include "getAllowedNamespaces" . | fromJsonArray) -}}
4+
{{ range $namespace := $allowedNamespaces }}
45
---
56
apiVersion: rbac.authorization.k8s.io/v1
67
kind: RoleBinding

signadot/operator/templates/signadot-controller-manager-deployment.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ spec:
4242
command:
4343
- /manager
4444
env:
45-
- name: ALLOWED_NAMESPACES
46-
value: {{ range $i, $val := .Values.allowedNamespaces }}{{ if gt $i 0 }},{{ end }}{{ $val }}{{ else }}""{{ end }}
4745
- name: SIDECAR_INIT_IMAGE_PULL_POLICY
4846
value: {{ with .Values }}{{ with .routeInit }}{{ with .imagePullPolicy }}{{ . }}{{- else -}}"IfNotPresent"{{- end }}{{- else -}}"IfNotPresent"{{- end }}{{- else -}}"IfNotPresent"{{- end }}
4947
- name: SIDECAR_INIT_IMAGE_PULL_SECRET

signadot/operator/templates/signadot-manager-namespaced-clusterrole.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ rules:
2626
- ""
2727
resources:
2828
- pods
29+
- endpoints
2930
verbs:
3031
- create
3132
- delete

signadot/operator/templates/signadot-manager-role-clusterrole.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,6 @@ metadata:
1212
{{- end }}
1313
name: signadot-manager-role
1414
rules:
15-
- apiGroups:
16-
- ""
17-
resources:
18-
- endpoints
19-
verbs:
20-
- create
21-
- delete
22-
- get
23-
- list
24-
- patch
25-
- update
26-
- watch
2715
- apiGroups:
2816
- admissionregistration.k8s.io
2917
resourceNames:

0 commit comments

Comments
 (0)