blob: 54ee1515bcfb362085bb3b16c716c2c677e523ab [file] [log] [blame]
Lathish818ee5d2020-08-26 13:45:03 +01001{{/*
2################################################################################
3# Copyright (c) 2020 Nordix Foundation. #
Konrad Bańka52c38b92020-10-28 16:49:19 +01004# Copyright © 2020 Samsung Electronics, Modifications #
Lathish818ee5d2020-08-26 13:45:03 +01005# #
6# Licensed under the Apache License, Version 2.0 (the "License"); #
7# you may not use this file except in compliance with the License. #
8# You may obtain a copy of the License at #
9# #
10# http://www.apache.org/licenses/LICENSE-2.0 #
11# #
12# Unless required by applicable law or agreed to in writing, software #
13# distributed under the License is distributed on an "AS IS" BASIS, #
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
15# See the License for the specific language governing permissions and #
16# limitations under the License. #
17################################################################################
18*/}}
19
PatrikBuhr746ff372021-04-30 15:12:51 +020020kind: StatefulSet
Lathish818ee5d2020-08-26 13:45:03 +010021apiVersion: apps/v1
PatrikBuhr746ff372021-04-30 15:12:51 +020022metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
Lathish818ee5d2020-08-26 13:45:03 +010023spec:
PatrikBuhr746ff372021-04-30 15:12:51 +020024 serviceName: {{ include "common.servicename" . }}
Lathish818ee5d2020-08-26 13:45:03 +010025 replicas: {{ index .Values.replicaCount }}
26 selector: {{- include "common.selectors" . | nindent 4 }}
27 template:
28 metadata:
29 labels: {{- include "common.labels" . | nindent 8 }}
30 spec:
Sylvain Desbureauxb5353c92021-02-15 11:30:29 +010031 initContainers: {{ include "common.certInitializer.initContainer" . | nindent 6 }}
Konrad Bańka52c38b92020-10-28 16:49:19 +010032 - name: {{ include "common.name" . }}-bootstrap-config
Sylvain Desbureauxd4a6afd2020-11-21 22:01:15 +010033 image: {{ include "repositoryGenerator.image.envsubst" . }}
Lathish818ee5d2020-08-26 13:45:03 +010034 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
35 command:
36 - sh
37 args:
38 - -c
Sylvain Desbureauxb5353c92021-02-15 11:30:29 +010039 - |
40 export $(cat {{ .Values.certInitializer.credsPath }}/mycreds.prop\
41 | xargs -0)
42 cd /config-input
43 for PFILE in `ls -1`
44 do
45 envsubst <${PFILE} >/config/${PFILE}
46 chmod o+w /config/${PFILE}
47 done
48 cat /config/application.yaml
Lathish818ee5d2020-08-26 13:45:03 +010049 env:
50 - name: A1CONTROLLER_USER
51 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "controller-secret" "key" "login") | indent 10 }}
52 - name: A1CONTROLLER_PASSWORD
53 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "controller-secret" "key" "password") | indent 10 }}
Sylvain Desbureauxb5353c92021-02-15 11:30:29 +010054 volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 8 }}
Lathish818ee5d2020-08-26 13:45:03 +010055 - mountPath: /config-input
56 name: {{ include "common.fullname" . }}-policy-conf-input
57 - mountPath: /config
58 name: config
59 containers:
Konrad Bańka52c38b92020-10-28 16:49:19 +010060 - name: {{ include "common.name" . }}-update-config
61 image: "{{ .Values.global.envsubstImage }}"
62 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
63 securityContext:
64 runAsGroup: {{ .Values.groupID }}
65 runAsUser: {{ .Values.userID }}
66 runAsNonRoot: true
67 command:
68 - sh
69 args:
70 - /tmp/scripts/daemon.sh
71 env:
72 - name: A1CONTROLLER_USER
73 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "controller-secret" "key" "login") | indent 10 }}
74 - name: A1CONTROLLER_PASSWORD
75 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "controller-secret" "key" "password") | indent 10 }}
76 volumeMounts:
77 - mountPath: /tmp/scripts
78 name: {{ include "common.fullname" . }}-envsubst-scripts
79 - mountPath: /config-input
80 name: {{ include "common.fullname" . }}-policy-conf-input
81 - mountPath: /config
82 name: config
Lathish818ee5d2020-08-26 13:45:03 +010083 - name: {{ include "common.name" . }}
Sylvain Desbureauxd4a6afd2020-11-21 22:01:15 +010084 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
Lathish818ee5d2020-08-26 13:45:03 +010085 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
86 ports: {{ include "common.containerPorts" . | nindent 10 }}
87 readinessProbe:
88 tcpSocket:
89 port: {{ .Values.readiness.port }}
90 initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
91 periodSeconds: {{ .Values.liveness.periodSeconds }}
92 livenessProbe:
93 httpGet:
94 path: /status
95 port: {{ .Values.liveness.port }}
96 scheme: {{ if (include "common.needTLS" .) }}HTTPS{{ else }}HTTP{{ end }}
97 initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
98 periodSeconds: {{ .Values.liveness.periodSeconds }}
Sylvain Desbureauxb5353c92021-02-15 11:30:29 +010099 volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 8 }}
Lathish818ee5d2020-08-26 13:45:03 +0100100 - name: config
Sylvain Desbureauxb5353c92021-02-15 11:30:29 +0100101 mountPath: /opt/app/policy-agent/data/application_configuration.json
102 subPath: application_configuration.json
103 - name: config
104 mountPath: /opt/app/policy-agent/config/application.yaml
PatrikBuhr746ff372021-04-30 15:12:51 +0200105 subPath: application.yaml
106 - name: {{ include "common.fullname" . }}
PatrikBuhr27c94362021-04-09 10:58:58 +0200107 mountPath: "/var/policy-management-service/database"
Lathish818ee5d2020-08-26 13:45:03 +0100108 resources: {{ include "common.resources" . | nindent 10 }}
Sylvain Desbureauxb5353c92021-02-15 11:30:29 +0100109 volumes: {{ include "common.certInitializer.volumes" . | nindent 8 }}
Lathish818ee5d2020-08-26 13:45:03 +0100110 - name: {{ include "common.fullname" . }}-policy-conf-input
111 configMap:
112 name: {{ include "common.fullname" . }}-policy-conf
Konrad Bańka52c38b92020-10-28 16:49:19 +0100113 - name: {{ include "common.fullname" . }}-envsubst-scripts
114 configMap:
115 name: {{ include "common.fullname" . }}-envsubst-scripts
Konrad Bańkaa8584622021-03-23 09:09:01 +0100116 defaultMode: 0555
Lathish818ee5d2020-08-26 13:45:03 +0100117 - name: config
118 emptyDir:
119 medium: Memory
PatrikBuhr746ff372021-04-30 15:12:51 +0200120{{- if not .Values.persistence.enabled }}
121 - name: {{ include "common.fullname" . }}
122 emptyDir: {}
123{{- else }}
124 volumeClaimTemplates:
125 - {{include "common.PVCTemplate" . | indent 6 | trim }}
126{{- end }}