Skip to content

Commit f945b1f

Browse files
authored
Merge pull request #60 from alexeyNsorokin/feature/add-helm-chart
Add Helm chart
2 parents cb8f12e + 889707f commit f945b1f

File tree

10 files changed

+449
-0
lines changed

10 files changed

+449
-0
lines changed
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 }}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
{{- if eq (len .Values.operator.namespace) 0 }}
3+
kind: ClusterRole
4+
{{- else }}
5+
kind: Role
6+
{{- end }}
7+
metadata:
8+
name: redis-cluster-operator
9+
rules:
10+
- apiGroups:
11+
- ""
12+
resources:
13+
- pods
14+
- secrets
15+
- endpoints
16+
- persistentvolumeclaims
17+
verbs:
18+
- get
19+
- list
20+
- watch
21+
- delete
22+
- apiGroups:
23+
- ""
24+
resources:
25+
- configmaps
26+
- pods/exec
27+
- secrets
28+
- services
29+
- events
30+
- persistentvolumeclaims
31+
verbs:
32+
- create
33+
- get
34+
- list
35+
- patch
36+
- update
37+
- watch
38+
- delete
39+
- apiGroups:
40+
- ""
41+
resources:
42+
- namespaces
43+
verbs:
44+
- get
45+
- list
46+
- watch
47+
- apiGroups:
48+
- batch
49+
resources:
50+
- jobs
51+
verbs:
52+
- create
53+
- get
54+
- list
55+
- patch
56+
- update
57+
- watch
58+
- delete
59+
- apiGroups:
60+
- apps
61+
resources:
62+
- deployments
63+
- replicasets
64+
- statefulsets
65+
verbs:
66+
- create
67+
- get
68+
- list
69+
- patch
70+
- update
71+
- watch
72+
- delete
73+
- apiGroups:
74+
- policy
75+
resources:
76+
- poddisruptionbudgets
77+
verbs:
78+
- create
79+
- get
80+
- list
81+
- patch
82+
- update
83+
- watch
84+
- delete
85+
- apiGroups:
86+
- apps
87+
resourceNames:
88+
- redis-operator
89+
resources:
90+
- deployments/finalizers
91+
verbs:
92+
- update
93+
- apiGroups:
94+
- redis.kun
95+
resources:
96+
- '*'
97+
- redisclusterbackups
98+
verbs:
99+
- delete
100+
- deletecollection
101+
- get
102+
- list
103+
- patch
104+
- update
105+
- watch

0 commit comments

Comments
 (0)