From 55beab680f18daeb79f6cf48a66aef3a572ababb Mon Sep 17 00:00:00 2001 From: Luna Das Date: Wed, 11 Mar 2020 22:28:28 +0530 Subject: [PATCH] Add more fields to daemonjob crd spec. Change-Id: I1690035c7e35887245bbdcfdc97b19409fd6ab8a --- daemonjob-controller/templates/crd.yaml | 6 ++++++ daemonjob-controller/templates/deployment.yaml | 4 +++- daemonjob-controller/values.yaml | 5 +++++ metacontroller/templates/statefulset.yaml | 6 ++---- tools/deployment/common/daemonjob-controller.sh | 8 ++++++++ 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/daemonjob-controller/templates/crd.yaml b/daemonjob-controller/templates/crd.yaml index 0a8edf2e8..48fcfc8c1 100644 --- a/daemonjob-controller/templates/crd.yaml +++ b/daemonjob-controller/templates/crd.yaml @@ -70,6 +70,10 @@ spec: type: string imagePullPolicy: type: string + args: + type: array + items: + type: string command: type: array items: @@ -353,6 +357,8 @@ spec: type: boolean stdin: type: boolean + hostNetwork: + type: boolean terminationGracePeriodSeconds: type: integer status: diff --git a/daemonjob-controller/templates/deployment.yaml b/daemonjob-controller/templates/deployment.yaml index 4f7d856c5..33eaf1001 100644 --- a/daemonjob-controller/templates/deployment.yaml +++ b/daemonjob-controller/templates/deployment.yaml @@ -24,7 +24,6 @@ metadata: name: daemonjob-controller annotations: {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" | indent 4 }} - configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "helm-toolkit.utils.hash" }} namespace: {{ .Release.Namespace }} labels: {{ tuple $envAll "daemonjob-controller" "controller" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} @@ -37,10 +36,13 @@ spec: metadata: annotations: {{ dict "envAll" $envAll "podName" "daemonjob-controller" "containerNames" (list "controller") | include "helm-toolkit.snippets.kubernetes_mandatory_access_control_annotation" | indent 8 }} + configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "helm-toolkit.utils.hash" }} labels: {{ tuple $envAll "daemonjob-controller" "controller" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} spec: serviceAccountName: {{ $serviceAccountName }} + nodeSelector: + {{ .Values.labels.daemonjob_controller.node_selector_key }}: {{ .Values.labels.daemonjob_controller.node_selector_value | quote }} containers: - name: controller {{ tuple $envAll "python" | include "helm-toolkit.snippets.image" | indent 8 }} diff --git a/daemonjob-controller/values.yaml b/daemonjob-controller/values.yaml index b3c8a76fe..6ac2a8bd1 100644 --- a/daemonjob-controller/values.yaml +++ b/daemonjob-controller/values.yaml @@ -27,6 +27,11 @@ images: - dep_check - image_repo_sync +labels: + daemonjob_controller: + node_selector_key: openstack-control-plane + node_selector_value: enabled + crds: group_name: ctl.example.com group_version: v1 diff --git a/metacontroller/templates/statefulset.yaml b/metacontroller/templates/statefulset.yaml index 81da00032..a98e5c284 100644 --- a/metacontroller/templates/statefulset.yaml +++ b/metacontroller/templates/statefulset.yaml @@ -64,12 +64,8 @@ spec: {{ tuple $envAll "metacontroller" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 6 }} serviceName: {{ tuple "metacontroller" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }} podManagementPolicy: "Parallel" - affinity: -{{ tuple $envAll "metacontroller" "server" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 4 }} replicas: {{ .Values.pod.replicas.metacontroller }} terminationGracePeriodSeconds: {{ .Values.pod.lifecycle.termination_grace_period.server.timeout | default "30" }} - nodeSelector: - {{ .Values.labels.server.node_selector_key }}: {{ .Values.labels.server.node_selector_value | quote }} template: metadata: labels: @@ -79,6 +75,8 @@ spec: spec: {{ dict "envAll" . "application" "metacontroller" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }} serviceAccountName: {{ $serviceAccountName }} + nodeSelector: + {{ .Values.labels.server.node_selector_key }}: {{ .Values.labels.server.node_selector_value | quote }} containers: - name: metacontroller {{ tuple $envAll "metacontroller" | include "helm-toolkit.snippets.image" | indent 8 }} diff --git a/tools/deployment/common/daemonjob-controller.sh b/tools/deployment/common/daemonjob-controller.sh index fa9d198e7..9af1ac4be 100755 --- a/tools/deployment/common/daemonjob-controller.sh +++ b/tools/deployment/common/daemonjob-controller.sh @@ -56,7 +56,14 @@ apiVersion: ctl.example.com/v1 kind: DaemonJob metadata: name: hello-world + annotations: + imageregistry: "https://hub.docker.com/" + labels: + app: hello-world spec: + selector: + matchLabels: + app: hello-world template: metadata: labels: @@ -90,6 +97,7 @@ until [[ "$(kubectl get $dj hello-world -o 'jsonpath={.status.conditions[0].stat else daemonset_pod_status=$(kubectl get pods | awk '/hello-world-dj/{print $3}') if [ $daemonset_pod_status == 'Init:0/1' ]; then + kubectl describe dj hello-world init_container_status=$(kubectl get pod $daemonset_pod -o 'jsonpath={.status.initContainerStatuses[0].state.running}') if [ ! -z "$init_container_status" ]; then expected_log=$(kubectl logs $daemonset_pod -c hello-world)