Merge "[DMAAP] DMaaP ServiceMesh compatibility"
[oom.git] / kubernetes / portal / components / portal-cassandra / templates / deployment.yaml
1 {{/*
2 # Copyright (c) 2017 Amdocs, Bell Canada
3 # Modifications Copyright (c) 2018 AT&T
4 # Modifications Copyright (c) 2020 Nokia, Orange
5 #
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 apiVersion: apps/v1
20 kind: Deployment
21 metadata:
22   name: {{ include "common.fullname" . }}
23   namespace: {{ include "common.namespace" . }}
24   labels:
25     app: {{ include "common.name" . }}
26     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
27     release: {{ include "common.release" . }}
28     heritage: {{ .Release.Service }}
29 spec:
30   selector:
31     matchLabels:
32       app: {{ include "common.name" . }}
33   replicas: {{ .Values.replicaCount }}
34   template:
35     metadata:
36       labels:
37         app: {{ include "common.name" . }}
38         release: {{ include "common.release" . }}
39     spec:
40       containers:
41       - name: {{ include "common.name" . }}
42         image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }}
43         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
44         command:
45         - /bin/bash
46         - -c
47         - |
48           /opt/bitnami/scripts/cassandra/entrypoint.sh /opt/bitnami/scripts/cassandra/run.sh
49         ports:
50         - containerPort: {{ .Values.service.internalPort }}
51         - containerPort: {{ .Values.service.internalPort2 }}
52         - containerPort: {{ .Values.service.internalPort3 }}
53         - containerPort: {{ .Values.service.internalPort4 }}
54         - containerPort: {{ .Values.service.internalPort5 }}
55         {{ if eq .Values.liveness.enabled true }}
56         livenessProbe:
57           exec:
58             command:
59             - /bin/bash
60             - -ec
61             - |
62               nodetool status
63           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
64           periodSeconds: {{ .Values.liveness.periodSeconds }}
65           timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
66           successThreshold: {{ .Values.liveness.successThreshold }}
67           failureThreshold: {{ .Values.liveness.failureThreshold }}
68         {{ end }}
69         readinessProbe:
70           exec:
71             command:
72             - /bin/bash
73             - -ec
74             - |
75               nodetool status | grep -E "^UN\\s+${POD_IP}"
76           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
77           periodSeconds: {{ .Values.readiness.periodSeconds }}
78           timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
79           successThreshold: {{ .Values.readiness.successThreshold }}
80           failureThreshold: {{ .Values.readiness.failureThreshold }}
81         lifecycle:
82           preStop:
83             exec:
84               command:
85               - bash
86               - -ec
87               - nodetool decommission
88         env:
89           - name: CASSANDRA_USER
90             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-creds" "key" "login") | indent 12}}
91           - name: CASSANDRA_PASSWORD
92             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-creds" "key" "password") | indent 12}}
93           - name: POD_IP
94             valueFrom:
95               fieldRef:
96                 fieldPath: status.podIP
97           - name: CASSANDRA_PASSWORD_SEEDER
98             value: "yes"
99           - name: BITNAMI_DEBUG
100             value: "true"
101           - name: CASSANDRA_CLUSTER_NAME
102             value: cassandra
103           - name: CASSANDRA_NUM_TOKENS
104             value: "256"
105           - name: CASSANDRA_DATACENTER
106             value: dc1
107           - name: CASSANDRA_ENDPOINT_SNITCH
108             value: SimpleSnitch
109           - name: CASSANDRA_RACK
110             value: rack1
111           - name: CASSANDRA_ENABLE_RPC
112             value: "true"
113           {{- $flavor := include "common.flavor" . }}
114           {{- $heap := pluck $flavor .Values.heap | first }}
115           {{- if (hasKey $heap "max") }}
116           - name: MAX_HEAP_SIZE
117             value: {{ $heap.max }}
118           {{- end }}
119           {{- if (hasKey $heap "new") }}
120           - name: HEAP_NEWSIZE
121             value: {{ $heap.new }}
122           {{- end }}
123         volumeMounts:
124         - mountPath: /etc/localtime
125           name: localtime
126           readOnly: true
127         - name: cassandra-docker-entrypoint-initdb
128           mountPath: /docker-entrypoint-initdb.d/aaa_portal.cql
129           subPath: portal.cql
130         - name: {{ include "common.fullname" . }}-data
131           mountPath: /var/lib/cassandra/data
132         resources:
133 {{ include "common.resources" . | indent 12 }}
134       {{- if .Values.nodeSelector }}
135       nodeSelector:
136 {{ toYaml .Values.nodeSelector | indent 10 }}
137       {{- end -}}
138       {{- if .Values.affinity }}
139       affinity:
140 {{ toYaml .Values.affinity | indent 10 }}
141       {{- end }}
142       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
143       volumes:
144         - name: cassandra-docker-entrypoint-initdb
145           configMap:
146             name: {{ include "common.fullname" . }}-docker-entry-initd
147         - name: localtime
148           hostPath:
149             path: /etc/localtime
150       {{- if .Values.persistence.enabled }}
151         - name: {{ include "common.fullname" . }}-data
152           persistentVolumeClaim:
153             claimName: {{ include "common.fullname" . }}
154       {{- else }}
155           emptyDir: {}
156       {{- end }}
157       imagePullSecrets:
158       - name: "{{ include "common.namespace" . }}-docker-registry-key"