From 23eeb0925ba967b73182c65802f7e19a7f3a5696 Mon Sep 17 00:00:00 2001 From: Alexander Matyushentsev Date: Mon, 25 Feb 2019 14:19:08 -0800 Subject: [PATCH] Add config template plugin examples (#7) --- README.md | 1 + guestbook/guestbook-ui-svc.yaml | 18 +++++------ plugins/README.md | 6 ++++ plugins/kasane/.gitignore | 2 ++ plugins/kasane/Kasanefile | 5 ++++ plugins/kasane/README.md | 29 ++++++++++++++++++ plugins/kasane/patch.jsonnet | 9 ++++++ plugins/kustomized-helm/.gitignore | 3 ++ plugins/kustomized-helm/Chart.yaml | 1 + plugins/kustomized-helm/README.md | 30 +++++++++++++++++++ plugins/kustomized-helm/kustomization.yaml | 7 +++++ .../overlays/guestbook-deployment.yaml | 10 +++++++ plugins/kustomized-helm/requirements.yaml | 4 +++ 13 files changed, 116 insertions(+), 9 deletions(-) create mode 100644 plugins/README.md create mode 100644 plugins/kasane/.gitignore create mode 100644 plugins/kasane/Kasanefile create mode 100644 plugins/kasane/README.md create mode 100644 plugins/kasane/patch.jsonnet create mode 100644 plugins/kustomized-helm/.gitignore create mode 100644 plugins/kustomized-helm/Chart.yaml create mode 100644 plugins/kustomized-helm/README.md create mode 100644 plugins/kustomized-helm/kustomization.yaml create mode 100644 plugins/kustomized-helm/overlays/guestbook-deployment.yaml create mode 100644 plugins/kustomized-helm/requirements.yaml diff --git a/README.md b/README.md index e16c7f5..e5b96db 100644 --- a/README.md +++ b/README.md @@ -16,3 +16,4 @@ to explore ArgoCD and GitOps! | [helm-dependency](helm-dependency/) | Demonstrates how to customize an OTS (off-the-shelf) helm chart from an upstream repo | | [blue-green-deploy](blue-green-deploy/) | Demonstrates an Argo CD Sync hook which performs a blue/green deployment | | [sock-shop](sock-shop/) | A microservices demo application (https://microservices-demo.github.io) | +| [plugins](plugins/) | Applications which demonstrate config management plugins usage | diff --git a/guestbook/guestbook-ui-svc.yaml b/guestbook/guestbook-ui-svc.yaml index e619b5c..e8a4a27 100644 --- a/guestbook/guestbook-ui-svc.yaml +++ b/guestbook/guestbook-ui-svc.yaml @@ -1,10 +1,10 @@ -apiVersion: v1 -kind: Service -metadata: - name: guestbook-ui -spec: - ports: - - port: 80 - targetPort: 80 - selector: +apiVersion: v1 +kind: Service +metadata: + name: guestbook-ui +spec: + ports: + - port: 80 + targetPort: 80 + selector: app: guestbook-ui diff --git a/plugins/README.md b/plugins/README.md new file mode 100644 index 0000000..ea8645b --- /dev/null +++ b/plugins/README.md @@ -0,0 +1,6 @@ +# Config Management Plugins Examples + +| Application | Description | +|-------------|-------------| +| [kasane](kasane/) | The guestbook application as a `kasane` package. | +| [kustomized-helm](kustomized-helm/) | Application comprised of a `helm` chart and customized using `kustomize` | diff --git a/plugins/kasane/.gitignore b/plugins/kasane/.gitignore new file mode 100644 index 0000000..db3a6fe --- /dev/null +++ b/plugins/kasane/.gitignore @@ -0,0 +1,2 @@ +vendor +Kasanefile.lock diff --git a/plugins/kasane/Kasanefile b/plugins/kasane/Kasanefile new file mode 100644 index 0000000..173412e --- /dev/null +++ b/plugins/kasane/Kasanefile @@ -0,0 +1,5 @@ +layers: +- ../../guestbook/guestbook-ui-deployment.yaml +- patch.jsonnet +- ../../guestbook/guestbook-ui-svc.yaml + diff --git a/plugins/kasane/README.md b/plugins/kasane/README.md new file mode 100644 index 0000000..36e5f9d --- /dev/null +++ b/plugins/kasane/README.md @@ -0,0 +1,29 @@ +# Kasane + +[Kasane](https://github.com/google/kasane) is a layering tool for Kubernetes which utilises Jsonnet for deep object modification and patching. + +Use following steps to try the application: + +* Follow instructions from [custom_tools.md](https://github.com/argoproj/argo-cd/blob/master/docs/custom_tools.md) to make sure `kasane` binary is available in `argocd-repo-server` pod. +* Register `kasane` plugin `argocd-cm` ConfigMap: + +```yaml +apiVersion: v1 +data: + configManagementPlugins: | + - name: kasane + init: + command: [kasane, update] + generate: + command: [kasane, show] +``` +* Create application using `kasane` as a config management plugin name. + +``` +argocd app create kasane \ + --config-management-plugin kasane \ + --repo https://github.com/argoproj/argocd-example-apps \ + --path plugins/kasane \ + --dest-server https://kubernetes.default.svc \ + --dest-namespace default +``` diff --git a/plugins/kasane/patch.jsonnet b/plugins/kasane/patch.jsonnet new file mode 100644 index 0000000..f5190fb --- /dev/null +++ b/plugins/kasane/patch.jsonnet @@ -0,0 +1,9 @@ +function (layers) + +[ + layers[0] { + spec+: { + replicas: 2, + }, + } +] diff --git a/plugins/kustomized-helm/.gitignore b/plugins/kustomized-helm/.gitignore new file mode 100644 index 0000000..2582de3 --- /dev/null +++ b/plugins/kustomized-helm/.gitignore @@ -0,0 +1,3 @@ +all.yaml +charts +requirements.lock diff --git a/plugins/kustomized-helm/Chart.yaml b/plugins/kustomized-helm/Chart.yaml new file mode 100644 index 0000000..bb298f2 --- /dev/null +++ b/plugins/kustomized-helm/Chart.yaml @@ -0,0 +1 @@ +name: guestbook diff --git a/plugins/kustomized-helm/README.md b/plugins/kustomized-helm/README.md new file mode 100644 index 0000000..dbfe9a9 --- /dev/null +++ b/plugins/kustomized-helm/README.md @@ -0,0 +1,30 @@ +# Helm + Kustomize + +Sometimes Helm chart don't have all required parameters and additional customization is required. This example application demonstrates how to combine Helm and Kustomize and use it +as a config management plugin in Argo CD. + +Use following steps to try the application: + +* configure `kustomized-helm` tool in `argocd-cm` ConfigMap: + +```yaml + configManagementPlugins: | + - name: kustomized-helm + init: + command: [helm, dependency, build] + generate: + command: [sh, -c] + args: ["helm template . > all.yaml && kustomize build"] +``` + +* create application using `kustomized-helm` as a config management plugin name: + + +``` +argocd app create kustomized-helm \ + --config-management-plugin kustomized-helm \ + --repo https://github.com/argoproj/argocd-example-apps \ + --path plugins/kustomized-helm \ + --dest-server https://kubernetes.default.svc \ + --dest-namespace default +``` diff --git a/plugins/kustomized-helm/kustomization.yaml b/plugins/kustomized-helm/kustomization.yaml new file mode 100644 index 0000000..23018b7 --- /dev/null +++ b/plugins/kustomized-helm/kustomization.yaml @@ -0,0 +1,7 @@ +namePrefix: kustomize- + +resources: +- ./all.yaml + +patches: +- overlays/guestbook-deployment.yaml diff --git a/plugins/kustomized-helm/overlays/guestbook-deployment.yaml b/plugins/kustomized-helm/overlays/guestbook-deployment.yaml new file mode 100644 index 0000000..08c62e9 --- /dev/null +++ b/plugins/kustomized-helm/overlays/guestbook-deployment.yaml @@ -0,0 +1,10 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: release-name-helm-guestbook +spec: + template: + spec: + containers: + - name: helm-guestbook + image: "gcr.io/heptio-images/ks-guestbook-demo:0.2" diff --git a/plugins/kustomized-helm/requirements.yaml b/plugins/kustomized-helm/requirements.yaml new file mode 100644 index 0000000..c199804 --- /dev/null +++ b/plugins/kustomized-helm/requirements.yaml @@ -0,0 +1,4 @@ +dependencies: +- name: helm-guestbook + version: 0.1.0 + repository: file://../../helm-guestbook