Compare commits
No commits in common. "2edd795ab8ceb339f0046f4f62b26e9fcf239df9" and "017e1e8a7c023f88c647a3887d98fd60328aa623" have entirely different histories.
2edd795ab8
...
017e1e8a7c
8
Makefile
8
Makefile
@ -16,9 +16,6 @@ GOTEST_ARGS ?= -short
|
|||||||
|
|
||||||
OPENWRT_DEVICE ?= 192.168.1.1
|
OPENWRT_DEVICE ?= 192.168.1.1
|
||||||
|
|
||||||
SIEGE_URLS_FILE ?= misc/siege/urls.txt
|
|
||||||
SIEGE_CONCURRENCY ?= 100
|
|
||||||
|
|
||||||
watch: tools/modd/bin/modd deps ## Watching updated files - live reload
|
watch: tools/modd/bin/modd deps ## Watching updated files - live reload
|
||||||
( set -o allexport && source .env && set +o allexport && tools/modd/bin/modd )
|
( set -o allexport && source .env && set +o allexport && tools/modd/bin/modd )
|
||||||
|
|
||||||
@ -108,10 +105,7 @@ grafterm: tools/grafterm/bin/grafterm
|
|||||||
tools/grafterm/bin/grafterm -c ./misc/grafterm/dashboard.json -v job=bouncer-proxy -r 5s
|
tools/grafterm/bin/grafterm -c ./misc/grafterm/dashboard.json -v job=bouncer-proxy -r 5s
|
||||||
|
|
||||||
siege:
|
siege:
|
||||||
$(eval TMP := $(shell mktemp))
|
siege -i -c 100 -f ./misc/siege/urls.txt
|
||||||
cat $(SIEGE_URLS_FILE) | envsubst > $(TMP)
|
|
||||||
siege -i -b -c $(SIEGE_CONCURRENCY) -f $(TMP)
|
|
||||||
rm -rf $(TMP)
|
|
||||||
|
|
||||||
tools/gitea-release/bin/gitea-release.sh:
|
tools/gitea-release/bin/gitea-release.sh:
|
||||||
mkdir -p tools/gitea-release/bin
|
mkdir -p tools/gitea-release/bin
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import "time"
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
RedisModeSimple = "simple"
|
RedisModeSimple = "simple"
|
||||||
RedisModeSentinel = "sentinel"
|
RedisModeSentinel = "sentinel"
|
||||||
@ -11,17 +9,11 @@ const (
|
|||||||
type RedisConfig struct {
|
type RedisConfig struct {
|
||||||
Adresses InterpolatedStringSlice `yaml:"addresses"`
|
Adresses InterpolatedStringSlice `yaml:"addresses"`
|
||||||
Master InterpolatedString `yaml:"master"`
|
Master InterpolatedString `yaml:"master"`
|
||||||
ReadTimeout InterpolatedDuration `yaml:"readTimeout"`
|
|
||||||
WriteTimeout InterpolatedDuration `yaml:"writeTimeout"`
|
|
||||||
DialTimeout InterpolatedDuration `yaml:"dialTimeout"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDefaultRedisConfig() RedisConfig {
|
func NewDefaultRedisConfig() RedisConfig {
|
||||||
return RedisConfig{
|
return RedisConfig{
|
||||||
Adresses: InterpolatedStringSlice{"localhost:6379"},
|
Adresses: InterpolatedStringSlice{"localhost:6379"},
|
||||||
Master: "",
|
Master: "",
|
||||||
ReadTimeout: InterpolatedDuration(30 * time.Second),
|
|
||||||
WriteTimeout: InterpolatedDuration(30 * time.Second),
|
|
||||||
DialTimeout: InterpolatedDuration(30 * time.Second),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcutil/base58"
|
"github.com/btcsuite/btcd/btcutil/base58"
|
||||||
@ -55,7 +56,7 @@ func PublicKeySet(keys ...jwk.Key) (jwk.Set, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func LoadOrGenerate(path string, size int) (jwk.Key, error) {
|
func LoadOrGenerate(path string, size int) (jwk.Key, error) {
|
||||||
data, err := os.ReadFile(path)
|
data, err := ioutil.ReadFile(path)
|
||||||
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||||
return nil, errors.WithStack(err)
|
return nil, errors.WithStack(err)
|
||||||
}
|
}
|
||||||
@ -71,7 +72,7 @@ func LoadOrGenerate(path string, size int) (jwk.Key, error) {
|
|||||||
return nil, errors.WithStack(err)
|
return nil, errors.WithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.WriteFile(path, data, 0o640); err != nil {
|
if err := ioutil.WriteFile(path, data, 0o640); err != nil {
|
||||||
return nil, errors.WithStack(err)
|
return nil, errors.WithStack(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func NewProxyRepository(ctx context.Context, conf config.RedisConfig) (store.ProxyRepository, error) {
|
func NewProxyRepository(ctx context.Context, conf config.RedisConfig) (store.ProxyRepository, error) {
|
||||||
rdb := newRedisClient(conf)
|
rdb := redis.NewUniversalClient(&redis.UniversalOptions{
|
||||||
|
Addrs: conf.Adresses,
|
||||||
|
MasterName: string(conf.Master),
|
||||||
|
})
|
||||||
|
|
||||||
return redisStore.NewProxyRepository(rdb), nil
|
return redisStore.NewProxyRepository(rdb), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"forge.cadoles.com/cadoles/bouncer/internal/proxy/director/layer/queue"
|
"forge.cadoles.com/cadoles/bouncer/internal/proxy/director/layer/queue"
|
||||||
queueRedis "forge.cadoles.com/cadoles/bouncer/internal/proxy/director/layer/queue/redis"
|
queueRedis "forge.cadoles.com/cadoles/bouncer/internal/proxy/director/layer/queue/redis"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/redis/go-redis/v9"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -35,6 +36,10 @@ func setupQueueLayer(conf *config.Config) (director.Layer, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newQueueAdapter(redisConf config.RedisConfig) (queue.Adapter, error) {
|
func newQueueAdapter(redisConf config.RedisConfig) (queue.Adapter, error) {
|
||||||
rdb := newRedisClient(redisConf)
|
rdb := redis.NewUniversalClient(&redis.UniversalOptions{
|
||||||
|
Addrs: redisConf.Adresses,
|
||||||
|
MasterName: string(redisConf.Master),
|
||||||
|
})
|
||||||
|
|
||||||
return queueRedis.NewAdapter(rdb, 2), nil
|
return queueRedis.NewAdapter(rdb, 2), nil
|
||||||
}
|
}
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
package setup
|
|
||||||
|
|
||||||
import (
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"forge.cadoles.com/cadoles/bouncer/internal/config"
|
|
||||||
"github.com/redis/go-redis/v9"
|
|
||||||
)
|
|
||||||
|
|
||||||
func newRedisClient(conf config.RedisConfig) redis.UniversalClient {
|
|
||||||
return redis.NewUniversalClient(&redis.UniversalOptions{
|
|
||||||
Addrs: conf.Adresses,
|
|
||||||
MasterName: string(conf.Master),
|
|
||||||
ReadTimeout: time.Duration(conf.ReadTimeout),
|
|
||||||
WriteTimeout: time.Duration(conf.WriteTimeout),
|
|
||||||
DialTimeout: time.Duration(conf.DialTimeout),
|
|
||||||
RouteByLatency: true,
|
|
||||||
ContextTimeoutEnabled: true,
|
|
||||||
})
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
# 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
|
|
||||||
```
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
kind: Cluster
|
|
||||||
apiVersion: kind.x-k8s.io/v1alpha4
|
|
||||||
name: bouncer-dev
|
|
@ -1,5 +0,0 @@
|
|||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
|
||||||
kind: Kustomization
|
|
||||||
|
|
||||||
resources:
|
|
||||||
- https://forge.cadoles.com/CadolesKube/c-kustom//base/redis?ref=develop
|
|
@ -28,9 +28,9 @@ admin:
|
|||||||
|
|
||||||
redis:
|
redis:
|
||||||
addresses:
|
addresses:
|
||||||
- rfs-bouncer-redis:${RFS_BOUNCER_REDIS_SERVICE_PORT}
|
- ${REDIS_SENTINEL_HOST}:${REDIS_SENTINEL_PORT}
|
||||||
master: mymaster
|
master: "${REDIS_MASTER_NAME}"
|
||||||
|
|
||||||
logger:
|
logger:
|
||||||
level: 2
|
level: 3
|
||||||
format: human
|
format: human
|
||||||
|
@ -10,3 +10,8 @@ configMapGenerator:
|
|||||||
files:
|
files:
|
||||||
- ./files/config.yml
|
- ./files/config.yml
|
||||||
- ./files/admin-key.json
|
- ./files/admin-key.json
|
||||||
|
- name: bouncer-admin-env
|
||||||
|
literals:
|
||||||
|
- REDIS_SENTINEL_HOST="rfs-$(REDIS_SERVICE_NAME)"
|
||||||
|
- REDIS_SENTINEL_PORT="26379"
|
||||||
|
- REDIS_MASTER_NAME="mymaster"
|
||||||
|
@ -19,9 +19,15 @@ spec:
|
|||||||
containers:
|
containers:
|
||||||
- name: bouncer-admin
|
- name: bouncer-admin
|
||||||
image: reg.cadoles.com/cadoles/bouncer:v2024.2.5-1602626
|
image: reg.cadoles.com/cadoles/bouncer:v2024.2.5-1602626
|
||||||
command: ["bouncer", "--debug", "-c", "/etc/bouncer/config.yml", "server", "admin", "run"]
|
command: ["bouncer"]
|
||||||
|
args: ["--debug", "-c", "/etc/bouncer/config.yml", "server", "admin", "run"]
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
resources: {}
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: bouncer-admin-env
|
||||||
|
env:
|
||||||
|
- name: REDIS_SENTINEL_HOST
|
||||||
|
value: "rfs-$(REDIS_SERVICE_NAME)"
|
||||||
ports:
|
ports:
|
||||||
- name: bouncer-admin
|
- name: bouncer-admin
|
||||||
containerPort: 8081
|
containerPort: 8081
|
||||||
|
@ -9,6 +9,6 @@ spec:
|
|||||||
ports:
|
ports:
|
||||||
- name: bouncer-admin
|
- name: bouncer-admin
|
||||||
port: 8081
|
port: 8081
|
||||||
targetPort: bouncer-admin
|
targetPort: 8080
|
||||||
selector:
|
selector:
|
||||||
io.kompose.service: bouncer-admin
|
io.kompose.service: bouncer-admin
|
||||||
|
@ -14,9 +14,9 @@ layers:
|
|||||||
|
|
||||||
redis:
|
redis:
|
||||||
addresses:
|
addresses:
|
||||||
- rfs-bouncer-redis:${RFS_BOUNCER_REDIS_SERVICE_PORT}
|
- ${RFS_BOUNCER_REDIS_SERVICE_HOST}:${RFS_BOUNCER_REDIS_SERVICE_PORT}
|
||||||
master: mymaster
|
master: "${REDIS_MASTER_NAME}"
|
||||||
|
|
||||||
logger:
|
logger:
|
||||||
level: 2
|
level: 3
|
||||||
format: human
|
format: human
|
||||||
|
@ -21,7 +21,6 @@ spec:
|
|||||||
image: reg.cadoles.com/cadoles/bouncer:v2024.2.5-1602626
|
image: reg.cadoles.com/cadoles/bouncer:v2024.2.5-1602626
|
||||||
command: ["bouncer", "-c", "/etc/bouncer/config.yml", "server", "proxy", "run"]
|
command: ["bouncer", "-c", "/etc/bouncer/config.yml", "server", "proxy", "run"]
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
resources: {}
|
|
||||||
ports:
|
ports:
|
||||||
- name: bouncer-server
|
- name: bouncer-server
|
||||||
containerPort: 8080
|
containerPort: 8080
|
||||||
|
@ -9,6 +9,6 @@ spec:
|
|||||||
ports:
|
ports:
|
||||||
- name: bouncer-server
|
- name: bouncer-server
|
||||||
port: 8080
|
port: 8080
|
||||||
targetPort: bouncer-server
|
targetPort: 8080
|
||||||
selector:
|
selector:
|
||||||
io.kompose.service: bouncer-server
|
io.kompose.service: bouncer-server
|
||||||
|
@ -147,9 +147,6 @@ redis:
|
|||||||
addresses:
|
addresses:
|
||||||
- localhost:6379
|
- localhost:6379
|
||||||
master: ""
|
master: ""
|
||||||
writeTimeout: 30s
|
|
||||||
readTimeout: 30s
|
|
||||||
dialTimeout: 30s
|
|
||||||
|
|
||||||
# Configuration des logs
|
# Configuration des logs
|
||||||
logger:
|
logger:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
${BASE_URL}/blog/
|
http://localhost:8080/blog/
|
||||||
${BASE_URL}/services/
|
http://localhost:8080/services/
|
||||||
${BASE_URL}
|
http://localhost:8080/
|
||||||
${BASE_URL}/recrutement/
|
http://localhost:8080/recrutement/
|
||||||
${BASE_URL}/faq/
|
http://localhost:8080/faq/
|
||||||
${BASE_URL}/societe/histoire/
|
http://localhost:8080/societe/histoire/
|
@ -33,7 +33,8 @@ build:
|
|||||||
- cmd/**
|
- cmd/**
|
||||||
- internal/**
|
- internal/**
|
||||||
- layers/**
|
- layers/**
|
||||||
- misc/**
|
- tools/**
|
||||||
|
- data/**
|
||||||
docker:
|
docker:
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ deploy:
|
|||||||
statusCheckDeadlineSeconds: 600
|
statusCheckDeadlineSeconds: 600
|
||||||
|
|
||||||
portForward:
|
portForward:
|
||||||
- resourceType: service
|
- resourceType: deployment
|
||||||
resourceName: bouncer-admin
|
resourceName: bouncer-admin
|
||||||
namespace: bouncer-dev
|
namespace: bouncer-dev
|
||||||
port: 8081
|
port: 8081
|
||||||
|
Loading…
x
Reference in New Issue
Block a user