From 454cc5296246da3f1bd251555a2e96ee7969aa41 Mon Sep 17 00:00:00 2001 From: Liviu Costea Date: Thu, 13 Jun 2019 04:06:34 +0300 Subject: [PATCH] Add example for jsonnet using functions with top level arguments (#30) --- README.md | 1 + jsonnet-guestbook-tla/guestbook-ui.jsonnet | 65 ++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 jsonnet-guestbook-tla/guestbook-ui.jsonnet diff --git a/README.md b/README.md index 10e14d8..eec819d 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ to explore ArgoCD and GitOps! | [ksonnet-guestbook](ksonnet-guestbook/) | The guestbook application as a ksonnet app | | [helm-guestbook](helm-guestbook/) | The guestbook application as a Helm chart | | [jsonnet-guestbook](jsonnet-guestbook/) | The guestbook application as a raw jsonnet | +| [jsonnet-guestbook-tla](jsonnet-guestbook-tla/) | The guestbook application as a raw jsonnet with support for top level arguments | | [kustomize-guestbook](kustomize-guestbook/) | The guestbook application as a Kustomize 2 app | | [pre-post-sync](pre-post-sync/) | Demonstrates Argo CD PreSync and PostSync hooks | | [sync-waves](sync-waves/) | Demonstrates Argo CD sync waves with hooks | diff --git a/jsonnet-guestbook-tla/guestbook-ui.jsonnet b/jsonnet-guestbook-tla/guestbook-ui.jsonnet new file mode 100644 index 0000000..5524600 --- /dev/null +++ b/jsonnet-guestbook-tla/guestbook-ui.jsonnet @@ -0,0 +1,65 @@ +function ( + containerPort=80, + image="gcr.io/heptio-images/ks-guestbook-demo:0.2", + name="jsonnet-guestbook-ui", + replicas=1, + servicePort=80, + type="LoadBalancer" +) + [ + { + "apiVersion": "v1", + "kind": "Service", + "metadata": { + "name": name + }, + "spec": { + "ports": [ + { + "port": servicePort, + "targetPort": containerPort + } + ], + "selector": { + "app": name + }, + "type": type + } + }, + { + "apiVersion": "apps/v1beta2", + "kind": "Deployment", + "metadata": { + "name": name + }, + "spec": { + "replicas": replicas, + "revisionHistoryLimit": 3, + "selector": { + "matchLabels": { + "app": name + }, + }, + "template": { + "metadata": { + "labels": { + "app": name + } + }, + "spec": { + "containers": [ + { + "image": image, + "name": name, + "ports": [ + { + "containerPort": containerPort + } + ] + } + ] + } + } + } + } + ] \ No newline at end of file