6d52b2a087da2aaaae48ebf21c46b8643242183e
[oom.git] / kubernetes / dcaegen2-services / common / dcaegen2-services-common / templates / _job.tpl
1 {{/*
2 #============LICENSE_START========================================================
3 # ================================================================================
4 # Copyright (c) 2021 J. F. Lucas. All rights reserved.
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 # ============LICENSE_END=========================================================
18 */}}
19 {{/*
20 dcaegen2-services-common.consulDeleteJob:
21 This template generates a Kubernetes Job that runs when a
22 DCAE microservice is deleted.  The Job deletes the Consul
23 entry that contains the microservice's configuration.
24
25 The template expects the full chart context as input.  A chart for a
26 DCAE microservice references this template using:
27 {{ include "dcaegen2-services-common.consulDeleteJob" . }}
28 The template directly references data in .Values, and indirectly (through its
29 use of templates from the ONAP "common" collection) references data in
30 .Release.
31
32 The microservice configuration data is loaded into Consul by an
33 initContainer that is part of the Kubernetes Deployment for the microservice.
34 See the documentation for dcaegen2-services-common.microserviceDeployment
35 for more information.
36 */}}
37 {{- define "dcaegen2-services-common.consulDeleteJob" -}}
38 apiVersion: batch/v1
39 kind: Job
40 metadata:
41   name: {{ include "common.fullname" . }}-delete-config
42   namespace: {{ include "common.namespace" . }}
43   labels: {{ include "common.labels" . | nindent 4 }}
44   annotations:
45     "helm.sh/hook": pre-delete
46     "helm.sh/hook-delete-policy": hook-succeeded,hook-failed
47 spec:
48   template:
49     metadata:
50       name: {{ include "common.fullname" . }}-delete-config
51       labels: {{ include "common.labels" . | nindent 8 }}
52     spec:
53       restartPolicy: Never
54       containers:
55       - name: dcae-config-delete
56         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.consulLoaderImage }}
57         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
58         args:
59         - --delete-key
60         - {{ include "common.name" . }}
61 {{ end -}}