From 94ad32f4ea26798997774ffc3e20fbfa8e0d8c21 Mon Sep 17 00:00:00 2001 From: Alex Collins Date: Fri, 11 Oct 2019 09:22:42 -0700 Subject: [PATCH] Tidy up the examples repo + add a Helm hooks examples (#40) --- apps/templates/helm-guestbook.yaml | 4 +- .../{guestbook.yaml => helm-hooks.yaml} | 8 +- apps/templates/kustomize-guestbook.yaml | 4 +- apps/templates/namespaces.yaml | 27 ++++++ .../{helm-dependency.yaml => sync-waves.yaml} | 8 +- apps/values.yaml | 1 + helm-hooks/manifests.yaml | 82 +++++++++++++++++++ sync-waves/manifests.yaml | 8 +- 8 files changed, 126 insertions(+), 16 deletions(-) rename apps/templates/{guestbook.yaml => helm-hooks.yaml} (74%) create mode 100644 apps/templates/namespaces.yaml rename apps/templates/{helm-dependency.yaml => sync-waves.yaml} (72%) create mode 100644 helm-hooks/manifests.yaml diff --git a/apps/templates/helm-guestbook.yaml b/apps/templates/helm-guestbook.yaml index 1044122..b351914 100644 --- a/apps/templates/helm-guestbook.yaml +++ b/apps/templates/helm-guestbook.yaml @@ -7,12 +7,12 @@ metadata: - resources-finalizer.argocd.argoproj.io spec: destination: - namespace: argocd + namespace: helm-guestbook server: {{ .Values.spec.destination.server }} project: default source: path: helm-guestbook - repoURL: https://github.com/argoproj/argocd-example-apps + repoURL: {{ .Values.spec.source.repoURL }} targetRevision: {{ .Values.spec.source.targetRevision }} syncPolicy: automated: diff --git a/apps/templates/guestbook.yaml b/apps/templates/helm-hooks.yaml similarity index 74% rename from apps/templates/guestbook.yaml rename to apps/templates/helm-hooks.yaml index 3f00024..2b70693 100644 --- a/apps/templates/guestbook.yaml +++ b/apps/templates/helm-hooks.yaml @@ -1,18 +1,18 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: - name: guestbook + name: helm-hooks namespace: argocd finalizers: - resources-finalizer.argocd.argoproj.io spec: destination: - namespace: argocd + namespace: helm-hooks server: {{ .Values.spec.destination.server }} project: default source: - path: guestbook - repoURL: https://github.com/argoproj/argocd-example-apps + path: helm-hooks + repoURL: {{ .Values.spec.source.repoURL }} targetRevision: {{ .Values.spec.source.targetRevision }} syncPolicy: automated: diff --git a/apps/templates/kustomize-guestbook.yaml b/apps/templates/kustomize-guestbook.yaml index f07e883..bf5ffd6 100644 --- a/apps/templates/kustomize-guestbook.yaml +++ b/apps/templates/kustomize-guestbook.yaml @@ -7,12 +7,12 @@ metadata: - resources-finalizer.argocd.argoproj.io spec: destination: - namespace: argocd + namespace: kustomize-guestbook server: {{ .Values.spec.destination.server }} project: default source: path: kustomize-guestbook - repoURL: https://github.com/argoproj/argocd-example-apps + repoURL: {{ .Values.spec.source.repoURL }} targetRevision: {{ .Values.spec.source.targetRevision }} syncPolicy: automated: diff --git a/apps/templates/namespaces.yaml b/apps/templates/namespaces.yaml new file mode 100644 index 0000000..435e4ba --- /dev/null +++ b/apps/templates/namespaces.yaml @@ -0,0 +1,27 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: helm-guestbook + annotations: + argocd.argoproj.io/sync-wave: "-1" +--- +apiVersion: v1 +kind: Namespace +metadata: + name: helm-hooks + annotations: + argocd.argoproj.io/sync-wave: "-1" +--- +apiVersion: v1 +kind: Namespace +metadata: + name: kustomize-guestbook + annotations: + argocd.argoproj.io/sync-wave: "-1" +--- +apiVersion: v1 +kind: Namespace +metadata: + name: sync-waves + annotations: + argocd.argoproj.io/sync-wave: "-1" diff --git a/apps/templates/helm-dependency.yaml b/apps/templates/sync-waves.yaml similarity index 72% rename from apps/templates/helm-dependency.yaml rename to apps/templates/sync-waves.yaml index f4528db..77be842 100644 --- a/apps/templates/helm-dependency.yaml +++ b/apps/templates/sync-waves.yaml @@ -1,18 +1,18 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: - name: helm-dependency + name: sync-waves namespace: argocd finalizers: - resources-finalizer.argocd.argoproj.io spec: destination: - namespace: argocd + namespace: sync-waves server: {{ .Values.spec.destination.server }} project: default source: - path: helm-dependency - repoURL: https://github.com/argoproj/argocd-example-apps + path: sync-waves + repoURL: {{ .Values.spec.source.repoURL }} targetRevision: {{ .Values.spec.source.targetRevision }} syncPolicy: automated: diff --git a/apps/values.yaml b/apps/values.yaml index 6f16640..cd66cc0 100644 --- a/apps/values.yaml +++ b/apps/values.yaml @@ -2,4 +2,5 @@ spec: destination: server: https://kubernetes.default.svc source: + repoURL: https://github.com/argoproj/argocd-example-apps targetRevision: HEAD \ No newline at end of file diff --git a/helm-hooks/manifests.yaml b/helm-hooks/manifests.yaml new file mode 100644 index 0000000..dcd852d --- /dev/null +++ b/helm-hooks/manifests.yaml @@ -0,0 +1,82 @@ +--- +apiVersion: batch/v1 +kind: Job +metadata: + generateName: upgrade-sql-schema + annotations: + helm.sh/hook: pre-install + helm.sh/hook-weight: "-2" +spec: + template: + spec: + containers: + - name: upgrade-sql-schema + image: alpine:latest + command: ["sleep", "5"] + restartPolicy: Never +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: maint-page-up + annotations: + helm.sh/hook: pre-install + helm.sh/hook-delete-policy: before-hook-creation + helm.sh/hook-weight: "-1" +spec: + template: + spec: + containers: + - name: page-up + image: alpine:latest + command: ["sleep", "2"] + restartPolicy: Never + backoffLimit: 0 +--- +apiVersion: apps/v1 +kind: ReplicaSet +metadata: + name: frontend +spec: + replicas: 1 + selector: + matchLabels: + tier: frontend + template: + metadata: + labels: + tier: frontend + spec: + containers: + - name: main + image: nginx:latest +--- +apiVersion: v1 +kind: Service +metadata: + name: frontend + annotations: + helm.sh/hook-weight: "2" +spec: + selector: + tier: frontend + ports: + - protocol: TCP + port: 80 + targetPort: 80 +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: maint-page-down + annotations: + helm.sh/hook: post-install + helm.sh/hook-delete-policy: before-hook-creation +spec: + template: + spec: + containers: + - name: page-down + image: alpine:latest + command: ["sleep", "2"] + restartPolicy: Never diff --git a/sync-waves/manifests.yaml b/sync-waves/manifests.yaml index 11fddf1..8f39133 100644 --- a/sync-waves/manifests.yaml +++ b/sync-waves/manifests.yaml @@ -47,10 +47,10 @@ spec: apiVersion: batch/v1 kind: Job metadata: - generateName: maint-page-up- + name: maint-page-up annotations: argocd.argoproj.io/hook: Sync - argocd.argoproj.io/hook-delete-policy: HookSucceeded + argocd.argoproj.io/hook-delete-policy: BeforeHookCreation argocd.argoproj.io/sync-wave: "1" spec: template: @@ -99,10 +99,10 @@ spec: apiVersion: batch/v1 kind: Job metadata: - generateName: maint-page-down- + name: maint-page-down annotations: argocd.argoproj.io/hook: Sync - argocd.argoproj.io/hook-delete-policy: HookSucceeded + argocd.argoproj.io/hook-delete-policy: BeforeHookCreation argocd.argoproj.io/sync-wave: "3" spec: template: