Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions chart/redis-cluster-operator/.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/
9 changes: 9 additions & 0 deletions chart/redis-cluster-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: redis-cluster-operator
description: A Helm chart for Redis cluster operator deployment

type: application

version: 0.1.0

appVersion: 0.1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: distributedredisclusters.redis.kun
spec:
group: redis.kun
names:
kind: DistributedRedisCluster
listKind: DistributedRedisClusterList
plural: distributedredisclusters
singular: distributedrediscluster
shortNames:
- drc
scope: Namespaced
additionalPrinterColumns:
- JSONPath: .spec.masterSize
description: The number of redis master node in the ensemble
name: MasterSize
type: integer
- JSONPath: .status.status
description: The status of redis cluster
name: Status
type: string
- JSONPath: .metadata.creationTimestamp
name: Age
type: date
- JSONPath: .status.numberOfMaster
priority: 1
description: The current master number of redis cluster
name: CurrentMasters
type: integer
- JSONPath: .spec.image
priority: 1
description: The image of redis cluster
name: Images
type: string
subresources:
status: {}
validation:
openAPIV3Schema:
description: DistributedRedisCluster is the Schema for the distributedredisclusters
API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: DistributedRedisClusterSpec defines the desired state of
DistributedRedisCluster
properties:
masterSize:
format: int32
type: integer
minimum: 3
maximum: 10
clusterReplicas:
format: int32
type: integer
minimum: 1
maximum: 3
serviceName:
type: string
pattern: '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*'
type: object
status:
description: DistributedRedisClusterStatus defines the observed state
of DistributedRedisCluster
type: object
type: object
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: redisclusterbackups.redis.kun
spec:
group: redis.kun
names:
kind: RedisClusterBackup
listKind: RedisClusterBackupList
plural: redisclusterbackups
singular: redisclusterbackup
shortNames:
- drcb
scope: Namespaced
additionalPrinterColumns:
- JSONPath: .metadata.creationTimestamp
name: Age
type: date
- JSONPath: .status.phase
description: The phase of redis cluster backup
name: Phase
type: string
subresources:
status: {}
versions:
- name: v1alpha1
# Each version can be enabled/disabled by Served flag.
served: true
# One and only one version must be marked as the storage version.
storage: true
validation:
openAPIV3Schema:
description: RedisClusterBackup is the Schema for the redisclusterbackups
API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: RedisClusterBackupSpec defines the desired state of RedisClusterBackup
type: object
status:
description: RedisClusterBackupStatus defines the observed state of RedisClusterBackup
type: object
type: object
63 changes: 63 additions & 0 deletions chart/redis-cluster-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "redis-cluster-operator.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "redis-cluster-operator.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "redis-cluster-operator.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "redis-cluster-operator.labels" -}}
helm.sh/chart: {{ include "redis-cluster-operator.chart" . }}
{{ include "redis-cluster-operator.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "redis-cluster-operator.selectorLabels" -}}
app.kubernetes.io/name: {{ include "redis-cluster-operator.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "redis-cluster-operator.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "redis-cluster-operator.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
55 changes: 55 additions & 0 deletions chart/redis-cluster-operator/templates/operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.operator.name }}
spec:
replicas: {{ .Values.operator.replicas }}
selector:
matchLabels:
name: {{ .Values.operator.name }}
template:
metadata:
labels:
name: {{ .Values.operator.name }}
spec:
serviceAccountName: {{ .Values.operator.service_account_name }}
securityContext:
{{- .Values.operator.podsecurityContext | toYaml | nindent 8 }}
containers:
- name: {{ .Values.operator.name }}
# Replace this with the built image name
image: {{ .Values.operator.image_source }}:{{ .Values.operator.image_tag }}
securityContext:
{{- .Values.operator.containersecurityContext | toYaml | nindent 12 }}
command:
- redis-cluster-operator
args:
- --rename-command-path=/etc/redisconf
- --rename-command-file=redis.conf
imagePullPolicy: {{ .Values.operator.imagePullPolicy }}
resources:
{{- .Values.operator.resources | toYaml | nindent 12 }}
env:
- name: WATCH_NAMESPACE
value: {{ .Values.operator.namespace | quote }}
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: OPERATOR_NAME
value: {{ .Values.operator.name | quote }}
volumeMounts:
- name: redisconf
mountPath: /etc/redisconf
volumes:
- name: redisconf
configMap:
name: redis-admin
---
apiVersion: v1
kind: ConfigMap
metadata:
name: redis-admin
data:
redis.conf: |-
{{- .Values.data.redis_conf | nindent 4 }}
105 changes: 105 additions & 0 deletions chart/redis-cluster-operator/templates/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
apiVersion: rbac.authorization.k8s.io/v1
{{- if eq (len .Values.operator.namespace) 0 }}
kind: ClusterRole
{{- else }}
kind: Role
{{- end }}
metadata:
name: redis-cluster-operator
rules:
- apiGroups:
- ""
resources:
- pods
- secrets
- endpoints
- persistentvolumeclaims
verbs:
- get
- list
- watch
- delete
- apiGroups:
- ""
resources:
- configmaps
- pods/exec
- secrets
- services
- events
- persistentvolumeclaims
verbs:
- create
- get
- list
- patch
- update
- watch
- delete
- apiGroups:
- ""
resources:
- namespaces
verbs:
- get
- list
- watch
- apiGroups:
- batch
resources:
- jobs
verbs:
- create
- get
- list
- patch
- update
- watch
- delete
- apiGroups:
- apps
resources:
- deployments
- replicasets
- statefulsets
verbs:
- create
- get
- list
- patch
- update
- watch
- delete
- apiGroups:
- policy
resources:
- poddisruptionbudgets
verbs:
- create
- get
- list
- patch
- update
- watch
- delete
- apiGroups:
- apps
resourceNames:
- redis-operator
resources:
- deployments/finalizers
verbs:
- update
- apiGroups:
- redis.kun
resources:
- '*'
- redisclusterbackups
verbs:
- delete
- deletecollection
- get
- list
- patch
- update
- watch
Loading