Skip to content

Commit

Permalink
move-storage-config-to-secret
Browse files Browse the repository at this point in the history
Signed-off-by: zhongjun.li <[email protected]>
  • Loading branch information
learner0810 committed Mar 13, 2024
1 parent 90b2fff commit 7171f6b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 55 deletions.
2 changes: 1 addition & 1 deletion charts/clusterpedia/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 2.2.0
version: 2.2.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
14 changes: 7 additions & 7 deletions charts/clusterpedia/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -171,22 +171,22 @@ Return the proper Docker Image Registry Secret Names
{{- define "clusterpedia.storage.password" -}}
{{- if eq .Values.storageInstallMode "external" }}
{{- if empty (include "clusterpedia.storage.dsn" .) -}}
{{- required "Please set correct storage password!" .Values.externalStorage.password | toString | b64enc -}}
{{- required "Please set correct storage password!" .Values.externalStorage.password | toString -}}
{{- else -}}
{{- .Values.externalStorage.password | toString | b64enc -}}
{{- .Values.externalStorage.password | toString -}}
{{- end -}}
{{- else -}}
{{- if eq (include "clusterpedia.storage.type" .) "postgres" }}
{{- if not (empty .Values.global.postgresql.auth.username) -}}
{{- .Values.global.postgresql.auth.password | toString | b64enc -}}
{{- .Values.global.postgresql.auth.password | toString -}}
{{- else -}}
{{- .Values.global.postgresql.auth.postgresPassword | toString | b64enc -}}
{{- .Values.global.postgresql.auth.postgresPassword | toString -}}
{{- end -}}
{{- else if eq (include "clusterpedia.storage.type" .) "mysql" -}}
{{- if not (empty .Values.mysql.auth.username) -}}
{{- .Values.mysql.auth.password | toString | b64enc -}}
{{- .Values.mysql.auth.password | toString -}}
{{- else -}}
{{- .Values.mysql.auth.rootPassword | toString | b64enc -}}
{{- .Values.mysql.auth.rootPassword | toString -}}
{{- end -}}
{{- end -}}
{{- end -}}
Expand Down Expand Up @@ -388,4 +388,4 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
- name: OTEL_RESOURCE_ATTRIBUTES
value: 'k8s.namespace.name=$(OTEL_K8S_NAMESPACE),k8s.node.name=$(OTEL_RESOURCE_ATTRIBUTES_NODE_NAME),k8s.pod.name=$(OTEL_RESOURCE_ATTRIBUTES_POD_NAME)'
{{- end -}}
{{- end -}}
{{- end -}}
22 changes: 3 additions & 19 deletions charts/clusterpedia/templates/apiserver-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ spec:
done;
echo 'DataBase OK ✓'
{{- end }}
env:
- name: {{ include "clusterpedia.storage.password.envKey" . }}
valueFrom:
secretKeyRef:
name: {{ include "clusterpedia.internalstorage.fullname" . }}
key: password
volumeMounts:
- name: internalstorage-config
mountPath: /etc/clusterpedia/storage
Expand Down Expand Up @@ -95,14 +89,6 @@ spec:
done;
echo 'DataBase OK ✓'
{{- end }}
{{- if eq (include "clusterpedia.storage.type" .) "mysql" }}
env:
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "clusterpedia.internalstorage.fullname" . }}
key: password
{{- end }}
volumeMounts:
- name: internalstorage-config
mountPath: /etc/clusterpedia/storage
Expand Down Expand Up @@ -130,11 +116,6 @@ spec:
resources: {{- toYaml .Values.apiserver.resources | nindent 12 }}
{{- end }}
env:
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "clusterpedia.internalstorage.fullname" . }}
key: password
{{- include "clusterpedia.apiserver.tracing.env" . | nindent 8 }}
{{- if .Values.apiserver.enableSHA1Cert }}
- name: GODEBUG
Expand Down Expand Up @@ -166,6 +147,9 @@ spec:
- name: internalstorage-config
configMap:
name: {{ include "clusterpedia.internalstorage.fullname" . }}
- name: internalstorage-connection-config
secret:
secretName: {{ include "clusterpedia.internalstorage.fullname" . }}
- name: scripts
configMap:
name: {{ include "clusterpedia.scripts.fullname" . }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ spec:
done;
echo 'DataBase OK ✓'
{{- end }}
env:
- name: {{ include "clusterpedia.storage.password.envKey" . }}
valueFrom:
secretKeyRef:
name: {{ include "clusterpedia.internalstorage.fullname" . }}
key: password
volumeMounts:
- name: internalstorage-config
mountPath: /etc/clusterpedia/storage
Expand Down Expand Up @@ -95,14 +89,6 @@ spec:
done;
echo 'DataBase OK ✓'
{{- end }}
{{- if eq (include "clusterpedia.storage.type" .) "mysql" }}
env:
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "clusterpedia.internalstorage.fullname" . }}
key: password
{{- end }}
volumeMounts:
- name: internalstorage-config
mountPath: /etc/clusterpedia/storage
Expand Down Expand Up @@ -134,11 +120,6 @@ spec:
resources: {{- toYaml .Values.clustersynchroManager.resources | nindent 12 }}
{{- end }}
env:
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "clusterpedia.internalstorage.fullname" . }}
key: password
- name: GODEBUG
value: netdns=go
volumeMounts:
Expand All @@ -157,8 +138,8 @@ spec:
{{- end }}
volumes:
- name: internalstorage-config
configMap:
name: {{ include "clusterpedia.internalstorage.fullname" . }}
secret:
secretName: {{ include "clusterpedia.internalstorage.fullname" . }}
- name: scripts
configMap:
name: {{ include "clusterpedia.scripts.fullname" . }}
8 changes: 1 addition & 7 deletions charts/clusterpedia/templates/internalstorage-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ metadata:
labels: {{- include "common.labels.standard" . | nindent 4 }}
data:
internalstorage-config.yaml: |-
type: {{ include "clusterpedia.storage.type" . | quote }}
dsn: {{ include "clusterpedia.storage.dsn" . | quote }}
host: {{ include "clusterpedia.storage.host" . | quote }}
port: {{ include "clusterpedia.storage.port" . }}
user: {{ include "clusterpedia.storage.user" . }}
database: {{ include "clusterpedia.storage.database" . }}
{{ if .Values.storageConfig.log.enabled }}
log:
stdout: {{ .Values.storageConfig.log.stdout }}
Expand All @@ -26,4 +20,4 @@ data:
connPool:
maxIdleConns: {{ .Values.storageConfig.connPool.maxIdleConns | int }}
maxOpenConns: {{ .Values.storageConfig.connPool.maxOpenConns | int }}
connMaxLifetime: {{ .Values.storageConfig.connPool.connMaxLifetime }}
connMaxLifetime: {{ .Values.storageConfig.connPool.connMaxLifetime }}
6 changes: 6 additions & 0 deletions charts/clusterpedia/templates/internalstorage-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ metadata:
app: {{ include "clusterpedia.internalstorage.fullname" . }}
internalstorage.clusterpedia.io/type: {{ include "clusterpedia.storage.type" . }}
data:
type: {{ include "clusterpedia.storage.type" . | quote }}
dsn: {{ include "clusterpedia.storage.dsn" . | quote }}
host: {{ include "clusterpedia.storage.host" . | quote }}
port: {{ include "clusterpedia.storage.port" . }}
user: {{ include "clusterpedia.storage.user" . }}
password: {{ include "clusterpedia.storage.password" . }}
database: {{ include "clusterpedia.storage.database" . }}

0 comments on commit 7171f6b

Please sign in to comment.