Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 1 | {{/* |
| 2 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | you may not use this file except in compliance with the License. |
| 4 | You may obtain a copy of the License at |
| 5 | |
| 6 | http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | |
| 8 | Unless required by applicable law or agreed to in writing, software |
| 9 | distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | See the License for the specific language governing permissions and |
| 12 | limitations under the License. |
| 13 | */}} |
| 14 | |
| 15 | {{- if .Values.manifests.job_cell_setup }} |
| 16 | {{- $envAll := . }} |
| 17 | |
| 18 | {{- $serviceAccountName := "nova-cell-setup" }} |
| 19 | {{ tuple $envAll "cell_setup" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} |
| 20 | --- |
| 21 | apiVersion: batch/v1 |
| 22 | kind: Job |
| 23 | metadata: |
| 24 | name: nova-cell-setup |
| 25 | labels: |
| 26 | {{ tuple $envAll "nova" "cell-setup" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} |
| 27 | annotations: |
| 28 | {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }} |
| 29 | spec: |
| 30 | template: |
| 31 | metadata: |
| 32 | labels: |
| 33 | {{ tuple $envAll "nova" "cell-setup" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} |
| 34 | annotations: |
| 35 | {{ dict "envAll" $envAll "podName" "nova-cell-setup" "containerNames" (list "nova-cell-setup-init" "nova-cell-setup" "init") | include "helm-toolkit.snippets.kubernetes_mandatory_access_control_annotation" | indent 8 }} |
| 36 | spec: |
| 37 | serviceAccountName: {{ $serviceAccountName }} |
| 38 | restartPolicy: OnFailure |
| 39 | nodeSelector: |
| 40 | {{ .Values.labels.job.node_selector_key }}: {{ .Values.labels.job.node_selector_value }} |
Oleksandr Kozachenko | a10d785 | 2023-02-02 22:01:16 +0100 | [diff] [blame] | 41 | {{ if $envAll.Values.pod.tolerations.nova.enabled }} |
| 42 | {{ tuple $envAll "nova" | include "helm-toolkit.snippets.kubernetes_tolerations" | indent 6 }} |
| 43 | {{ end }} |
Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 44 | initContainers: |
| 45 | {{ tuple $envAll "cell_setup" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} |
| 46 | {{- if $envAll.Values.bootstrap.wait_for_computes.enabled }} |
| 47 | - name: nova-wait-for-computes-init |
| 48 | {{ tuple $envAll "nova_wait_for_computes_init" | include "helm-toolkit.snippets.image" | indent 10 }} |
| 49 | {{ dict "envAll" $envAll "application" "bootstrap" "container" "nova_wait_for_computes_init" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} |
| 50 | command: |
| 51 | - /bin/bash |
| 52 | - -c |
| 53 | - /tmp/wait-for-computes-init.sh |
| 54 | volumeMounts: |
| 55 | - name: pod-tmp |
| 56 | mountPath: /tmp |
| 57 | - name: nova-bin |
| 58 | mountPath: /tmp/wait-for-computes-init.sh |
| 59 | subPath: wait-for-computes-init.sh |
| 60 | readOnly: true |
| 61 | {{- end }} |
| 62 | - name: nova-cell-setup-init |
| 63 | {{ tuple $envAll "nova_cell_setup_init" | include "helm-toolkit.snippets.image" | indent 10 }} |
| 64 | {{ tuple $envAll $envAll.Values.pod.resources.jobs.cell_setup | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} |
| 65 | {{ dict "envAll" $envAll "application" "nova_cell_setup" "container" "nova_cell_setup_init" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} |
| 66 | env: |
Oleksandr Kozachenko | a10d785 | 2023-02-02 22:01:16 +0100 | [diff] [blame] | 67 | {{- with $env := dict "ksUserSecret" $envAll.Values.secrets.identity.admin "useCA" (or .Values.manifests.certificates .Values.tls.identity) }} |
Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 68 | {{- include "helm-toolkit.snippets.keystone_openrc_env_vars" $env | indent 12 }} |
| 69 | {{- end }} |
| 70 | command: |
| 71 | - /tmp/cell-setup-init.sh |
| 72 | volumeMounts: |
| 73 | - name: pod-tmp |
| 74 | mountPath: /tmp |
| 75 | - name: nova-bin |
| 76 | mountPath: /tmp/cell-setup-init.sh |
| 77 | subPath: cell-setup-init.sh |
| 78 | readOnly: true |
Oleksandr Kozachenko | a10d785 | 2023-02-02 22:01:16 +0100 | [diff] [blame] | 79 | {{- dict "enabled" (or .Values.manifests.certificates .Values.tls.identity) "name" .Values.secrets.tls.compute.osapi.internal | include "helm-toolkit.snippets.tls_volume_mount" | indent 12 }} |
Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 80 | containers: |
| 81 | - name: nova-cell-setup |
| 82 | {{ tuple $envAll "nova_cell_setup" | include "helm-toolkit.snippets.image" | indent 10 }} |
| 83 | {{ tuple $envAll $envAll.Values.pod.resources.jobs.cell_setup | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} |
| 84 | {{ dict "envAll" $envAll "application" "nova_cell_setup" "container" "nova_cell_setup" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} |
Oleksandr Kozachenko | a10d785 | 2023-02-02 22:01:16 +0100 | [diff] [blame] | 85 | {{- if or .Values.manifests.certificates .Values.tls.identity }} |
| 86 | env: |
| 87 | - name: REQUESTS_CA_BUNDLE |
| 88 | value: "/etc/nova/certs/ca.crt" |
| 89 | {{- end }} |
Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 90 | command: |
| 91 | - /tmp/cell-setup.sh |
| 92 | volumeMounts: |
| 93 | - name: pod-tmp |
| 94 | mountPath: /tmp |
| 95 | - name: nova-bin |
| 96 | mountPath: /tmp/cell-setup.sh |
| 97 | subPath: cell-setup.sh |
| 98 | readOnly: true |
| 99 | - name: etcnova |
| 100 | mountPath: /etc/nova |
| 101 | - name: nova-etc |
| 102 | mountPath: /etc/nova/nova.conf |
| 103 | subPath: nova.conf |
| 104 | readOnly: true |
| 105 | {{- if .Values.conf.nova.DEFAULT.log_config_append }} |
| 106 | - name: nova-etc |
| 107 | mountPath: {{ .Values.conf.nova.DEFAULT.log_config_append }} |
| 108 | subPath: {{ base .Values.conf.nova.DEFAULT.log_config_append }} |
| 109 | readOnly: true |
| 110 | {{- end }} |
| 111 | - name: nova-etc |
| 112 | mountPath: /etc/nova/policy.yaml |
| 113 | subPath: policy.yaml |
| 114 | readOnly: true |
| 115 | {{- dict "enabled" .Values.manifests.certificates "name" .Values.endpoints.oslo_db.auth.admin.secret.tls.internal "path" "/etc/mysql/certs" | include "helm-toolkit.snippets.tls_volume_mount" | indent 12 }} |
Oleksandr Kozachenko | a10d785 | 2023-02-02 22:01:16 +0100 | [diff] [blame] | 116 | {{- dict "enabled" (or .Values.manifests.certificates .Values.tls.identity) "name" .Values.secrets.tls.compute.osapi.internal | include "helm-toolkit.snippets.tls_volume_mount" | indent 12 }} |
Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 117 | volumes: |
| 118 | - name: pod-tmp |
| 119 | emptyDir: {} |
| 120 | - name: etcnova |
| 121 | emptyDir: {} |
| 122 | - name: nova-etc |
| 123 | secret: |
| 124 | secretName: nova-etc |
| 125 | defaultMode: 0444 |
| 126 | - name: nova-bin |
| 127 | configMap: |
| 128 | name: nova-bin |
| 129 | defaultMode: 0555 |
| 130 | {{- dict "enabled" .Values.manifests.certificates "name" .Values.endpoints.oslo_db.auth.admin.secret.tls.internal | include "helm-toolkit.snippets.tls_volume" | indent 8 }} |
Oleksandr Kozachenko | a10d785 | 2023-02-02 22:01:16 +0100 | [diff] [blame] | 131 | {{- dict "enabled" (or .Values.manifests.certificates .Values.tls.identity) "name" .Values.secrets.tls.compute.osapi.internal | include "helm-toolkit.snippets.tls_volume" | indent 8 }} |
Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 132 | --- |
| 133 | kind: ClusterRole |
| 134 | apiVersion: rbac.authorization.k8s.io/v1 |
| 135 | metadata: |
| 136 | name: {{ $serviceAccountName }} |
| 137 | rules: |
| 138 | - apiGroups: |
| 139 | - '' |
| 140 | resources: |
| 141 | - nodes |
| 142 | verbs: |
| 143 | - get |
| 144 | - list |
| 145 | --- |
| 146 | apiVersion: rbac.authorization.k8s.io/v1 |
| 147 | kind: ClusterRoleBinding |
| 148 | metadata: |
| 149 | name: {{ $serviceAccountName }} |
| 150 | subjects: |
| 151 | - kind: ServiceAccount |
| 152 | name: {{ $serviceAccountName }} |
| 153 | namespace: {{ $envAll.Release.Namespace }} |
| 154 | roleRef: |
| 155 | kind: ClusterRole |
| 156 | name: {{ $serviceAccountName }} |
| 157 | apiGroup: rbac.authorization.k8s.io |
| 158 | {{- end }} |