aboutsummaryrefslogtreecommitdiffstats
path: root/robot/assets/helm/ves-client/templates/_helpers.tpl
blob: e8940d786705d79055d905ce5c25e08d2c50fbdb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
{{/*
Expand the name of the chart.
*/}}
{{- define "ves-client.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "ves-client.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "ves-client.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "ves-client.labels" -}}
helm.sh/chart: {{ include "ves-client.chart" . }}
{{ include "ves-client.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "ves-client.selectorLabels" -}}
app.kubernetes.io/name: {{ include "ves-client.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "ves-client.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "ves-client.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Common namespace
*/}}
{{- define "ves-client.namespace" -}}
  {{- default .Release.Namespace .Values.nsPrefix -}}
{{- end -}}

{{/*
Define dns names in certificate
*/}}
{{- define "ves-client.dnsNames" -}}
{{- range $dnsName := $.Values.certificates.dnsNames }}
- {{ $dnsName }}
{{- end }}
{{- end }}

{{/*
Define dns names in certificate
*/}}
{{- define "ves-client.init" -}}
{{ if eq .Values.certMethod "wrongCert" }}
- name: {{ include "common.name" . }}-readiness
  env:
  - name: NAMESPACE
    valueFrom:
      fieldRef:
        apiVersion: v1
        fieldPath: metadata.namespace
  image: {{ .Values.certInitializer.image }}
  imagePullPolicy: {{ .Values.pullPolicy | default .Values.pullPolicy }}
  volumeMounts:
    - name: {{ .Values.aafVolumeName }}
      mountPath: /opt/app/osaaf
{{- end }}
{{- end }}

{{- define "ves-client.containers" -}}
- env:
  - name: MONGO_HOSTNAME
    value: {{ .Values.config.mongoDbName | quote }}
  - name: USE_CERTIFICATE_FOR_AUTHORIZATION
    value: {{ .Values.config.useCerts | quote }}
  - name: STRICT_HOSTNAME_VERIFICATION
    value: {{ .Values.config.strictHost | quote }}
  name: {{ .Values.configMapName }}
  securityContext:
    {{- toYaml .Values.securityContext | nindent 12 }}
  image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
  imagePullPolicy: {{ .Values.image.pullPolicy }}
  ports:
    - containerPort: {{ .Values.service.port }}
      protocol: TCP
  livenessProbe:
    httpGet:
      path: /simulator/config
      port: 5000
    initialDelaySeconds: 10
    periodSeconds: 30
    timeoutSeconds: 1
    successThreshold: 1
    failureThreshold: 3
  readinessProbe:
    httpGet:
      path: /simulator/config
      port: 5000
    initialDelaySeconds: 60
    periodSeconds: 15
    timeoutSeconds: 1
    successThreshold: 1
    failureThreshold: 3
  resources:
    {{- toYaml .Values.resources | nindent 12 }}
  volumeMounts:
    {{ if eq .Values.certMethod "wrongCert" }}
    - name: certstore
      mountPath: /app/store/cert.p12
      subPath: cert.p12
    - name: certstore
      mountPath: /app/store/p12.pass
      subPath: p12.pass
    - name: {{ .Values.aafVolumeName }}
      mountPath: /app/store
    {{- end }}
    {{ if eq .Values.certMethod "cmpv2" }}
    - name: certstore
      mountPath: /app/store
    {{- end }}
{{- end }}

{{- define "ves-client.volumes" -}}
{{ if or ( eq .Values.certMethod "cmpv2" ) ( eq .Values.certMethod "wrongCert" ) }}
- name: certstore
  projected:
    sources:
      - secret:
          name: ves-client-secret-cmpv2
          items:
            - key: keystore.p12
              path: cert.p12
            - key: p12.pass
              path: p12.pass
            - key: p12.pass
              path: truststore.pass
            - key: truststore.jks
              path: trust.jks
{{- end }}
{{ if eq .Values.certMethod "wrongCert" }}
{{ include "common.certInitializer.volumes" . | nindent 8 }}
- name: {{ .Values.aafVolumeName }}
  emptyDir: {}
{{- end }}
{{- end }}