maas/charts/maas/templates/statefulset-region.yaml

213 lines
8.5 KiB
YAML

{{/*
# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License. */}}
{{- if .Values.manifests.region_statefulset }}
{{- $envAll := . }}
{{- $serviceAccountName := "maas-region" }}
{{- $mounts_maas_region := .Values.pod.mounts.maas_region.maas_region }}
{{- $mounts_maas_region_init := .Values.pod.mounts.maas_region.init_container }}
{{ tuple $envAll "region_controller" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }}
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: maas-region
annotations:
{{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }}
labels:
{{ tuple $envAll "maas" "region" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
spec:
selector:
matchLabels:
{{ tuple $envAll "maas" "region" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 6 }}
serviceName: maas-region-ui
replicas: {{ .Values.pod.replicas.region }}
updateStrategy:
type: 'RollingUpdate'
template:
metadata:
labels:
{{ tuple $envAll "maas" "region" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
annotations:
{{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" | indent 8 }}
configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "helm-toolkit.utils.hash" }}
configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "helm-toolkit.utils.hash" }}
{{- $containers := "init maas-region" }}
{{- if .Values.conf.cache.enabled }}
{{- $containers = printf "%s maas-cache" $containers }}
{{- end }}
{{- $containers = splitList " " $containers }}
{{ dict "envAll" $envAll "podName" "maas-region" "containerNames" $containers | include "helm-toolkit.snippets.kubernetes_mandatory_access_control_annotation" | indent 8 }}
spec:
{{ dict "envAll" $envAll "application" "region" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }}
serviceAccountName: {{ $serviceAccountName }}
affinity:
{{ tuple $envAll "maas" "region" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }}
nodeSelector:
{{ .Values.labels.region.node_selector_key }}: {{ .Values.labels.region.node_selector_value }}
initContainers:
{{ tuple $envAll "region_controller" $mounts_maas_region_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
containers:
{{- if .Values.conf.cache.enabled }}
- name: maas-cache
{{ dict "envAll" $envAll "application" "region" "container" "maas_cache" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
image: {{ .Values.images.tags.maas_cache }}
imagePullPolicy: {{ .Values.images.pull_policy }}
{{- end }}
{{- if .Values.manifests.maas_syslog }}
- name: maas-syslog
image: {{ .Values.images.tags.maas_region }}
imagePullPolicy: {{ .Values.images.pull_policy }}
command:
- /tmp/start-syslog.sh
env:
- name: RSYSLOG_CONFFILE
value: "/etc/rsyslog.conf"
- name: LOGFILE
value: {{ printf "%s/%s" .Values.conf.syslog.logpath .Values.conf.syslog.logfile | quote }}
volueMounts:
- mountPath: /etc/rsyslog.conf
name: maas-etc
subPath: rsyslog.conf
readOnly: true
- mountPath: /tmp/start-syslog.sh
name: maas-bin
subPath: start-syslog.sh
readOnly: true
- mountPath: {{ .Values.conf.syslog.logpath }}
name: syslog-archive
readOnly: false
{{- end }}
- name: maas-region
image: {{ .Values.images.tags.maas_region }}
imagePullPolicy: {{ .Values.images.pull_policy }}
tty: true
{{ tuple $envAll $envAll.Values.pod.resources.maas_region | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
{{ dict "envAll" $envAll "application" "region" "container" "maas_region" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
ports:
- name: region-api
containerPort: {{ tuple "maas_region" "podport" "region_api" $envAll | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
- name: region-proxy
containerPort: {{ tuple "maas_region" "podport" "region_proxy" $envAll | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
readinessProbe:
tcpSocket:
port: {{ tuple "maas_region" "podport" "region_api" $envAll | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
command:
- /tmp/start.sh
volumeMounts:
- mountPath: /sys/fs/cgroup
name: host-sys-fs-cgroup
readOnly: true
- mountPath: /run
name: pod-run
- mountPath: /run/lock
name: pod-run-lock
- mountPath: /tmp
name: pod-tmp
- name: maas-region-secret
mountPath: /var/lib/maas/secret
subPath: REGION_SECRET
readOnly: true
- name: maas-etc
mountPath: /etc/bind/named.conf.options
subPath: named.conf.options
readOnly: true
- name: maas-etc
mountPath: /etc/maas/regiond.conf
subPath: regiond.conf
readOnly: true
{{- if .Values.conf.curtin.override }}
- name: maas-etc
mountPath: /etc/maas/preseeds/curtin_userdata
subPath: curtin_userdata
readOnly: true
{{- end }}
{{- if .Values.conf.drivers }}
- name: maas-etc
mountPath: /etc/maas/drivers.yaml
subPath: drivers.yaml
readOnly: true
{{- end }}
- name: maas-bin
mountPath: /tmp/start.sh
subPath: start.sh
readOnly: true
- name: maas-etc
mountPath: /etc/nsswitch.conf
subPath: nsswitch.conf
readOnly: true
{{- if .Values.conf.maas.ntp.disable_ntpd_region }}
- name: maas-bin
mountPath: /usr/sbin/ntpd
subPath: ntpd.sh
readOnly: true
{{- end }}
{{- if .Values.conf.cloudconfig.override }}
- name: maas-etc
mountPath: /etc/maas/preseeds/enlist
subPath: enlist
readOnly: true
- name: maas-etc
mountPath: /etc/maas/preseeds/commissioning
subPath: commissioning
readOnly: true
- name: maas-etc
mountPath: /etc/maas/preseeds/curtin
subPath: curtin
readOnly: true
{{- end }}
- name: maas-etc
mountPath: /etc/default/bind9
subPath: bind9
readOnly: true
{{- if $mounts_maas_region.volumeMounts }}{{ toYaml $mounts_maas_region.volumeMounts | indent 12 }}{{ end }}
volumes:
- name: host-sys-fs-cgroup
hostPath:
path: /sys/fs/cgroup
- name: pod-run
emptyDir: {}
- name: pod-run-lock
emptyDir: {}
- name: pod-tmp
emptyDir: {}
- name: maas-etc
configMap:
name: maas-etc
defaultMode: 0444
- name: maas-bin
configMap:
name: maas-bin
defaultMode: 0555
- name: maas-region-secret
secret:
secretName: {{ .Values.secrets.maas_region.name }}
{{- if $mounts_maas_region.volumes }}{{ toYaml $mounts_maas_region.volumes | indent 8 }}{{ end }}
{{- if .Values.manifests.maas_syslog }}
volumeClaimTemplates:
- metadata:
name: syslog-archive
annotations:
{{ .Values.storage.syslog.pvc.class_path }}: {{ .Values.storage.syslog.pvc.class_name }}
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: {{ .Values.storage.syslog.pvc.size }}
{{- end }}
...
{{- end }}