diff --git a/README.md b/README.md index afeb97c..8de3029 100644 --- a/README.md +++ b/README.md @@ -1 +1,12 @@ # ArgoCD Example Apps + +This repository contains example ksonnet applications for demoing ArgoCD functionality. Feel free +to register this repository to your ArgoCD instance, or fork this repo and push your own commits +to explore ArgoCD and GitOps! + +| Application | Description | +|-------------|-------------| +| [guestbook](guestbook/) | The ksonnet hello word application | +| [pre-post-sync](pre-post-sync/) | Demonstrates ArgoCD PreSync and PostSync hooks | +| [blue-green-deploy](blue-green-deploy/) | Demonstrates an ArgoCD Sync hook which performs a blue/green deployment | +| [sock-shop](sock-shop/) | A microservices demo application (https://microservices-demo.github.io) | diff --git a/guestbook/app.yaml b/guestbook/app.yaml index 4caf70f..6fc0b6a 100644 --- a/guestbook/app.yaml +++ b/guestbook/app.yaml @@ -6,6 +6,18 @@ environments: server: https://kubernetes.default.svc k8sVersion: v1.10.0 path: default + dev: + destination: + namespace: dev + server: https://kubernetes.default.svc + k8sVersion: v1.10.0 + path: dev + prod: + destination: + namespace: prod + server: https://kubernetes.default.svc + k8sVersion: v1.10.0 + path: prod kind: ksonnet.io/app name: guestbook version: 0.0.1 diff --git a/guestbook/environments/dev/globals.libsonnet b/guestbook/environments/dev/globals.libsonnet new file mode 100644 index 0000000..7a73a41 --- /dev/null +++ b/guestbook/environments/dev/globals.libsonnet @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/guestbook/environments/dev/main.jsonnet b/guestbook/environments/dev/main.jsonnet new file mode 100644 index 0000000..58695a8 --- /dev/null +++ b/guestbook/environments/dev/main.jsonnet @@ -0,0 +1,8 @@ +local base = import "base.libsonnet"; +// uncomment if you reference ksonnet-lib +// local k = import "k.libsonnet"; + +base + { + // Insert user-specified overrides here. For example if a component is named \"nginx-deployment\", you might have something like:\n") + // "nginx-deployment"+: k.deployment.mixin.metadata.labels({foo: "bar"}) +} diff --git a/guestbook/environments/dev/params.libsonnet b/guestbook/environments/dev/params.libsonnet new file mode 100644 index 0000000..b6eb32d --- /dev/null +++ b/guestbook/environments/dev/params.libsonnet @@ -0,0 +1,17 @@ +local params = std.extVar("__ksonnet/params"); +local globals = import "globals.libsonnet"; +local envParams = params + { + components +: { + // Insert component parameter overrides here. Ex: + // guestbook +: { + // name: "guestbook-dev", + // replicas: params.global.replicas, + // }, + }, +}; + +{ + components: { + [x]: envParams.components[x] + globals, for x in std.objectFields(envParams.components) + }, +} diff --git a/guestbook/environments/prod/globals.libsonnet b/guestbook/environments/prod/globals.libsonnet new file mode 100644 index 0000000..7a73a41 --- /dev/null +++ b/guestbook/environments/prod/globals.libsonnet @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/guestbook/environments/prod/main.jsonnet b/guestbook/environments/prod/main.jsonnet new file mode 100644 index 0000000..58695a8 --- /dev/null +++ b/guestbook/environments/prod/main.jsonnet @@ -0,0 +1,8 @@ +local base = import "base.libsonnet"; +// uncomment if you reference ksonnet-lib +// local k = import "k.libsonnet"; + +base + { + // Insert user-specified overrides here. For example if a component is named \"nginx-deployment\", you might have something like:\n") + // "nginx-deployment"+: k.deployment.mixin.metadata.labels({foo: "bar"}) +} diff --git a/guestbook/environments/prod/params.libsonnet b/guestbook/environments/prod/params.libsonnet new file mode 100644 index 0000000..b6eb32d --- /dev/null +++ b/guestbook/environments/prod/params.libsonnet @@ -0,0 +1,17 @@ +local params = std.extVar("__ksonnet/params"); +local globals = import "globals.libsonnet"; +local envParams = params + { + components +: { + // Insert component parameter overrides here. Ex: + // guestbook +: { + // name: "guestbook-dev", + // replicas: params.global.replicas, + // }, + }, +}; + +{ + components: { + [x]: envParams.components[x] + globals, for x in std.objectFields(envParams.components) + }, +} diff --git a/pre-post-sync/components/post-sync-job.yaml b/pre-post-sync/components/post-sync-job.yaml index 477e845..f60542c 100644 --- a/pre-post-sync/components/post-sync-job.yaml +++ b/pre-post-sync/components/post-sync-job.yaml @@ -4,12 +4,13 @@ metadata: generateName: after- annotations: argocd.argoproj.io/hook: PostSync + argocd.argoproj.io/hook-delete-policy: OnSuccess spec: template: spec: containers: - name: sleep image: alpine:latest - command: ["sleep", "30"] + command: ["sleep", "20"] restartPolicy: Never - backoffLimit: 4 + backoffLimit: 0 diff --git a/pre-post-sync/components/pre-sync-job.yaml b/pre-post-sync/components/pre-sync-job.yaml index 33673ce..c92bbe8 100644 --- a/pre-post-sync/components/pre-sync-job.yaml +++ b/pre-post-sync/components/pre-sync-job.yaml @@ -4,12 +4,13 @@ metadata: generateName: before- annotations: argocd.argoproj.io/hook: PreSync + argocd.argoproj.io/hook-delete-policy: OnSuccess spec: template: spec: containers: - name: sleep image: alpine:latest - command: ["sleep", "30"] + command: ["sleep", "20"] restartPolicy: Never - backoffLimit: 4 + backoffLimit: 0