From 82b0cdf1f0e9f07f25f12aaafa1937481ec22084 Mon Sep 17 00:00:00 2001 From: Thomas Schuetz Date: Tue, 4 Oct 2022 15:22:42 +0200 Subject: [PATCH 1/6] doc: add dns function Signed-off-by: Thomas Schuetz --- functions-runtime/samples/ts/dns.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 functions-runtime/samples/ts/dns.ts diff --git a/functions-runtime/samples/ts/dns.ts b/functions-runtime/samples/ts/dns.ts new file mode 100644 index 0000000000..6f67341384 --- /dev/null +++ b/functions-runtime/samples/ts/dns.ts @@ -0,0 +1,11 @@ +let text = Deno.env.get("DATA"); +let data; +data = JSON.parse(text); + +try { + const a = await Deno.resolveDns(data.host, "A"); +} +catch (error){ + console.error("Could not resolve hostname") + Deno.exit(1) +} \ No newline at end of file From 8315c5ff7f158f441555448217577077834e1fc7 Mon Sep 17 00:00:00 2001 From: Thomas Schuetz Date: Tue, 4 Oct 2022 15:42:54 +0200 Subject: [PATCH 2/6] doc: added http check Signed-off-by: Thomas Schuetz --- examples/podtatohead-deployment/.gitignore | 1 + examples/podtatohead-deployment/check_entry.yaml | 12 ++++++++++++ .../podtatohead-deployment/pre-deployment-tasks.yaml | 10 ---------- functions-runtime/samples/ts/dns.ts | 11 ----------- functions-runtime/samples/ts/http.ts | 11 +++++++++++ 5 files changed, 24 insertions(+), 21 deletions(-) create mode 100644 examples/podtatohead-deployment/.gitignore create mode 100644 examples/podtatohead-deployment/check_entry.yaml delete mode 100644 examples/podtatohead-deployment/pre-deployment-tasks.yaml delete mode 100644 functions-runtime/samples/ts/dns.ts create mode 100644 functions-runtime/samples/ts/http.ts diff --git a/examples/podtatohead-deployment/.gitignore b/examples/podtatohead-deployment/.gitignore new file mode 100644 index 0000000000..2a082b43fe --- /dev/null +++ b/examples/podtatohead-deployment/.gitignore @@ -0,0 +1 @@ +/slack-secret.yaml diff --git a/examples/podtatohead-deployment/check_entry.yaml b/examples/podtatohead-deployment/check_entry.yaml new file mode 100644 index 0000000000..6c8b53fed4 --- /dev/null +++ b/examples/podtatohead-deployment/check_entry.yaml @@ -0,0 +1,12 @@ +apiVersion: lifecycle.keptn.sh/v1alpha1 +kind: KeptnTaskDefinition +metadata: + name: check-entry-service + namespace: podtato-kubectl +spec: + function: + httpRef: + url: https://raw.githubusercontent.com/keptn-sandbox/lifecycle-controller/doc/add_dns_function/functions-runtime/samples/ts/dns.ts + parameters: + map: + host: podtato-head-entry.podtato-kubectl.svc.cluster.local diff --git a/examples/podtatohead-deployment/pre-deployment-tasks.yaml b/examples/podtatohead-deployment/pre-deployment-tasks.yaml deleted file mode 100644 index 3d178eae9a..0000000000 --- a/examples/podtatohead-deployment/pre-deployment-tasks.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: lifecycle.keptn.sh/v1alpha1 -kind: KeptnTaskDefinition -metadata: - name: pre-deployment-hello - namespace: podtato-kubectl -spec: - function: - inline: - code: | - console.log("Pre-Deployment Task has been executed"); diff --git a/functions-runtime/samples/ts/dns.ts b/functions-runtime/samples/ts/dns.ts deleted file mode 100644 index 6f67341384..0000000000 --- a/functions-runtime/samples/ts/dns.ts +++ /dev/null @@ -1,11 +0,0 @@ -let text = Deno.env.get("DATA"); -let data; -data = JSON.parse(text); - -try { - const a = await Deno.resolveDns(data.host, "A"); -} -catch (error){ - console.error("Could not resolve hostname") - Deno.exit(1) -} \ No newline at end of file diff --git a/functions-runtime/samples/ts/http.ts b/functions-runtime/samples/ts/http.ts new file mode 100644 index 0000000000..271d19338c --- /dev/null +++ b/functions-runtime/samples/ts/http.ts @@ -0,0 +1,11 @@ +let text = Deno.env.get("DATA"); +let data; +data = JSON.parse(text); + +try { + let resp = await fetch(data.url); +} +catch (error){ + console.error("Could not fetch url"); + Deno.exit(1); +} \ No newline at end of file From e0ea41a714d01e6c0ae75717b2b7e31b77311f2a Mon Sep 17 00:00:00 2001 From: Thomas Schuetz Date: Tue, 4 Oct 2022 16:04:57 +0200 Subject: [PATCH 3/6] doc: describe generation of slack-secret Signed-off-by: Thomas Schuetz --- examples/podtatohead-deployment/README.md | 5 +++++ .../podtatohead-deployment/check_entry.yaml | 4 ++-- examples/podtatohead-deployment/manifest.yaml | 18 +++++++++++------- 3 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 examples/podtatohead-deployment/README.md diff --git a/examples/podtatohead-deployment/README.md b/examples/podtatohead-deployment/README.md new file mode 100644 index 0000000000..bb394b536a --- /dev/null +++ b/examples/podtatohead-deployment/README.md @@ -0,0 +1,5 @@ +### Create Secret for Slack here + +``` +kubectl create secret generic slack-notification --from-literal=SECURE_DATA='{"slack_hook":"","text":"Deployed PodTatoHead Entry Service"}' -n podtato-kubectl -oyaml --dry-run > secret.yaml +``` diff --git a/examples/podtatohead-deployment/check_entry.yaml b/examples/podtatohead-deployment/check_entry.yaml index 6c8b53fed4..3ab9da4e2c 100644 --- a/examples/podtatohead-deployment/check_entry.yaml +++ b/examples/podtatohead-deployment/check_entry.yaml @@ -6,7 +6,7 @@ metadata: spec: function: httpRef: - url: https://raw.githubusercontent.com/keptn-sandbox/lifecycle-controller/doc/add_dns_function/functions-runtime/samples/ts/dns.ts + url: https://raw.githubusercontent.com/keptn-sandbox/lifecycle-controller/doc/add_dns_function/functions-runtime/samples/ts/http.ts parameters: map: - host: podtato-head-entry.podtato-kubectl.svc.cluster.local + url: http://podtato-head-entry.podtato-kubectl.svc.cluster.local:9000 diff --git a/examples/podtatohead-deployment/manifest.yaml b/examples/podtatohead-deployment/manifest.yaml index 1fda3dde2d..ee4f29a56b 100644 --- a/examples/podtatohead-deployment/manifest.yaml +++ b/examples/podtatohead-deployment/manifest.yaml @@ -23,9 +23,13 @@ spec: keptn.sh/app: podtato-head keptn.sh/workload: podtato-head-entry keptn.sh/version: 0.1.0 - keptn.sh/pre-deployment-tasks: pre-deployment-hello + keptn.sh/post-deployment-tasks: post-deployment-hello spec: terminationGracePeriodSeconds: 5 + initContainers: + - name: init-myservice + image: busybox:1.28 + command: ['sh', '-c', 'sleep 30'] containers: - name: server image: ghcr.io/podtato-head/entry:latest @@ -74,7 +78,7 @@ spec: keptn.sh/app: podtato-head keptn.sh/workload: podtato-head-hat keptn.sh/version: 0.1.0 - keptn.sh/pre-deployment-tasks: pre-deployment-hello + keptn.sh/pre-deployment-tasks: check-entry-service spec: terminationGracePeriodSeconds: 5 containers: @@ -123,7 +127,7 @@ spec: keptn.sh/app: podtato-head keptn.sh/workload: podtato-head-left-leg keptn.sh/version: 0.1.0 - keptn.sh/pre-deployment-tasks: pre-deployment-hello + keptn.sh/pre-deployment-tasks: check-entry-service spec: terminationGracePeriodSeconds: 5 containers: @@ -171,8 +175,8 @@ spec: annotations: keptn.sh/app: podtato-head keptn.sh/workload: podtato-head-left-arm - keptn.sh/version: 0.1.0 - keptn.sh/pre-deployment-tasks: pre-deployment-hello + keptn.sh/version: 0.1.1 + keptn.sh/pre-deployment-tasks: check-entry-service spec: terminationGracePeriodSeconds: 5 containers: @@ -221,7 +225,7 @@ spec: keptn.sh/app: podtato-head keptn.sh/workload: podtato-head-right-leg keptn.sh/version: 0.1.0 - keptn.sh/pre-deployment-tasks: pre-deployment-hello + keptn.sh/pre-deployment-tasks: check-entry-service spec: terminationGracePeriodSeconds: 5 containers: @@ -270,7 +274,7 @@ spec: keptn.sh/app: podtato-head keptn.sh/workload: podtato-head-right-arm keptn.sh/version: 0.1.0 - keptn.sh/pre-deployment-tasks: pre-deployment-hello + keptn.sh/pre-deployment-tasks: check-entry-service spec: terminationGracePeriodSeconds: 5 containers: From ab094dbfb7ea36cf9757d3fbf47c756c4dceb98d Mon Sep 17 00:00:00 2001 From: Thomas Schuetz Date: Tue, 4 Oct 2022 16:14:00 +0200 Subject: [PATCH 4/6] doc: fixed secret Signed-off-by: Thomas Schuetz --- examples/podtatohead-deployment/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/podtatohead-deployment/README.md b/examples/podtatohead-deployment/README.md index bb394b536a..6b709a817a 100644 --- a/examples/podtatohead-deployment/README.md +++ b/examples/podtatohead-deployment/README.md @@ -1,5 +1,5 @@ ### Create Secret for Slack here ``` -kubectl create secret generic slack-notification --from-literal=SECURE_DATA='{"slack_hook":"","text":"Deployed PodTatoHead Entry Service"}' -n podtato-kubectl -oyaml --dry-run > secret.yaml +kubectl create secret generic slack-notification --from-literal=SECURE_DATA='{"slack_hook":"","text":"Deployed PodTatoHead Entry Service"}' -n podtato-kubectl -oyaml --dry-run > slack-secret.yaml ``` From d97bcc33f6e0d3e40c3180dd594c089d27f2a078 Mon Sep 17 00:00:00 2001 From: Thomas Schuetz Date: Tue, 4 Oct 2022 16:21:03 +0200 Subject: [PATCH 5/6] doc: fixed secret Signed-off-by: Thomas Schuetz --- examples/podtatohead-deployment/manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/podtatohead-deployment/manifest.yaml b/examples/podtatohead-deployment/manifest.yaml index ee4f29a56b..75a9f70a95 100644 --- a/examples/podtatohead-deployment/manifest.yaml +++ b/examples/podtatohead-deployment/manifest.yaml @@ -175,7 +175,7 @@ spec: annotations: keptn.sh/app: podtato-head keptn.sh/workload: podtato-head-left-arm - keptn.sh/version: 0.1.1 + keptn.sh/version: 0.1.0 keptn.sh/pre-deployment-tasks: check-entry-service spec: terminationGracePeriodSeconds: 5 From 8aca318795eb754879d514c8adfa8fd680f4524f Mon Sep 17 00:00:00 2001 From: Thomas Schuetz Date: Tue, 4 Oct 2022 16:27:45 +0200 Subject: [PATCH 6/6] doc: fixed branch Signed-off-by: Thomas Schuetz --- examples/podtatohead-deployment/check_entry.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/podtatohead-deployment/check_entry.yaml b/examples/podtatohead-deployment/check_entry.yaml index 3ab9da4e2c..958540ec07 100644 --- a/examples/podtatohead-deployment/check_entry.yaml +++ b/examples/podtatohead-deployment/check_entry.yaml @@ -6,7 +6,7 @@ metadata: spec: function: httpRef: - url: https://raw.githubusercontent.com/keptn-sandbox/lifecycle-controller/doc/add_dns_function/functions-runtime/samples/ts/http.ts + url: https://raw.githubusercontent.com/keptn-sandbox/lifecycle-controller/main/functions-runtime/samples/ts/http.ts parameters: map: url: http://podtato-head-entry.podtato-kubectl.svc.cluster.local:9000