maas/charts/maas/templates/job-export-api-key.yaml
Scott Hussey fced4bd1d2 Fix - Job robustness
- Fix bash conditional error causing the export
  key job to fail for any chart upgrade
- Enhance the image import/configuration job to
  be more robust with additional retrying and better
  failure detection

Change-Id: I874a98587a56b03905d740cd53cdd70a8419a04e
2018-03-09 22:50:21 -05:00

135 lines
4.1 KiB
YAML

{{/*
Copyright 2017 The Openstack-Helm Authors.
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.
*/}}
{{- $envAll := . }}
{{- $dependencies := .Values.dependencies.export_api_key }}
{{- $initMounts := .Values.pod.mounts.export_api_key.export_api_key }}
{{- $serviceAccountName := "maas-export-api-key" }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ $serviceAccountName }}
namespace: {{ $envAll.Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
name: {{ $envAll.Release.Name }}-{{ $serviceAccountName }}
namespace: {{ $envAll.Release.Namespace }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ $envAll.Release.Name }}-{{ $envAll.Release.Namespace }}-{{ $serviceAccountName }}
subjects:
- kind: ServiceAccount
name: {{ $serviceAccountName }}
namespace: {{ $envAll.Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: Role
metadata:
name: {{ $envAll.Release.Name }}-{{ $envAll.Release.Namespace }}-{{ $serviceAccountName }}
namespace: {{ $envAll.Release.Namespace }}
rules:
- apiGroups:
- ""
- extensions
- batch
- apps
verbs:
- get
- list
resources:
- services
- endpoints
- jobs
- pods
- apiGroups:
- ""
verbs:
- get
- create
- update
- delete
resources:
- secrets
---
apiVersion: batch/v1
kind: Job
metadata:
name: maas-export-api-key
spec:
template:
metadata:
labels:
{{ tuple $envAll "maas" "export-api-key" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
spec:
serviceAccountName: {{ $serviceAccountName }}
restartPolicy: OnFailure
nodeSelector:
{{ .Values.labels.region.node_selector_key }}: {{ .Values.labels.region.node_selector_value }}
initContainers:
{{ tuple $envAll $dependencies $initMounts | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
containers:
- name: exporter
image: {{ .Values.images.tags.export_api_key }}
imagePullPolicy: {{ .Values.images.pull_policy }}
env:
- name: SECRET_NAMESPACE
value: {{ .Values.conf.maas.credentials.secret.namespace }}
- name: ADMIN_USERNAME
valueFrom:
secretKeyRef:
name: {{ .Values.secrets.maas_users.admin }}
key: USERNAME
- name: SECRET_NAME
value: {{ .Values.conf.maas.credentials.secret.name }}
command:
- /tmp/export-api-key.sh
readinessProbe:
exec:
command:
- /tmp/job-readiness.sh
initialDelaySeconds: 60
volumeMounts:
- name: maas-bin
mountPath: /tmp/export-api-key.sh
subPath: export-api-key.sh
readOnly: true
- name: maas-bin
mountPath: /tmp/job-readiness.sh
subPath: job-readiness.sh
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
volumes:
- name: maas-bin
configMap:
name: maas-bin
defaultMode: 0555
- name: maas-etc
configMap:
name: maas-etc
defaultMode: 0444