summaryrefslogtreecommitdiffstats
path: root/nix/test-deployment.nix
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-10-03 13:13:07 +0200
committerMatthias Beyer <mail@beyermatthias.de>2021-10-03 19:00:47 +0200
commitace5563a8f8428483c050759274d0a32de9f67d9 (patch)
treeaec23eadacd1dacfaec667bab601d583956e9216 /nix/test-deployment.nix
parent13045eb086f5afbe2ed5a1b5daaa870005809ddd (diff)
Add first working setup for running kind cluster
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'nix/test-deployment.nix')
-rw-r--r--nix/test-deployment.nix40
1 files changed, 40 insertions, 0 deletions
diff --git a/nix/test-deployment.nix b/nix/test-deployment.nix
new file mode 100644
index 0000000..d10e5e6
--- /dev/null
+++ b/nix/test-deployment.nix
@@ -0,0 +1,40 @@
+{ kind, pkgs }:
+
+pkgs.writeScriptBin "test-deployment" ''
+ #! ${pkgs.runtimeShell}
+ set -euo pipefail
+
+ SERVICE_URL=http://localhost:8001/api/v1/namespaces/default/services/hello:3000/proxy/
+
+ KUBECONFIG=$(${kind}/bin/kind get kubeconfig-path --name="kind")
+ PROXY_PID=""
+ trap cleanup EXIT
+
+ function cleanup {
+ if ! [ -z $PROXY_PID ]; then
+ kill -9 $PROXY_PID
+ fi
+ }
+
+ CLUSTERS=$(${kind}/bin/kind get clusters)
+ if ! [ "$CLUSTERS" = "kind" ]; then
+ echo "Error: kind cluster not running"
+ exit 1
+ fi
+
+ echo "- Cluster seems to be up and running ✓"
+ ${pkgs.kubectl}/bin/kubectl proxy >/dev/null &
+
+ PROXY_PID=$!
+ sleep 3
+
+ RESPONSE=$(${pkgs.curl}/bin/curl --silent $SERVICE_URL)
+
+ if ! [ "$RESPONSE" == "Hello World" ]; then
+ echo "Error: did not get expected response from service:"
+ echo $RESPONSE
+ exit 1
+ fi
+ echo "- Service returns expected response ✓"
+''
+