Skip to content

Commit f34d70e

Browse files
authored
Merge pull request #3 from angel9484/feature/make_configurable_port_and_gossip_in_redis
Feature/make configurable port and gossip in redis
2 parents b515195 + 5c0899c commit f34d70e

22 files changed

+724
-17
lines changed

.github/workflows/release-chart.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Release Charts
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- 'charts/**'
9+
10+
jobs:
11+
release:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v1
16+
- name: Configure Git
17+
run: |
18+
git config user.name "$GITHUB_ACTOR"
19+
git config user.email "[email protected]"
20+
- name: Run chart-releaser
21+
uses: helm/chart-releaser-action@master
22+
env:
23+
CR_TOKEN: '${{ secrets.CR_TOKEN }}'

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ Table of Contents
2020

2121
* [redis-cluster-operator](#redis-cluster-operator)
2222
* [Overview](#overview)
23+
* [Table of Contents](#table-of-contents)
2324
* [Prerequisites](#prerequisites)
2425
* [Features](#features)
2526
* [Quick Start](#quick-start)
2627
* [Deploy redis cluster operator](#deploy-redis-cluster-operator)
28+
* [Install Step by step](#install-step-by-step)
29+
* [Install using helm chart](#install-using-helm-chart)
30+
* [Usage](#usage)
2731
* [Deploy a sample Redis Cluster](#deploy-a-sample-redis-cluster)
2832
* [Scaling Up the Redis Cluster](#scaling-up-the-redis-cluster)
2933
* [Scaling Down the Redis Cluster](#scaling-down-the-redis-cluster)
@@ -62,6 +66,8 @@ Table of Contents
6266

6367
### Deploy redis cluster operator
6468

69+
#### Install Step by step
70+
6571
Register the DistributedRedisCluster and RedisClusterBackup custom resource definition (CRD).
6672
```
6773
$ kubectl create -f deploy/crds/redis.kun_distributedredisclusters_crd.yaml
@@ -84,15 +90,31 @@ $ kubectl create -f deploy/namespace/role_binding.yaml
8490
$ kubectl create -f deploy/namespace/operator.yaml
8591
```
8692

93+
#### Install using helm chart
94+
95+
Add Helm repository
96+
```
97+
helm repo add ucloud-operator https://ucloud.github.io/redis-cluster-operator/
98+
helm repo update
99+
```
100+
101+
Install chart
102+
```
103+
helm install --generate-name ucloud-operator/redis-cluster-operator
104+
```
105+
87106
Verify that the redis-cluster-operator is up and running:
88107
```
89108
$ kubectl get deployment
90109
NAME READY UP-TO-DATE AVAILABLE AGE
91110
redis-cluster-operator 1/1 1 1 1d
92111
```
93112

113+
### Usage
94114
#### Deploy a sample Redis Cluster
95115

116+
NOTE: **Only the redis cluster that use persistent storage(pvc) can recover after accidental deletion or rolling update.Even if you do not use persistence(like rdb or aof), you need to set pvc for redis.**
117+
96118
```
97119
$ kubectl apply -f deploy/example/redis.kun_v1alpha1_distributedrediscluster_cr.yaml
98120
```
@@ -168,7 +190,7 @@ spec:
168190

169191
#### Backup and Restore
170192

171-
**Only Ceph object storage is supported now**
193+
NOTE: **Only Ceph S3 object storage and PVC is supported now**
172194

173195
Backup
174196
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v2
2+
name: redis-cluster-operator
3+
description: A Helm chart for Redis cluster operator deployment
4+
5+
type: application
6+
7+
version: 0.1.0
8+
9+
appVersion: 0.1.0
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
apiVersion: apiextensions.k8s.io/v1beta1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: distributedredisclusters.redis.kun
5+
spec:
6+
group: redis.kun
7+
names:
8+
kind: DistributedRedisCluster
9+
listKind: DistributedRedisClusterList
10+
plural: distributedredisclusters
11+
singular: distributedrediscluster
12+
shortNames:
13+
- drc
14+
scope: Namespaced
15+
additionalPrinterColumns:
16+
- JSONPath: .spec.masterSize
17+
description: The number of redis master node in the ensemble
18+
name: MasterSize
19+
type: integer
20+
- JSONPath: .status.status
21+
description: The status of redis cluster
22+
name: Status
23+
type: string
24+
- JSONPath: .metadata.creationTimestamp
25+
name: Age
26+
type: date
27+
- JSONPath: .status.numberOfMaster
28+
priority: 1
29+
description: The current master number of redis cluster
30+
name: CurrentMasters
31+
type: integer
32+
- JSONPath: .spec.image
33+
priority: 1
34+
description: The image of redis cluster
35+
name: Images
36+
type: string
37+
subresources:
38+
status: {}
39+
validation:
40+
openAPIV3Schema:
41+
description: DistributedRedisCluster is the Schema for the distributedredisclusters
42+
API
43+
properties:
44+
apiVersion:
45+
description: 'APIVersion defines the versioned schema of this representation
46+
of an object. Servers should convert recognized schemas to the latest
47+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
48+
type: string
49+
kind:
50+
description: 'Kind is a string value representing the REST resource this
51+
object represents. Servers may infer this from the endpoint the client
52+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
53+
type: string
54+
metadata:
55+
type: object
56+
spec:
57+
description: DistributedRedisClusterSpec defines the desired state of
58+
DistributedRedisCluster
59+
properties:
60+
masterSize:
61+
format: int32
62+
type: integer
63+
minimum: 3
64+
maximum: 10
65+
clusterReplicas:
66+
format: int32
67+
type: integer
68+
minimum: 1
69+
maximum: 3
70+
serviceName:
71+
type: string
72+
pattern: '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*'
73+
type: object
74+
status:
75+
description: DistributedRedisClusterStatus defines the observed state
76+
of DistributedRedisCluster
77+
type: object
78+
type: object
79+
version: v1alpha1
80+
versions:
81+
- name: v1alpha1
82+
served: true
83+
storage: true
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
apiVersion: apiextensions.k8s.io/v1beta1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: redisclusterbackups.redis.kun
5+
spec:
6+
group: redis.kun
7+
names:
8+
kind: RedisClusterBackup
9+
listKind: RedisClusterBackupList
10+
plural: redisclusterbackups
11+
singular: redisclusterbackup
12+
shortNames:
13+
- drcb
14+
scope: Namespaced
15+
additionalPrinterColumns:
16+
- JSONPath: .metadata.creationTimestamp
17+
name: Age
18+
type: date
19+
- JSONPath: .status.phase
20+
description: The phase of redis cluster backup
21+
name: Phase
22+
type: string
23+
subresources:
24+
status: {}
25+
versions:
26+
- name: v1alpha1
27+
# Each version can be enabled/disabled by Served flag.
28+
served: true
29+
# One and only one version must be marked as the storage version.
30+
storage: true
31+
validation:
32+
openAPIV3Schema:
33+
description: RedisClusterBackup is the Schema for the redisclusterbackups
34+
API
35+
properties:
36+
apiVersion:
37+
description: 'APIVersion defines the versioned schema of this representation
38+
of an object. Servers should convert recognized schemas to the latest
39+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
40+
type: string
41+
kind:
42+
description: 'Kind is a string value representing the REST resource this
43+
object represents. Servers may infer this from the endpoint the client
44+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
45+
type: string
46+
metadata:
47+
type: object
48+
spec:
49+
description: RedisClusterBackupSpec defines the desired state of RedisClusterBackup
50+
type: object
51+
status:
52+
description: RedisClusterBackupStatus defines the observed state of RedisClusterBackup
53+
type: object
54+
type: object
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "redis-cluster-operator.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
7+
{{- end }}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "redis-cluster-operator.fullname" -}}
15+
{{- if .Values.fullnameOverride }}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
17+
{{- else }}
18+
{{- $name := default .Chart.Name .Values.nameOverride }}
19+
{{- if contains $name .Release.Name }}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
21+
{{- else }}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
23+
{{- end }}
24+
{{- end }}
25+
{{- end }}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "redis-cluster-operator.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
32+
{{- end }}
33+
34+
{{/*
35+
Common labels
36+
*/}}
37+
{{- define "redis-cluster-operator.labels" -}}
38+
helm.sh/chart: {{ include "redis-cluster-operator.chart" . }}
39+
{{ include "redis-cluster-operator.selectorLabels" . }}
40+
{{- if .Chart.AppVersion }}
41+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
42+
{{- end }}
43+
app.kubernetes.io/managed-by: {{ .Release.Service }}
44+
{{- end }}
45+
46+
{{/*
47+
Selector labels
48+
*/}}
49+
{{- define "redis-cluster-operator.selectorLabels" -}}
50+
app.kubernetes.io/name: {{ include "redis-cluster-operator.name" . }}
51+
app.kubernetes.io/instance: {{ .Release.Name }}
52+
{{- end }}
53+
54+
{{/*
55+
Create the name of the service account to use
56+
*/}}
57+
{{- define "redis-cluster-operator.serviceAccountName" -}}
58+
{{- if .Values.serviceAccount.create }}
59+
{{- default (include "redis-cluster-operator.fullname" .) .Values.serviceAccount.name }}
60+
{{- else }}
61+
{{- default "default" .Values.serviceAccount.name }}
62+
{{- end }}
63+
{{- end }}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ .Values.operator.name }}
5+
spec:
6+
replicas: {{ .Values.operator.replicas }}
7+
selector:
8+
matchLabels:
9+
name: {{ .Values.operator.name }}
10+
template:
11+
metadata:
12+
labels:
13+
name: {{ .Values.operator.name }}
14+
spec:
15+
serviceAccountName: {{ .Values.operator.service_account_name }}
16+
securityContext:
17+
{{- .Values.operator.podsecurityContext | toYaml | nindent 8 }}
18+
containers:
19+
- name: {{ .Values.operator.name }}
20+
# Replace this with the built image name
21+
image: {{ .Values.operator.image_source }}:{{ .Values.operator.image_tag }}
22+
securityContext:
23+
{{- .Values.operator.containersecurityContext | toYaml | nindent 12 }}
24+
command:
25+
- redis-cluster-operator
26+
args:
27+
- --rename-command-path=/etc/redisconf
28+
- --rename-command-file=redis.conf
29+
imagePullPolicy: {{ .Values.operator.imagePullPolicy }}
30+
resources:
31+
{{- .Values.operator.resources | toYaml | nindent 12 }}
32+
env:
33+
- name: WATCH_NAMESPACE
34+
value: {{ .Values.operator.namespace | quote }}
35+
- name: POD_NAME
36+
valueFrom:
37+
fieldRef:
38+
fieldPath: metadata.name
39+
- name: OPERATOR_NAME
40+
value: {{ .Values.operator.name | quote }}
41+
volumeMounts:
42+
- name: redisconf
43+
mountPath: /etc/redisconf
44+
volumes:
45+
- name: redisconf
46+
configMap:
47+
name: redis-admin
48+
---
49+
apiVersion: v1
50+
kind: ConfigMap
51+
metadata:
52+
name: redis-admin
53+
data:
54+
redis.conf: |-
55+
{{- .Values.data.redis_conf | nindent 4 }}

0 commit comments

Comments
 (0)