{{/* Copyright (c) 2019 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. */}} {{- if .Values.manifests.job_key_rotate }} {{- $envAll := . }} {{ $serviceAccountName := "apiserver-key-rotate" }} --- apiVersion: v1 kind: ServiceAccount metadata: name: {{ $serviceAccountName }} --- apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRole metadata: name: {{ $serviceAccountName }}-cluster rules: - apiGroups: - "" resources: - secrets verbs: - list - get - delete - create - update - patch --- apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRoleBinding metadata: name: {{ $serviceAccountName }}-cluster roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: {{ $serviceAccountName }}-cluster subjects: - kind: ServiceAccount name: {{ $serviceAccountName }} namespace: {{ $envAll.Release.Namespace }} --- apiVersion: rbac.authorization.k8s.io/v1beta1 kind: Role metadata: name: {{ $serviceAccountName }}-{{ $envAll.Release.Namespace }} rules: - apiGroups: - "" resources: - endpoints - pods verbs: - get --- apiVersion: rbac.authorization.k8s.io/v1beta1 kind: RoleBinding metadata: name: {{ $serviceAccountName }}-{{ $envAll.Release.Namespace }} roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: {{ $serviceAccountName }}-{{ $envAll.Release.Namespace }} subjects: - kind: ServiceAccount name: {{ $serviceAccountName }} namespace: {{ $envAll.Release.Namespace }} --- apiVersion: batch/v1 kind: Job metadata: name: apiserver-key-rotate annotations: {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }} spec: template: metadata: annotations: {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }} {{ dict "envAll" $envAll "podName" "kube-apiserver" "containerNames" (list "init" "apiserver-key-rotate") | include "helm-toolkit.snippets.kubernetes_mandatory_access_control_annotation" | indent 8 }} labels: {{ tuple $envAll "kube-apiserver" "key-rotate" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} spec: {{ dict "envAll" $envAll "application" "key_rotate" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }} serviceAccountName: {{ $serviceAccountName }} restartPolicy: OnFailure nodeSelector: {{ .Values.labels.job.node_selector_key }}: {{ .Values.labels.job.node_selector_value }} initContainers: {{ tuple $envAll "key_rotate" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} containers: - name: apiserver-key-rotate image: {{ .Values.images.tags.key_rotate | quote }} imagePullPolicy: {{ .Values.images.pull_policy | quote }} {{ tuple $envAll $envAll.Values.pod.resources.key_rotate | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} {{ dict "envAll" $envAll "application" "key_rotate" "container" "apiserver_key_rotate" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} env: - name: "ANNOTATION_NAME" value: {{ .Values.const.encryption_annotation | quote }} command: - /tmp/key-rotate.sh volumeMounts: - name: apiserver-bin mountPath: /tmp/key-rotate.sh subPath: key-rotate.sh readOnly: true volumes: - name: apiserver-bin configMap: name: {{ .Values.service.name }}-bin defaultMode: 0555 ... {{- end }}