From f25b8ea969e62d7f4760c11ffaca6ae4612e3330 Mon Sep 17 00:00:00 2001 From: Rajagopalan Ranganathan Date: Tue, 18 Jun 2024 12:47:21 +0100 Subject: [PATCH] fix the kind local dev set up - Fix the kind set up - Add make target to teardown kind - fix the readme for updated paths and sameple request --- Makefile | 4 +++ deploy/deploy.sh | 13 +++++----- .../kind-kube/kind-ingress.config | 6 ++--- spicedb-kind-setup/setup.sh | 5 ++-- spicedb-kind-setup/teardown.sh | 25 +++++++++++++++++++ 5 files changed, 42 insertions(+), 11 deletions(-) create mode 100755 spicedb-kind-setup/teardown.sh diff --git a/Makefile b/Makefile index 46a84ce..87f69b0 100644 --- a/Makefile +++ b/Makefile @@ -105,6 +105,10 @@ kind/rebac: ./spicedb-kind-setup/setup.sh .PHONY: kind/spicedb +kind/teardown: + ./spicedb-kind-setup/teardown.sh +.PHONY: kind/teardown + .PHONY: run # run api locally run: build diff --git a/deploy/deploy.sh b/deploy/deploy.sh index c7e3e7a..8088c55 100755 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -128,13 +128,14 @@ if [[ "$RBAC_ARGUMENT" == "rbac" ]]; then echo "" echo "curl -v -u ${USER}:${PASSWORD} ${BASE_URL}/api/rbac/v1/status/" echo "" - echo "Relations - Read(GET) - Sample CURL request" - echo "" - echo "curl -v -u ${USER}:${PASSWORD} '${BASE_URL}/api/authz/v1/relationships?filter.objectType=group&filter.objectId=bob_club&filter.relation=member'" - echo "" + # Revisit after the HTTP streaming decision + # echo "Relations - Read(GET) - Sample CURL request" + # echo "" + # echo "curl -v -u ${USER}:${PASSWORD} '${BASE_URL}/api/authz/v1/relationships?filter.objectType=group&filter.objectId=bob_club&filter.relation=member'" + # echo "" fi echo "Relations - Write(POST) - Sample CURL request" echo "" -JSON_DATA='{"touch":true,"relationships":[{"object":{"type":"group","id":"bob_club"},"relation":"member","subject":{"object":{"type":"user","id":"bob"}}}]}' -echo "curl -v -u ${USER}:${PASSWORD} ${BASE_URL}/api/authz/v1/relationships -H 'Content-Type: application/json' -d '$JSON_DATA'" +JSON_DATA='{ "tuples": [{"resource": {"type": {"type": "group"},"id": "bob_club2"},"relation": "member","subject": {"subject": {"type": {"type": "user"},"id": "bob2"}}}]}' +echo "curl -v -u ${USER}:${PASSWORD} ${BASE_URL}/api/authz/v0/tuples -H 'Content-Type: application/json' -d '$JSON_DATA'" diff --git a/spicedb-kind-setup/kind-kube/kind-ingress.config b/spicedb-kind-setup/kind-kube/kind-ingress.config index 818dba0..7a496fb 100644 --- a/spicedb-kind-setup/kind-kube/kind-ingress.config +++ b/spicedb-kind-setup/kind-kube/kind-ingress.config @@ -1,6 +1,6 @@ kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 -name: sp-cluster +name: kessel-relations-cluster nodes: - role: control-plane kubeadmConfigPatches: @@ -11,8 +11,8 @@ nodes: node-labels: "ingress-ready=true" extraPortMappings: - containerPort: 80 - hostPort: 80 + hostPort: 8000 listenAddress: "0.0.0.0" - containerPort: 443 - hostPort: 443 + hostPort: 8443 listenAddress: "0.0.0.0" diff --git a/spicedb-kind-setup/setup.sh b/spicedb-kind-setup/setup.sh index af89d95..cca5da7 100755 --- a/spicedb-kind-setup/setup.sh +++ b/spicedb-kind-setup/setup.sh @@ -66,6 +66,7 @@ done echo "Route" kubectl get ingresses.networking.k8s.io -n spicedb -echo "Sample curl to relationships api" +echo "Relations - Write(POST) - Sample CURL request" echo "" -echo "curl http://relationships.127.0.0.1.nip.io/api/authz/v1/relationships -d '{ "touch": true, "relationships": [{"object": {"type": "group","id": "bob_club"},"relation": "member","subject": {"object": {"type": "user","id": "bob"}}}]}'" \ No newline at end of file +JSON_DATA='{ "tuples": [{"resource": {"type": {"type": "group"},"id": "bob_club2"},"relation": "member","subject": {"subject": {"type": {"type": "user"},"id": "bob2"}}}]}' +echo "curl -v http://relationships.127.0.0.1.nip.io:8000/api/authz/v0/tuples -H 'Content-Type: application/json' -d '$JSON_DATA'" diff --git a/spicedb-kind-setup/teardown.sh b/spicedb-kind-setup/teardown.sh new file mode 100755 index 0000000..42610cd --- /dev/null +++ b/spicedb-kind-setup/teardown.sh @@ -0,0 +1,25 @@ +#!/bin/bash +set -oe errexit + +if ! command -v kind &> /dev/null +then + echo "kind could not be found" + exit +fi + +if ! command -v helm &> /dev/null +then + echo "helm could not be found" + exit +fi + +if ! command -v kubectl &> /dev/null +then + echo "kubectl could not be found" + exit +fi + +# desired cluster name; default is "kind" +echo "Deleting kind cluster -- \"kessel-relations-cluster\"" + +kind delete cluster --name kessel-relations-cluster