Skip to content

Commit

Permalink
no need for the list secrets perm - need to mount manually to file sy…
Browse files Browse the repository at this point in the history
…stem (kiali#189)

part of: kiali/kiali#5738
  • Loading branch information
jmazzitelli authored Jan 27, 2023
1 parent f41d61d commit f500333
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 8 deletions.
23 changes: 23 additions & 0 deletions kiali-server/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,27 @@ Determine the root namespace - default is where Kiali is installed.
{{- else }}
{{- .Release.Namespace }}
{{- end }}
{{- end }}

{{/*
Autodetect remote cluster secrets if enabled - looks for secrets in the same namespace where Kiali is installed.
Returns a JSON dict whose keys are the cluster names and values are the cluster secret data.
*/}}
{{- define "kiali-server.remote-cluster-secrets" -}}
{{- $theDict := dict }}
{{- if .Values.kiali_feature_flags.clustering.autodetect_secrets.enabled }}
{{- $secretLabelToLookFor := (regexSplit "=" .Values.kiali_feature_flags.clustering.autodetect_secrets.label 2) }}
{{- $secretLabelNameToLookFor := first $secretLabelToLookFor }}
{{- $secretLabelValueToLookFor := last $secretLabelToLookFor }}
{{- range $i, $secret := (lookup "v1" "Secret" .Release.Namespace "").items }}
{{- if (and (and (hasKey $secret.metadata "labels") (hasKey $secret.metadata.labels $secretLabelNameToLookFor)) (eq (get $secret.metadata.labels $secretLabelNameToLookFor) ($secretLabelValueToLookFor))) }}
{{- $clusterName := $secret.metadata.name }}
{{- if (and (hasKey $secret.metadata "annotations") (hasKey $secret.metadata.annotations "networking.istio.io/cluster")) }}
{{- $clusterName = get $secret.metadata.annotations "networking.istio.io/cluster" }}
{{- end }}
{{- $theDict = set $theDict $clusterName $secret.metadata.name }}
{{- end }}
{{- end }}
{{- end }}
{{- $theDict | toJson }}
{{- end }}
18 changes: 18 additions & 0 deletions kiali-server/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ spec:
- name: {{ .name }}
mountPath: "{{ .mount }}"
{{- end }}
{{- range $key, $_ := (include "kiali-server.remote-cluster-secrets" .) | fromJson }}
- name: {{ $key }}
mountPath: "/kiali-remote-cluster-secrets/{{ $key }}"
{{- end }}
{{- range .Values.kiali_feature_flags.clustering.clusters }}
- name: {{ .name }}
mountPath: "/kiali-remote-cluster-secrets/{{ .name }}"
{{- end }}
{{- if .Values.deployment.resources }}
resources:
{{- toYaml .Values.deployment.resources | nindent 10 }}
Expand Down Expand Up @@ -161,6 +169,16 @@ spec:
secretName: {{ .name }}
optional: {{ .optional | default false }}
{{- end }}
{{- range $key, $val := (include "kiali-server.remote-cluster-secrets" .) | fromJson }}
- name: {{ $key }}
secret:
secretName: {{ $val }}
{{- end }}
{{- range .Values.kiali_feature_flags.clustering.clusters }}
- name: {{ .name }}
secret:
secretName: {{ .secret_name }}
{{- end }}
{{- if or (.Values.deployment.affinity.node) (or (.Values.deployment.affinity.pod) (.Values.deployment.affinity.pod_anti)) }}
affinity:
{{- if .Values.deployment.affinity.node }}
Expand Down
7 changes: 0 additions & 7 deletions kiali-server/templates/role-controlplane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ metadata:
labels:
{{- include "kiali-server.labels" . | nindent 4 }}
rules:
{{- if .Values.kiali_feature_flags.clustering.enabled }}
- apiGroups: [""]
resources:
- secrets
verbs:
- list
{{- end }}
{{- if .Values.kiali_feature_flags.certificates_information_indicators.enabled }}
- apiGroups: [""]
resourceNames:
Expand Down
5 changes: 4 additions & 1 deletion kiali-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ kiali_feature_flags:
- cacerts
- istio-ca-secret
clustering:
enabled: true
autodetect_secrets:
enabled: true
label: "istio/multiCluster=true"
clusters: []
disabled_features: []
validations:
ignore: ["KIA1201"]
Expand Down

0 comments on commit f500333

Please sign in to comment.