fix(k8s): redis configuration

This commit is contained in:
wpetit 2024-02-15 15:15:41 +01:00
parent 017e1e8a7c
commit 6f61073d1f
11 changed files with 76 additions and 26 deletions

53
misc/k8s/README.md Normal file
View File

@ -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/<YOUR_PERSONNAL_USER_NAME>
```
## Testing
1. Open shell in bouncer-admin pod
```shell
kubectl exec -it -n bouncer-dev bouncer-admin-<suffix> -- /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
```

View File

@ -0,0 +1,3 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: bouncer-dev

View File

@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- https://forge.cadoles.com/CadolesKube/c-kustom//base/redis?ref=develop

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -9,6 +9,6 @@ spec:
ports:
- name: bouncer-admin
port: 8081
targetPort: 8080
targetPort: bouncer-admin
selector:
io.kompose.service: bouncer-admin

View File

@ -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

View File

@ -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

View File

@ -9,6 +9,6 @@ spec:
ports:
- name: bouncer-server
port: 8080
targetPort: 8080
targetPort: bouncer-server
selector:
io.kompose.service: bouncer-server

View File

@ -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