-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:pika-master-slave-cluster in kb (#2903)
* Pika-master-slave-cluster in kubeblocks 0.9;use lifecycleActions instead of script to bind master-slave relation * Use lifecycleActions instead of script to bind master-slave relation(Warning: This feature still has bugs waiting to be fixed) * Master-slave binding via lifecycleActions field, deprecating script (but still retaining) * Use headless svc to replace the ip
- Loading branch information
1 parent
d031ba6
commit c3cd42e
Showing
18 changed files
with
1,086 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
tools/kubeblocks_helm/pika-master-slave-cluster/.helmignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
22 changes: 22 additions & 0 deletions
22
tools/kubeblocks_helm/pika-master-slave-cluster/Chart.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: v2 | ||
name: pika-master-slave | ||
description: A Pika Master-Slave Group Helm chart for KubeBlocks. | ||
|
||
type: application | ||
|
||
version: 0.9.0 | ||
|
||
appVersion: "3.5.5" | ||
|
||
home: https://github.com/OpenAtomFoundation/pika | ||
keywords: | ||
- pika | ||
- redis | ||
- database | ||
- nosql | ||
- replication | ||
- codis | ||
|
||
maintainers: | ||
- name: pika | ||
url: https://github.com/OpenAtomFoundation/pika/tools/kubeblocks_helm |
62 changes: 62 additions & 0 deletions
62
tools/kubeblocks_helm/pika-master-slave-cluster/templates/_helpers.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "pika-cluster.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 "pika-cluster.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 "pika-cluster.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "pika-cluster.labels" -}} | ||
helm.sh/chart: {{ include "pika-cluster.chart" . }} | ||
{{ include "pika-cluster.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "pika-cluster.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "pika-cluster.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{- define "clustername" -}} | ||
{{ include "pika-cluster.fullname" .}} | ||
{{- end}} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "pika-cluster.serviceAccountName" -}} | ||
{{- default (printf "kb-%s" (include "clustername" .)) .Values.serviceAccount.name }} | ||
{{- end }} |
43 changes: 43 additions & 0 deletions
43
tools/kubeblocks_helm/pika-master-slave-cluster/templates/cluster.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
apiVersion: apps.kubeblocks.io/v1alpha1 | ||
kind: Cluster | ||
metadata: | ||
name: {{ include "clustername" . }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: {{ include "pika-cluster.labels" . | nindent 4 }} | ||
spec: | ||
terminationPolicy: {{ .Values.terminationPolicy }} | ||
affinity: | ||
{{- with .Values.topologyKeys }} | ||
topologyKeys: {{ . | toYaml | nindent 6 }} | ||
{{- end }} | ||
{{- with $.Values.tolerations }} | ||
tolerations: {{ . | toYaml | nindent 4 }} | ||
{{- end }} | ||
componentSpecs: | ||
- name: pika | ||
componentDef: pika # Ref componentdefinition.name | ||
enabledLogs: {{ $.Values.enabledLogs | toJson | indent 4 }} | ||
replicas: {{ add (int $.Values.slaveCount) 1 | default 2 }} | ||
serviceAccountName: {{ include "pika-cluster.serviceAccountName" $ }} | ||
{{- with $.Values.resources.pikaMS }} | ||
resources: | ||
limits: | ||
cpu: {{ .limits.cpu | quote }} | ||
memory: {{ .limits.memory | quote }} | ||
requests: | ||
cpu: {{ .requests.cpu | quote }} | ||
memory: {{ .requests.memory | quote }} | ||
{{- end }} | ||
{{- if $.Values.persistence.enabled }} | ||
volumeClaimTemplates: | ||
{{- with $.Values.persistence.pikaData }} | ||
- name: data # ref componentDefinition.containers.volumeMounts.name | ||
spec: | ||
storageClassName: {{ .storageClassName }} | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: {{ .size }} | ||
{{- end }} | ||
{{- end }} |
14 changes: 14 additions & 0 deletions
14
tools/kubeblocks_helm/pika-master-slave-cluster/templates/role.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: kb-{{ include "clustername" . }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{ include "pika-cluster.labels" . | nindent 4 }} | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- events | ||
verbs: | ||
- create |
15 changes: 15 additions & 0 deletions
15
tools/kubeblocks_helm/pika-master-slave-cluster/templates/rolebinding.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: kb-{{ include "clustername" . }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{ include "pika-cluster.labels" . | nindent 4 }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: kb-{{ include "clustername" . }} | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ include "pika-cluster.serviceAccountName" . }} | ||
namespace: {{ .Release.Namespace }} |
7 changes: 7 additions & 0 deletions
7
tools/kubeblocks_helm/pika-master-slave-cluster/templates/serviceaccount.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ include "pika-cluster.serviceAccountName" . }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{ include "pika-cluster.labels" . | nindent 4 }} |
52 changes: 52 additions & 0 deletions
52
tools/kubeblocks_helm/pika-master-slave-cluster/values.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Default values for pika. | ||
# This is a YAML-formatted file. | ||
# Declare variables to be passed into your templates. | ||
|
||
nameOverride: "" | ||
fullnameOverride: "" | ||
|
||
slaveCount: 1 | ||
|
||
terminationPolicy: Delete | ||
|
||
clusterVersionOverride: "" | ||
|
||
monitor: | ||
enabled: false | ||
|
||
switchPolicy: | ||
type: Noop | ||
|
||
resources: | ||
# We usually recommend not to specify default resources and to leave this as a conscious | ||
# choice for the user. This also increases chances charts run on environments with little | ||
# resources, such as Minikube. If you do want to specify resources, uncomment the following | ||
# lines, adjust them as necessary, and remove the curly braces after 'resources:'. | ||
pikaMS: | ||
limits: | ||
cpu: 500m | ||
memory: 3Gi | ||
requests: | ||
cpu: 500m | ||
memory: 1Gi | ||
|
||
persistence: | ||
enabled: true | ||
pikaData: | ||
storageClassName: | ||
size: 10Gi | ||
|
||
topologyKeys: | ||
- kubernetes.io/hostname | ||
|
||
## @param tolerations | ||
## ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ | ||
## | ||
tolerations: [ ] | ||
|
||
#enabledLogs: | ||
# - running | ||
|
||
# The RBAC permission used by cluster component pod, now include event.create | ||
serviceAccount: | ||
name: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: v2 | ||
name: pika | ||
description: A Pika Master Slave Group definition Helm chart for Kubernetes | ||
|
||
type: application | ||
|
||
version: 0.9.0 | ||
|
||
appVersion: "3.5.5" | ||
|
||
home: https://github.com/OpenAtomFoundation/pika | ||
keywords: | ||
- pika | ||
- redis | ||
- database | ||
- nosql | ||
- replication | ||
|
||
maintainers: | ||
- name: pika | ||
url: https://github.com/OpenAtomFoundation/pika/tools/kubeblocks_helm |
Oops, something went wrong.