From ded6d179c13940ba4d7ce9f632340a1d78d6c97d Mon Sep 17 00:00:00 2001 From: William Petit Date: Thu, 15 Feb 2024 15:15:41 +0100 Subject: [PATCH] fix(k8s): redis configuration --- misc/k8s/README.md | 53 +++++++++++++++++++ misc/k8s/kind/bouncer-cluster.yaml | 3 ++ misc/k8s/kind/cluster/kustomization.yaml | 5 ++ .../resources/bouncer-admin/files/config.yml | 6 +-- .../bouncer-admin/kustomization.yaml | 7 +-- .../bouncer-admin/resources/deployment.yaml | 12 ++--- .../bouncer-admin/resources/service.yaml | 2 +- .../resources/bouncer-server/files/config.yml | 6 +-- .../bouncer-server/resources/deployment.yaml | 1 + .../bouncer-server/resources/service.yaml | 2 +- skaffold.yaml | 5 +- 11 files changed, 76 insertions(+), 26 deletions(-) create mode 100644 misc/k8s/README.md create mode 100644 misc/k8s/kind/bouncer-cluster.yaml create mode 100644 misc/k8s/kind/cluster/kustomization.yaml diff --git a/misc/k8s/README.md b/misc/k8s/README.md new file mode 100644 index 0000000..359e386 --- /dev/null +++ b/misc/k8s/README.md @@ -0,0 +1,53 @@ +# Kubernetes + +## Getting started with Kind + +1. Create your [Kind](https://kind.sigs.k8s.io/) cluster + + ```shell + kind create cluster --config misc/k8s/kind/bouncer-cluster.yaml + ``` + +2. Deploy required operators + + ```shell + kubectl apply -k misc/k8s/kind/cluster --server-side + ``` + +3. Deploy your Bouncer development environment + + ```shell + skaffold dev -p dev --cleanup=false --default-repo reg.cadoles.com/ + ``` + +## Testing + +1. Open shell in bouncer-admin pod + + ```shell + kubectl exec -it -n bouncer-dev bouncer-admin- -- /bin/sh + ``` + +2. Create an authentication token + + ```shell + bouncer auth create-token > .bouncer-token + ``` + +3. Create a proxy and enable it + + ```shell + bouncer admin proxy create --proxy-to https://www.cadoles.com --proxy-name cadoles + bouncer admin proxy update --proxy-name cadoles --proxy-enabled=true + ``` + +4. With you host web browser, open http://localhost:9000, you should see the Cadoles website. + +## Benchmarking + +You can use [`siege`](https://github.com/JoeDog/siege) to benchmark your instance with the Cadoles proxy. + +```shell +BASE_URL=http://localhost:9000 make siege +``` + diff --git a/misc/k8s/kind/bouncer-cluster.yaml b/misc/k8s/kind/bouncer-cluster.yaml new file mode 100644 index 0000000..6d991fd --- /dev/null +++ b/misc/k8s/kind/bouncer-cluster.yaml @@ -0,0 +1,3 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +name: bouncer-dev diff --git a/misc/k8s/kind/cluster/kustomization.yaml b/misc/k8s/kind/cluster/kustomization.yaml new file mode 100644 index 0000000..5f43460 --- /dev/null +++ b/misc/k8s/kind/cluster/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- https://forge.cadoles.com/CadolesKube/c-kustom//base/redis?ref=develop \ No newline at end of file diff --git a/misc/k8s/kustomization/base/resources/bouncer-admin/files/config.yml b/misc/k8s/kustomization/base/resources/bouncer-admin/files/config.yml index 25ceccf..c38d4a3 100644 --- a/misc/k8s/kustomization/base/resources/bouncer-admin/files/config.yml +++ b/misc/k8s/kustomization/base/resources/bouncer-admin/files/config.yml @@ -28,9 +28,9 @@ admin: redis: addresses: - - ${REDIS_SENTINEL_HOST}:${REDIS_SENTINEL_PORT} - master: "${REDIS_MASTER_NAME}" + - rfs-bouncer-redis:${RFS_BOUNCER_REDIS_SERVICE_PORT} + master: mymaster logger: - level: 3 + level: 2 format: human diff --git a/misc/k8s/kustomization/base/resources/bouncer-admin/kustomization.yaml b/misc/k8s/kustomization/base/resources/bouncer-admin/kustomization.yaml index edec116..ec6818d 100644 --- a/misc/k8s/kustomization/base/resources/bouncer-admin/kustomization.yaml +++ b/misc/k8s/kustomization/base/resources/bouncer-admin/kustomization.yaml @@ -9,9 +9,4 @@ configMapGenerator: - name: bouncer-admin-config files: - ./files/config.yml - - ./files/admin-key.json -- name: bouncer-admin-env - literals: - - REDIS_SENTINEL_HOST="rfs-$(REDIS_SERVICE_NAME)" - - REDIS_SENTINEL_PORT="26379" - - REDIS_MASTER_NAME="mymaster" + - ./files/admin-key.json \ No newline at end of file diff --git a/misc/k8s/kustomization/base/resources/bouncer-admin/resources/deployment.yaml b/misc/k8s/kustomization/base/resources/bouncer-admin/resources/deployment.yaml index 75b6dc0..21216da 100644 --- a/misc/k8s/kustomization/base/resources/bouncer-admin/resources/deployment.yaml +++ b/misc/k8s/kustomization/base/resources/bouncer-admin/resources/deployment.yaml @@ -19,15 +19,9 @@ spec: containers: - name: bouncer-admin image: reg.cadoles.com/cadoles/bouncer:v2024.2.5-1602626 - command: ["bouncer"] - args: ["--debug", "-c", "/etc/bouncer/config.yml", "server", "admin", "run"] + command: ["bouncer", "--debug", "-c", "/etc/bouncer/config.yml", "server", "admin", "run"] imagePullPolicy: Always - envFrom: - - configMapRef: - name: bouncer-admin-env - env: - - name: REDIS_SENTINEL_HOST - value: "rfs-$(REDIS_SERVICE_NAME)" + resources: {} ports: - name: bouncer-admin containerPort: 8081 @@ -37,4 +31,4 @@ spec: volumes: - name: bouncer-admin-config configMap: - name: bouncer-admin-config + name: bouncer-admin-config \ No newline at end of file diff --git a/misc/k8s/kustomization/base/resources/bouncer-admin/resources/service.yaml b/misc/k8s/kustomization/base/resources/bouncer-admin/resources/service.yaml index dd1aa9d..258ac42 100644 --- a/misc/k8s/kustomization/base/resources/bouncer-admin/resources/service.yaml +++ b/misc/k8s/kustomization/base/resources/bouncer-admin/resources/service.yaml @@ -9,6 +9,6 @@ spec: ports: - name: bouncer-admin port: 8081 - targetPort: 8080 + targetPort: bouncer-admin selector: io.kompose.service: bouncer-admin diff --git a/misc/k8s/kustomization/base/resources/bouncer-server/files/config.yml b/misc/k8s/kustomization/base/resources/bouncer-server/files/config.yml index ce55335..1a9de19 100644 --- a/misc/k8s/kustomization/base/resources/bouncer-server/files/config.yml +++ b/misc/k8s/kustomization/base/resources/bouncer-server/files/config.yml @@ -14,9 +14,9 @@ layers: redis: addresses: - - ${RFS_BOUNCER_REDIS_SERVICE_HOST}:${RFS_BOUNCER_REDIS_SERVICE_PORT} - master: "${REDIS_MASTER_NAME}" + - rfs-bouncer-redis:${RFS_BOUNCER_REDIS_SERVICE_PORT} + master: mymaster logger: - level: 3 + level: 2 format: human diff --git a/misc/k8s/kustomization/base/resources/bouncer-server/resources/deployment.yaml b/misc/k8s/kustomization/base/resources/bouncer-server/resources/deployment.yaml index 8cd3c99..a7c3abc 100644 --- a/misc/k8s/kustomization/base/resources/bouncer-server/resources/deployment.yaml +++ b/misc/k8s/kustomization/base/resources/bouncer-server/resources/deployment.yaml @@ -21,6 +21,7 @@ spec: image: reg.cadoles.com/cadoles/bouncer:v2024.2.5-1602626 command: ["bouncer", "-c", "/etc/bouncer/config.yml", "server", "proxy", "run"] imagePullPolicy: Always + resources: {} ports: - name: bouncer-server containerPort: 8080 diff --git a/misc/k8s/kustomization/base/resources/bouncer-server/resources/service.yaml b/misc/k8s/kustomization/base/resources/bouncer-server/resources/service.yaml index 691984f..16e1ab3 100644 --- a/misc/k8s/kustomization/base/resources/bouncer-server/resources/service.yaml +++ b/misc/k8s/kustomization/base/resources/bouncer-server/resources/service.yaml @@ -9,6 +9,6 @@ spec: ports: - name: bouncer-server port: 8080 - targetPort: 8080 + targetPort: bouncer-server selector: io.kompose.service: bouncer-server diff --git a/skaffold.yaml b/skaffold.yaml index 0d59a5a..69a6d47 100644 --- a/skaffold.yaml +++ b/skaffold.yaml @@ -33,8 +33,7 @@ build: - cmd/** - internal/** - layers/** - - tools/** - - data/** + - misc/** docker: dockerfile: Dockerfile @@ -42,7 +41,7 @@ deploy: statusCheckDeadlineSeconds: 600 portForward: -- resourceType: deployment +- resourceType: service resourceName: bouncer-admin namespace: bouncer-dev port: 8081