Skip to content

Commit

Permalink
feat: support camellia redis proxy (apecloud#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
Y-Rookie authored Mar 4, 2024
1 parent 2c78aa8 commit 4d191f8
Show file tree
Hide file tree
Showing 31 changed files with 879 additions and 0 deletions.
24 changes: 24 additions & 0 deletions addons/camellia-redis-proxy-cluster/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
*.lock
30 changes: 30 additions & 0 deletions addons/camellia-redis-proxy-cluster/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
annotations:
category: Database
apiVersion: v2
name: camellia-redis-proxy-cluster
type: application
version: 0.8.2
description: A Camellia Redis Proxy Cluster Helm chart for KubeBlocks.
dependencies:
- name: kblib
version: 0.1.0
repository: file://../kblib
alias: extra

appVersion: "1.2.26"

keywords:
- redis
- redis proxy
- database
- nosql

home: https://github.com/apecloud/kubeblocks/tree/main/deploy/camellia-redis-proxy-cluster
icon: https://kubeblocks.io/img/logo.png

maintainers:
- name: ApeCloud
url: https://kubeblocks.io/

sources:
- https://github.com/apecloud/kubeblocks/
2 changes: 2 additions & 0 deletions addons/camellia-redis-proxy-cluster/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1. Get the application URL by running these commands:

21 changes: 21 additions & 0 deletions addons/camellia-redis-proxy-cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{/*
Define common fileds of cluster object
*/}}
{{- define "camellia-redis-proxy.clusterCommon" }}
apiVersion: apps.kubeblocks.io/v1alpha1
kind: Cluster
metadata:
name: {{ include "kblib.clusterName" . }}
namespace: {{ .Release.Namespace }}
labels: {{ include "kblib.clusterLabels" . | nindent 4 }}
spec:
terminationPolicy: {{ .Values.extra.terminationPolicy }}
{{- include "kblib.affinity" . | indent 2 }}
{{- end }}

{{/*
Define replica count.
*/}}
{{- define "camellia-redis-proxy.replicaCount" }}
replicas: {{ .Values.replicas | default 2 }}
{{- end }}
14 changes: 14 additions & 0 deletions addons/camellia-redis-proxy-cluster/templates/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- include "camellia-redis-proxy.clusterCommon" . }}
clusterDefinitionRef: camellia-redis-proxy
clusterVersionRef: {{ .Values.version }}
componentSpecs:
- name: proxy
componentDef: camellia-redis-proxy
{{- include "kblib.componentMonitor" . | indent 6 }}
{{- include "camellia-redis-proxy.replicaCount" . | indent 6 }}
serviceAccountName: {{ include "kblib.serviceAccountName" . }}
switchPolicy:
type: Noop
{{- include "kblib.componentResources" . | indent 6 }}
{{- include "kblib.componentStorages" . | indent 6 }}
{{- include "kblib.componentServices" . | indent 6 }}
1 change: 1 addition & 0 deletions addons/camellia-redis-proxy-cluster/templates/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{- include "kblib.rbac" . }}
15 changes: 15 additions & 0 deletions addons/camellia-redis-proxy-cluster/templates/validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{/*
Validate cpu, memory and storage
*/}}
{{- $cpu := (float64 .Values.cpu) }}
{{- $memory := (float64 .Values.memory) }}
{{- $storage := (float64 .Values.storage) }}
{{- if or (lt $cpu 0.5) (gt $cpu 64.0) }}
{{- fail (print "cpu must be between 0.5 and 64, got " $cpu) }}
{{- end }}
{{- if or (lt $memory 0.5) (gt $memory 1000.0) }}
{{- fail (print "memory must be between 0.5 and 1000, got " $memory) }}
{{- end }}
{{- if or (lt $storage 1.0 ) (gt $storage 10000.0) }}
{{- fail (print "storage must be between 1 and 10000, got " $storage) }}
{{- end }}
54 changes: 54 additions & 0 deletions addons/camellia-redis-proxy-cluster/values.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"$schema": "http://json-schema.org/schema#",
"type": "object",
"properties": {
"version": {
"title": "Version",
"description": "Camellia Redis Proxy Cluster version.",
"type": "string",
"default": "camellia-redis-proxy-1.2.26"
},
"replicas": {
"title": "Replicas",
"description": "The number of replicas, default is 2.",
"type": "integer",
"default": 1,
"minimum": 1,
"maximum": 2048
},
"cpu": {
"title": "CPU",
"description": "CPU cores.",
"type": [
"number",
"string"
],
"default": 0.5,
"minimum": 0.5,
"maximum": 64,
"multipleOf": 0.5
},
"memory": {
"title": "Memory(Gi)",
"description": "Memory, the unit is Gi.",
"type": [
"number",
"string"
],
"default": 0.5,
"minimum": 0.5,
"maximum": 1000
},
"storage": {
"title": "Storage(Gi)",
"description": "Storage size, the unit is Gi.",
"type": [
"number",
"string"
],
"default": 20,
"minimum": 1,
"maximum": 10000
}
}
}
25 changes: 25 additions & 0 deletions addons/camellia-redis-proxy-cluster/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## @param version camellia redis proxy version
version: camellia-redis-proxy-1.2.26

## @param replicas specify replicas of camellia redis proxy
replicas: 2

## @param cpu
##
cpu: 0.5

## @param memory, the unit is Gi
##
memory: 1

## @param requests.cpu if not set, use cpu
## @param requests.memory, if not set, use memory
##
requests:
# cpu:
# memory:

## @param storage size, the unit is Gi
##
storage: 20

23 changes: 23 additions & 0 deletions addons/camellia-redis-proxy/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
25 changes: 25 additions & 0 deletions addons/camellia-redis-proxy/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v2
name: camellia-redis-proxy
description: "camellia-redis-proxy is a high-performance redis proxy developed using Netty4."

type: application

version: 0.8.2

appVersion: "1.2.26"

home: https://github.com/netease-im/camellia
keywords:
- redis
- redis proxy
- database
- nosql

maintainers:
- name: ApeCloud
url: https://github.com/apecloud/kubeblocks/deploy

annotations:
addon.kubeblocks.io/kubeblocks-version: ">=0.8.2"
addon.kubeblocks.io/model: "key-value"
addon.kubeblocks.io/provider: "apecloud"
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
## This is application.yml configuration file for camellia-redis-proxy

## Default dynamic configuration example for multi-tenant proxy configuration
## refer: https://github.com/netease-im/camellia/blob/master/docs/redis-proxy/other/multi-telant2.md
## you need to provide a properties file (default is camellia-redis-proxy.properties) for dynamic configuration.
server:
port: 6380
spring:
application:
name: camellia-redis-proxy-server

camellia-redis-proxy:
console-port: 16379
monitor-enable: false
monitor-interval-seconds: 60
plugins:
- monitorPlugin
- bigKeyPlugin
- hotKeyPlugin
client-auth-provider-class-name: com.netease.nim.camellia.redis.proxy.auth.MultiTenantClientAuthProvider
transpond:
type: custom
custom:
proxy-route-conf-updater-class-name: com.netease.nim.camellia.redis.proxy.route.MultiTenantProxyRouteConfUpdater
#
# the mapping camellia-redis-proxy.properties file content, that is an array where each item represents a route, supporting multiple sets of routes:
# multi.tenant.route.config=[{"name":"route1", "password": "passwd1", "route": "redis://[email protected]:16379"},{"name":"route2", "password": "passwd2", "route": "redis-cluster://@127.0.0.1:6380,127.0.0.1:6381,127.0.0.1:6382"},{"name":"route3", "password": "passwd3", "route": {"type": "simple","operation": {"read": "redis://[email protected]:6379","type": "rw_separate","write": "redis-sentinel://[email protected]:6379,127.0.0.1:6378/master"}}}]


## dynamic configuration for a single-tenant proxy with a local redis backend with json-file format
## refer: https://github.com/netease-im/camellia/blob/master/docs/redis-proxy/other/dynamic-conf.md
##
#server:
# port: 6380
#spring:
# application:
# name: camellia-redis-proxy-server
#
#camellia-redis-proxy:
# console-port: 16379 # console port, default 16379, if setting -16379, proxy will choose a random port, if setting 0, will disable console
# password: pass123 # password of proxy, priority less than custom client-auth-provider-class-name
# monitor-enable: false # monitor enable/disable configure
# monitor-interval-seconds: 60 # monitor data refresh interval seconds
# plugins: # plugin list
# - monitorPlugin
# - bigKeyPlugin
# - hotKeyPlugin
# proxy-dynamic-conf-loader-class-name: com.netease.nim.camellia.redis.proxy.conf.FileBasedProxyDynamicConfLoader
# config:
# "dynamic.conf.file.path": "camellia-redis-proxy.properties"
# transpond:
# type: local # local、remote、custom, local type does not support multi-tenant.
# local:
# type: complex # simple、complexze
# dynamic: true # dynamic load conf
# check-interval-millis: 3000 # dynamic conf check interval seconds
# json-file: "resource-table.json" # backend redis resources json file

## Another configuration for camellia-redis-proxy under a multi-tenant mode.
## refer: https://github.com/netease-im/camellia/blob/master/docs/redis-proxy/other/multi-telant.md
## you need to provide a properties file (default is camellia-redis-proxy.properties) for dynamic configuration.
#
# server:
# port: 6380
# spring:
# application:
# name: camellia-redis-proxy-server
#
# camellia-redis-proxy:
# console-port: 16379
# monitor-enable: false
# monitor-interval-seconds: 60
# plugins:
# - monitorPlugin
# - bigKeyPlugin
# - hotKeyPlugin
# client-auth-provider-class-name: com.netease.nim.camellia.redis.proxy.auth.DynamicConfClientAuthProvider
# transpond:
# type: custom
# custom:
# proxy-route-conf-updater-class-name: com.netease.nim.camellia.redis.proxy.route.DynamicConfProxyRouteConfUpdater
#
# the mapping camellia-redis-proxy.properties file content:
#
# ## provided for DynamicConfProxyRouteConfUpdater
# 1.default.route.conf=redis://@127.0.0.1:6379
# 2.default.route.conf=redis-cluster://@127.0.0.1:6380,127.0.0.1:6381,127.0.0.1:6382
# 3.default.route.conf={"type": "simple","operation": {"read": "redis://[email protected]:6379","type": "rw_separate","write": "redis-sentinel://[email protected]:6379,127.0.0.1:6378/master"}}
#
# ## provided for DynamicConfClientAuthProvider
# password123.auth.conf=1|default
# password456.auth.conf=2|default
# password789.auth.conf=3|default









Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## This is dynamic configuration file for camellia-redis-proxy backend redis resources with json format

## the supported backend redis resources can be referred here: https://github.com/netease-im/camellia/blob/master/docs/redis-proxy/auth/redis-resources.md
## and the example of backend resource configuration can be referred here: https://github.com/netease-im/camellia/blob/master/docs/redis-proxy/auth/complex.md

## for example:
## {
# "type": "simple",
# "operation": {
# "read": "redis://[email protected]:6379",
# "type": "rw_separate",
# "write": "redis-sentinel://[email protected]:6379,127.0.0.1:6378/master"
# }
# }

## config a redis backend resource, replace it with your own redis resource
redis://[email protected]:6379
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## This is dynamic configuration file for camellia redis proxy
## when camellia-redis-proxy.proxy-dynamic-conf-loader-class-name defined in application.yaml is com.netease.nim.camellia.redis.proxy.conf.FileBasedProxyDynamicConfLoader then this file will be loaded
## the default configuration file name is camellia-redis-proxy.properties

## Configuration for multi-tenant proxies

# ## provided for DynamicConfProxyRouteConfUpdater
# 1.default.route.conf=redis://@127.0.0.1:6379
# 2.default.route.conf=redis-cluster://@127.0.0.1:6380,127.0.0.1:6381,127.0.0.1:6382
# 3.default.route.conf={"type": "simple","operation": {"read": "redis://[email protected]:6379","type": "rw_separate","write": "redis-sentinel://[email protected]:6379,127.0.0.1:6378/master"}}
#
# ## provided for DynamicConfClientAuthProvider
# password123.auth.conf=1|default
# password456.auth.conf=2|default
# password789.auth.conf=3|default


## Another Configuration for multi-tenant proxies
# ## This is an array where each item represents a route, supporting multiple sets of routes.
# multi.tenant.route.config=[{"name":"route1", "password": "passwd1", "route": "redis://[email protected]:16379"},{"name":"route2", "password": "passwd2", "route": "redis-cluster://@127.0.0.1:6380,127.0.0.1:6381,127.0.0.1:6382"},{"name":"route3", "password": "passwd3", "route": {"type": "simple","operation": {"read": "redis://[email protected]:6379","type": "rw_separate","write": "redis-sentinel://[email protected]:6379,127.0.0.1:6378/master"}}}]
Loading

0 comments on commit 4d191f8

Please sign in to comment.