From 96bfcb57efb6a0b7dbb1d0031ccb53c320ba73f5 Mon Sep 17 00:00:00 2001
From: Larry Rensing <lr699s@att.com>
Date: Mon, 17 Apr 2017 10:43:35 -0500
Subject: [PATCH] Move keystone config files to manifests

This patch set moves the required keystone config files to the manifests, and
allows users to specify their own additional volume mounts if necessary.

Change-Id: I622abbba3e19390ce1003441eb9c0a3477754b82
---
 keystone/templates/deployment.yaml  | 42 ++++++++++++++-
 keystone/templates/job-db-init.yaml | 22 +++++++-
 keystone/templates/job-db-sync.yaml | 22 +++++++-
 keystone/values.yaml                | 80 -----------------------------
 4 files changed, 80 insertions(+), 86 deletions(-)

diff --git a/keystone/templates/deployment.yaml b/keystone/templates/deployment.yaml
index 12ce4a6891..38aa3dd142 100644
--- a/keystone/templates/deployment.yaml
+++ b/keystone/templates/deployment.yaml
@@ -75,6 +75,44 @@ spec:
             tcpSocket:
               port: {{ .Values.network.api.port }}
           volumeMounts:
-{{ toYaml $mounts_keystone_api.volumeMounts | indent 12 }}
+          - name: etckeystone
+            mountPath: /etc/keystone
+          - name: keystone-etc
+            mountPath: /etc/keystone/keystone.conf
+            subPath: keystone.conf
+            readOnly: true
+          - name: keystone-etc
+            mountPath: /etc/keystone/keystone-paste.ini
+            subPath: keystone-paste.ini
+            readOnly: true
+          - name: keystone-etc
+            mountPath: /etc/keystone/policy.json
+            subPath: policy.json
+            readOnly: true
+          - name: keystone-etc
+            mountPath: /etc/keystone/sso_callback_template.html
+            subPath: sso_callback_template.html
+            readOnly: true
+          - name: keystone-etc
+            mountPath: /etc/apache2/conf-enabled/wsgi-keystone.conf
+            subPath: wsgi-keystone.conf
+            readOnly: true
+          - name: keystone-etc
+            mountPath: /etc/apache2/mods-available/mpm_event.conf
+            subPath: mpm_event.conf
+            readOnly: true
+          - name: keystone-bin
+            mountPath: /tmp/start.sh
+            subPath: start.sh
+            readOnly: true
+{{ if $mounts_keystone_api.volumeMounts }}{{ toYaml $mounts_keystone_api.volumeMounts | indent 10 }}{{ end }}
       volumes:
-{{ toYaml $mounts_keystone_api.volumes | indent 8 }}
+      - name: etckeystone
+        emptyDir: {}
+      - name: keystone-etc
+        configMap:
+          name: keystone-etc
+      - name: keystone-bin
+        configMap:
+          name: keystone-bin
+{{ if $mounts_keystone_api.volumes }}{{ toYaml $mounts_keystone_api.volumes | indent 6 }}{{ end }}
diff --git a/keystone/templates/job-db-init.yaml b/keystone/templates/job-db-init.yaml
index 93593af8dd..29a291f5e9 100644
--- a/keystone/templates/job-db-init.yaml
+++ b/keystone/templates/job-db-init.yaml
@@ -61,6 +61,24 @@ spec:
             - python
             - /tmp/db-init.py
           volumeMounts:
-{{ toYaml $mounts_keystone_db_init.volumeMounts | indent 12 }}
+          - name: etckeystone
+            mountPath: /etc/keystone
+          - name: keystone-etc
+            mountPath: /etc/keystone/keystone.conf
+            subPath: keystone.conf
+            readOnly: true
+          - name: keystone-bin
+            mountPath: /tmp/db-init.py
+            subPath: db-init.py
+            readOnly: true
+{{ if $mounts_keystone_db_init.volumeMounts }}{{ toYaml $mounts_keystone_db_init.volumeMounts | indent 10 }}{{ end }}
       volumes:
-{{ toYaml $mounts_keystone_db_init.volumes | indent 8 }}
+      - name: etckeystone
+        emptyDir: {}
+      - name: keystone-etc
+        configMap:
+          name: keystone-etc
+      - name: keystone-bin
+        configMap:
+          name: keystone-bin
+{{ if $mounts_keystone_db_init.volumes }}{{ toYaml $mounts_keystone_db_init.volumes | indent 6 }}{{ end }}
diff --git a/keystone/templates/job-db-sync.yaml b/keystone/templates/job-db-sync.yaml
index 8cc8f1f745..e0dbf057c2 100644
--- a/keystone/templates/job-db-sync.yaml
+++ b/keystone/templates/job-db-sync.yaml
@@ -48,6 +48,24 @@ spec:
             - bash
             - /tmp/db-sync.sh
           volumeMounts:
-{{ toYaml $mounts_keystone_db_sync.volumeMounts | indent 12 }}
+          - name: etckeystone
+            mountPath: /etc/keystone
+          - name: keystone-etc
+            mountPath: /etc/keystone/keystone.conf
+            subPath: keystone.conf
+            readOnly: true
+          - name: keystone-bin
+            mountPath: /tmp/db-sync.sh
+            subPath: db-sync.sh
+            readOnly: true
+{{ if $mounts_keystone_db_sync.volumeMounts }}{{ toYaml $mounts_keystone_db_sync.volumeMounts | indent 10 }}{{ end }}
       volumes:
-{{ toYaml $mounts_keystone_db_sync.volumes | indent 8 }}
+      - name: etckeystone
+        emptyDir: {}
+      - name: keystone-etc
+        configMap:
+          name: keystone-etc
+      - name: keystone-bin
+        configMap:
+          name: keystone-bin
+{{ if $mounts_keystone_db_sync.volumes }}{{ toYaml $mounts_keystone_db_sync.volumes | indent 6 }}{{ end }}
diff --git a/keystone/values.yaml b/keystone/values.yaml
index 58a7cc756d..64c2ff4518 100644
--- a/keystone/values.yaml
+++ b/keystone/values.yaml
@@ -107,92 +107,12 @@ mounts:
   keystone_db_init:
     init_container: null
     keystone_db_init:
-      volumes:
-      - name: empty
-        emptyDir: {}
-      - name: keystone-etc
-        configMap:
-          name: keystone-etc
-      - name: keystone-bin
-        configMap:
-          name: keystone-bin
-      volumeMounts:
-      - name: empty
-        mountPath: /etc/keystone
-      - name: keystone-etc
-        mountPath: /etc/keystone/keystone.conf
-        subPath: keystone.conf
-        readOnly: true
-      - name: keystone-bin
-        mountPath: /tmp/db-init.py
-        subPath: db-init.py
-        readOnly: true
   keystone_db_sync:
     init_container: null
     keystone_db_sync:
-      volumes:
-      - name: empty
-        emptyDir: {}
-      - name: keystone-etc
-        configMap:
-          name: keystone-etc
-      - name: keystone-bin
-        configMap:
-          name: keystone-bin
-      volumeMounts:
-      - name: empty
-        mountPath: /etc/keystone
-      - name: keystone-etc
-        mountPath: /etc/keystone/keystone.conf
-        subPath: keystone.conf
-        readOnly: true
-      - name: keystone-bin
-        mountPath: /tmp/db-sync.sh
-        subPath: db-sync.sh
-        readOnly: true
   keystone_api:
     init_container: null
     keystone_api:
-      volumes:
-      - name: empty
-        emptyDir: {}
-      - name: keystone-etc
-        configMap:
-          name: keystone-etc
-      - name: keystone-bin
-        configMap:
-          name: keystone-bin
-      volumeMounts:
-      - name: empty
-        mountPath: /etc/keystone
-      - name: keystone-etc
-        mountPath: /etc/keystone/keystone.conf
-        subPath: keystone.conf
-        readOnly: true
-      - name: keystone-etc
-        mountPath: /etc/keystone/keystone-paste.ini
-        subPath: keystone-paste.ini
-        readOnly: true
-      - name: keystone-etc
-        mountPath: /etc/keystone/policy.json
-        subPath: policy.json
-        readOnly: true
-      - name: keystone-etc
-        mountPath: /etc/keystone/sso_callback_template.html
-        subPath: sso_callback_template.html
-        readOnly: true
-      - name: keystone-etc
-        mountPath: /etc/apache2/conf-enabled/wsgi-keystone.conf
-        subPath: wsgi-keystone.conf
-        readOnly: true
-      - name: keystone-etc
-        mountPath: /etc/apache2/mods-available/mpm_event.conf
-        subPath: mpm_event.conf
-        readOnly: true
-      - name: keystone-bin
-        mountPath: /tmp/start.sh
-        subPath: start.sh
-        readOnly: true
 
 conf:
   paste: