From 9c549b198c6d3044197941014d170320efe3195a Mon Sep 17 00:00:00 2001 From: Alexander Matyushentsev Date: Thu, 6 Sep 2018 15:17:36 -0700 Subject: [PATCH] Add jsonnet example --- README.md | 1 + jsonnet-guestbook/guestbook-ui.jsonnet | 58 ++++++++++++++++++++++++++ jsonnet-guestbook/params.libsonnet | 8 ++++ 3 files changed, 67 insertions(+) create mode 100644 jsonnet-guestbook/guestbook-ui.jsonnet create mode 100644 jsonnet-guestbook/params.libsonnet diff --git a/README.md b/README.md index 1c5d013..333ac4a 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ to explore ArgoCD and GitOps! |-------------|-------------| | [guestbook](guestbook/) | The ksonnet hello word application | | [helm-guestbook](helm-guestbook/) | The guestbook application as a Helm chart | +| [jsonnet-guestbook](jsonnet-guestbook/) | The guestbook application as a raw jsonnet | | [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/jsonnet-guestbook/guestbook-ui.jsonnet b/jsonnet-guestbook/guestbook-ui.jsonnet new file mode 100644 index 0000000..b1b377e --- /dev/null +++ b/jsonnet-guestbook/guestbook-ui.jsonnet @@ -0,0 +1,58 @@ +local params = import 'params.libsonnet'; + +[ + { + "apiVersion": "v1", + "kind": "Service", + "metadata": { + "name": params.name + }, + "spec": { + "ports": [ + { + "port": params.servicePort, + "targetPort": params.containerPort + } + ], + "selector": { + "app": params.name + }, + "type": params.type + } + }, + { + "apiVersion": "apps/v1beta2", + "kind": "Deployment", + "metadata": { + "name": params.name + }, + "spec": { + "replicas": params.replicas, + "selector": { + "matchLabels": { + "app": params.name + }, + }, + "template": { + "metadata": { + "labels": { + "app": params.name + } + }, + "spec": { + "containers": [ + { + "image": params.image, + "name": params.name, + "ports": [ + { + "containerPort": params.containerPort + } + ] + } + ] + } + } + } + } +] diff --git a/jsonnet-guestbook/params.libsonnet b/jsonnet-guestbook/params.libsonnet new file mode 100644 index 0000000..e51ab62 --- /dev/null +++ b/jsonnet-guestbook/params.libsonnet @@ -0,0 +1,8 @@ +{ + containerPort: 80, + image: "gcr.io/heptio-images/ks-guestbook-demo:0.2", + name: "guestbook-ui", + replicas: 1, + servicePort: 80, + type: "LoadBalancer", +}