blob: 7d4b8387477be61d45c892a6e1dff9c041c6a8f6 [file] [log] [blame]
Yaguang Tang4e18cd02024-07-31 21:54:44 +08001{{/*
2Licensed under the Apache License, Version 2.0 (the "License");
3you may not use this file except in compliance with the License.
4You may obtain a copy of the License at
5
6 http://www.apache.org/licenses/LICENSE-2.0
7
8Unless required by applicable law or agreed to in writing, software
9distributed under the License is distributed on an "AS IS" BASIS,
10WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11See the License for the specific language governing permissions and
12limitations under the License.
13*/}}
14
15{{- if .Values.manifests.deployment_api }}
16{{- $envAll := . }}
17
18{{- $mounts_ironic_api := .Values.pod.mounts.ironic_api.ironic_api }}
19{{- $mounts_ironic_api_init := .Values.pod.mounts.ironic_api.init_container }}
20
21{{- $serviceAccountName := "ironic-api" }}
22{{ tuple $envAll "api" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }}
23---
24apiVersion: apps/v1
25kind: Deployment
26metadata:
27 name: ironic-api
28 annotations:
29 {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }}
30 labels:
31{{ tuple $envAll "ironic" "api" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
32spec:
33 replicas: {{ .Values.pod.replicas.api }}
34 selector:
35 matchLabels:
36{{ tuple $envAll "ironic" "api" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 6 }}
37{{ tuple $envAll | include "helm-toolkit.snippets.kubernetes_upgrades_deployment" | indent 2 }}
38 template:
39 metadata:
40 labels:
41{{ tuple $envAll "ironic" "api" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
42 annotations:
43{{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" | indent 8 }}
44 configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "helm-toolkit.utils.hash" }}
45 configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "helm-toolkit.utils.hash" }}
46{{ tuple "ironic_api" . | include "helm-toolkit.snippets.custom_pod_annotations" | indent 8 }}
47 spec:
48 serviceAccountName: {{ $serviceAccountName }}
49 affinity:
50{{ tuple $envAll "ironic" "api" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }}
51 nodeSelector:
52 {{ .Values.labels.api.node_selector_key }}: {{ .Values.labels.api.node_selector_value }}
53{{ if $envAll.Values.pod.tolerations.ironic.enabled }}
54{{ tuple $envAll "ironic" | include "helm-toolkit.snippets.kubernetes_tolerations" | indent 10 }}
55{{ end }}
56 terminationGracePeriodSeconds: {{ .Values.pod.lifecycle.termination_grace_period.api.timeout | default "30" }}
57 initContainers:
58{{ tuple $envAll "api" $mounts_ironic_api_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
59{{- if and (.Values.bootstrap.object_store.enabled) (.Values.bootstrap.object_store.openstack.enabled) }}
60 - name: ironic-retrive-swift-config
61{{ tuple $envAll "ironic_retrive_swift_config" | include "helm-toolkit.snippets.image" | indent 10 }}
62{{ tuple $envAll $envAll.Values.pod.resources.conductor | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
63 env:
64 - name: OS_SWIFT_API_VERSION
65 value: {{ .Values.conf.ironic.glance.swift_api_version | quote }}
66{{- with $env := dict "ksUserSecret" .Values.secrets.identity.glance }}
67{{- include "helm-toolkit.snippets.keystone_openrc_env_vars" $env | indent 12 }}
68{{- end }}
69 command:
70 - /tmp/retreive-swift-config.sh
71 volumeMounts:
72 - name: pod-tmp
73 mountPath: /tmp
74 - name: ironic-bin
75 mountPath: /tmp/retreive-swift-config.sh
76 subPath: retreive-swift-config.sh
77 readOnly: true
78 - name: pod-shared
79 mountPath: /tmp/pod-shared
80{{- end }}
81{{- if and (.Values.bootstrap.network.enabled) (.Values.bootstrap.network.openstack.enabled) }}
82 - name: ironic-retrive-cleaning-net
83{{ tuple $envAll "ironic_retrive_cleaning_network" | include "helm-toolkit.snippets.image" | indent 10 }}
84{{ tuple $envAll $envAll.Values.pod.resources.conductor | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
85 env:
86{{- with $env := dict "ksUserSecret" .Values.secrets.identity.ironic }}
87{{- include "helm-toolkit.snippets.keystone_openrc_env_vars" $env | indent 12 }}
88{{- end }}
89{{ include "helm-toolkit.utils.to_k8s_env_vars" $envAll.Values.network.pxe | indent 12 }}
90 command:
91 - /tmp/retreive-cleaning-network.sh
92 volumeMounts:
93 - name: pod-tmp
94 mountPath: /tmp
95 - name: ironic-bin
96 mountPath: /tmp/retreive-cleaning-network.sh
97 subPath: retreive-cleaning-network.sh
98 readOnly: true
99 - name: pod-shared
100 mountPath: /tmp/pod-shared
101{{- end }}
102 containers:
103 - name: ironic-api
104{{ tuple $envAll "ironic_api" | include "helm-toolkit.snippets.image" | indent 10 }}
105{{ tuple $envAll $envAll.Values.pod.resources.api | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
106 command:
107 - /tmp/ironic-api.sh
108 - start
109 lifecycle:
110 preStop:
111 exec:
112 command:
113 - /tmp/ironic-api.sh
114 - stop
115 ports:
116 - containerPort: {{ tuple "baremetal" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
117 readinessProbe:
118 httpGet:
119 scheme: {{ tuple "baremetal" "internal" "api" . | include "helm-toolkit.endpoints.keystone_endpoint_scheme_lookup" | upper }}
120 path: /
121 port: {{ tuple "baremetal" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
122 volumeMounts:
123 - name: pod-tmp
124 mountPath: /tmp
125 - name: ironic-bin
126 mountPath: /tmp/ironic-api.sh
127 subPath: ironic-api.sh
128 readOnly: true
129 - name: ironic-etc
130 mountPath: /etc/ironic/ironic.conf
131 subPath: ironic.conf
132 readOnly: true
133 {{- if .Values.conf.ironic.DEFAULT.log_config_append }}
134 - name: ironic-etc
135 mountPath: {{ .Values.conf.ironic.DEFAULT.log_config_append }}
136 subPath: {{ base .Values.conf.ironic.DEFAULT.log_config_append }}
137 readOnly: true
138 {{- end }}
139 - name: ironic-etc
140 mountPath: /etc/ironic/policy.yaml
141 subPath: policy.yaml
142 readOnly: true
143 - name: pod-shared
144 mountPath: /tmp/pod-shared
145{{ if $mounts_ironic_api.volumeMounts }}{{ toYaml $mounts_ironic_api.volumeMounts | indent 12 }}{{ end }}
146 volumes:
147 - name: pod-tmp
148 emptyDir: {}
149 - name: ironic-bin
150 configMap:
151 name: ironic-bin
152 defaultMode: 0555
153 - name: ironic-etc
154 secret:
155 secretName: ironic-etc
156 defaultMode: 0444
157 - name: pod-shared
158 emptyDir: {}
159{{ if $mounts_ironic_api.volumes }}{{ toYaml $mounts_ironic_api.volumes | indent 8 }}{{ end }}
160{{- end }}