From 46840b6c59a26fb5400d20fe588c1a9412951a19 Mon Sep 17 00:00:00 2001 From: Lukasz Lempart Date: Fri, 23 Mar 2018 17:21:57 -0700 Subject: [PATCH] Deploy CRD as a pre-install hook **What** Using `lachlanevenson/k8s-kubectl`, which appears to be the most popular, off the shelf container with `kubectl` applied, run a job to apply the `workflow` crd. **Why** CRD is not, and cannot, be parameterized with release and so attempting to deploy as a regular template causes failures when installing subsequent releases. --- charts/argo/templates/_workflow-crd.json | 19 +++++++++++++++++++ .../templates/apply-workflow-crd-job.yaml | 18 ++++++++++++++++++ charts/argo/templates/workflow-crd.yaml | 13 ------------- 3 files changed, 37 insertions(+), 13 deletions(-) create mode 100644 charts/argo/templates/_workflow-crd.json create mode 100644 charts/argo/templates/apply-workflow-crd-job.yaml delete mode 100644 charts/argo/templates/workflow-crd.yaml diff --git a/charts/argo/templates/_workflow-crd.json b/charts/argo/templates/_workflow-crd.json new file mode 100644 index 00000000..ef26b415 --- /dev/null +++ b/charts/argo/templates/_workflow-crd.json @@ -0,0 +1,19 @@ +{{- define "workflow-crd-json" }} +{ + "apiVersion": "apiextensions.k8s.io/v1beta1", + "kind": "CustomResourceDefinition", + "metadata": { + "name": "workflows.argoproj.io" + }, + "spec": { + "group": "argoproj.io", + "names": { + "kind": "Workflow", + "plural": "workflows", + "shortNames": ["wf"] + }, + "scope": "Namespaced", + "version": "v1alpha1" + } +} +{{- end}} \ No newline at end of file diff --git a/charts/argo/templates/apply-workflow-crd-job.yaml b/charts/argo/templates/apply-workflow-crd-job.yaml new file mode 100644 index 00000000..313a05f2 --- /dev/null +++ b/charts/argo/templates/apply-workflow-crd-job.yaml @@ -0,0 +1,18 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ .Release.Name }}-apply-workflow-crd + annotations: + helm.sh/hook: pre-install + helm.sh/hook-delete-policy: hook-succeeded +spec: + backoffLimit: 5 + activeDeadlineSeconds: 100 + template: + spec: + containers: + - name: kubectl-apply + image: lachlanevenson/k8s-kubectl + command: ["/bin/sh"] + args: ["-c", 'echo ''{{- include "workflow-crd-json" .}}'' | kubectl apply -f -'] + restartPolicy: Never \ No newline at end of file diff --git a/charts/argo/templates/workflow-crd.yaml b/charts/argo/templates/workflow-crd.yaml deleted file mode 100644 index aaf95780..00000000 --- a/charts/argo/templates/workflow-crd.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: workflows.argoproj.io -spec: - group: argoproj.io - names: - kind: Workflow - plural: workflows - shortNames: - - wf - scope: Namespaced - version: v1alpha1 \ No newline at end of file