浏览代码

Update postgres deployment to use library chart

Waqar Ahmed 4 年之前
父节点
当前提交
2733aab5c5
共有 1 个文件被更改,包括 16 次插入39 次删除
  1. 16 39
      test/nextcloud/1.1.0/templates/postgres-deployment.yaml

+ 16 - 39
test/nextcloud/1.1.0/templates/postgres-deployment.yaml

@@ -1,43 +1,30 @@
-apiVersion: apps/v1
+{{ $values := . }}
+{{ $_ := set $values "nameSuffix" "postgres" }}
+apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
 kind: Deployment
 metadata:
-  name: {{ template "nextcloud.fullname" . }}-postgres
-  labels:
-    helm.sh/chart: {{ include "nextcloud.chart" . }}
-    {{- include "nextcloud.postgres.selectorLabels" . | nindent 4 }}
-    app.kubernetes.io/managed-by: {{ .Release.Service }}
-    app.kubernetes.io/component: database
+  name: {{ template "common.names.fullname" $values }}
+  labels: {{ include "common.labels.selectorLabels" $values | nindent 4 }}
 spec:
   replicas: 1
   strategy:
     type: {{ .Values.nextcloud.strategy }}
   selector:
-    matchLabels:
-      {{- include "nextcloud.postgres.selectorLabels" . | nindent 6 }}
-      app.kubernetes.io/component: database
+    matchLabels: {{- include "common.labels.selectorLabels" $values | nindent 6 }}
   template:
     metadata:
-      labels:
-        {{- include "nextcloud.postgres.selectorLabels" . | nindent 8 }}
-        app.kubernetes.io/component: database
-      annotations:
-        rollme: {{ randAlphaNum 5 | quote }}
+      labels: {{- include "common.labels.selectorLabels" $values | nindent 8 }}
+      annotations: {{- include "common.annotations" $values | nindent 8 }}
     spec:
       containers:
       - name: {{ .Chart.Name }}-postgres
         image: {{ template "postgres.imageName" . }}
         imagePullPolicy: {{ .Values.image.pullPolicy }}
         env:
-        - name: POSTGRES_USER
-          valueFrom:
-            secretKeyRef:
-              name: db-details
-              key: db-user
-        - name: POSTGRES_PASSWORD
-          valueFrom:
-            secretKeyRef:
-              name: db-details
-              key: db-password
+        {{ $envList := list }}
+        {{ $envList = mustAppend $envList (dict "name" "POSTGRES_USER" "valueFromSecret" true "secretName" "db-details" "secretKey" "db-user") }}
+        {{ $envList = mustAppend $envList (dict "name" "POSTGRES_PASSWORD" "valueFromSecret" true "secretName" "db-details" "secretKey" "db-password") }}
+        {{ include "common.containers.environmentVariables" (dict "environmentVariables" $envList) | nindent 10 }}
         volumeMounts:
           - name: postgres-data
             mountPath: /var/lib/postgresql/data
@@ -48,17 +35,7 @@ spec:
           containerPort: 5432
           protocol: TCP
       volumes:
-      - name: postgres-data
-        {{- if ne (include "configuredPostgresHostPath" .) "" }}
-        hostPath:
-          path: {{ template "configuredPostgresHostPath" . }}
-        {{- else }}
-        emptyDir: {}
-        {{- end }}
-      - name: postgres-backup
-        {{- if ne (include "configuredBackupPostgresHostPath" .) "" }}
-        hostPath:
-          path: {{ template "configuredBackupPostgresHostPath" . }}
-        {{- else }}
-        emptyDir: {}
-        {{- end }}
+      {{ $vols := list }}
+      {{ $vols = mustAppend $vols (dict "name" "postgres-data" "emptyDirVolumes" .Values.emptyDirVolumes "hostPathEnabled" false "pathField" nil "datasetName" (.Values.postgresDataVolume | default dict).datasetName ) }}
+      {{ $vols = mustAppend $vols (dict "name" "postgres-backup" "emptyDirVolumes" .Values.emptyDirVolumes "hostPathEnabled" false "pathField" nil "datasetName" (.Values.postgresBackupVolume | default dict).datasetName ) }}
+      {{ include "common.storage.volumesConfiguration" (dict "ixVolumes" .Values.ixVolumes "volumes" $vols) | nindent 8 }}