maas/charts/maas/templates/job-export-api-key.yaml

130 lines
4.2 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 := . }}
{{- $initMounts := .Values.pod.mounts.export_api_key.export_api_key }}
{{- $serviceAccountName := "maas-export-api-key" }}
{{ tuple $envAll "export_api_key" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }}
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
name: {{ $envAll.Release.Name }}-{{ $serviceAccountName }}-job
namespace: {{ $envAll.Release.Namespace }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ $envAll.Release.Name }}-{{ $envAll.Release.Namespace }}-{{ $serviceAccountName }}}-job
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 }}}-job
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 "export_api_key" $initMounts | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
containers:
- name: exporter
image: {{ .Values.images.tags.export_api_key }}
{{ tuple $envAll $envAll.Values.pod.resources.jobs.export_api_key | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
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