Skip to content

Commit

Permalink
Feature: helm chart to deploy cluster quickly (#88)
Browse files Browse the repository at this point in the history
* feat: helm chart to deploy cluster
  • Loading branch information
powerfooI authored Oct 26, 2023
1 parent 181b616 commit 1142588
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/ob-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1alpha1
apiVersion: v2
appVersion: 2.0.0
description: A Helm chart for OB-Operator
name: ob-operator
Expand Down
23 changes: 23 additions & 0 deletions charts/oceanbase-cluster/.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/
24 changes: 24 additions & 0 deletions charts/oceanbase-cluster/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: oceanbase-cluster
description: A Helm chart for Kubernetes to deploy OceanBase cluster

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 4.2.0-sp.0-101000032023091319

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "4.2.0.0-101000032023091319"
Empty file.
62 changes: 62 additions & 0 deletions charts/oceanbase-cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "oceanbase-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 "oceanbase-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 "oceanbase-cluster.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "oceanbase-cluster.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "oceanbase-cluster.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
46 changes: 46 additions & 0 deletions charts/oceanbase-cluster/templates/obcluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: oceanbase.oceanbase.com/v1alpha1
kind: OBCluster
metadata:
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace | quote }}
labels:
{{- include "oceanbase-cluster.labels" . | nindent 4 }}
spec:
clusterName: {{ .Values.clusterName | default .Release.Name | quote }}
clusterId: {{ .Values.clusterId | default 1 }}
userSecrets:
{{- range $key, $value := .Values.userSecrets }}
{{ $key }}: {{ $value | quote }}
{{- end }}
topology:
{{- toYaml .Values.topology | nindent 4 }}
observer:
image: oceanbase/oceanbase-cloud-native:4.2.0.0-101000032023091319
{{- with .Values.observerConfig }}
resource:
{{- toYaml .resource | nindent 6 }}
storage:
{{- range $key, $size := .storages }}
{{ $key }}:
storageClass: {{ $.Values.storageClass }}
size: {{ $size }}
{{- end }}
{{- end }}
{{- if .Values.monitorEnabled }}
monitor:
image: oceanbase/obagent:4.2.0-100000062023080210
resource:
{{- toYaml .Values.monitorResource | nindent 6 }}
{{- end }}
parameters:
{{- range $param := .Values.parameters }}
- name: {{ $param.name }}
value: {{ $param.value | quote }}
{{- end }}
{{- if .Values.nfsBackupEnabled }}
backupVolume:
volume:
name: backup
nfs:
{{- toYaml .Values.nfsBackup | nindent 8 }}
{{- end }}
16 changes: 16 additions & 0 deletions charts/oceanbase-cluster/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if $.Values.generateUserSecrets }}
{{- range $secretName := $.Values.userSecrets }}
{{- if empty (lookup "v1" "Secret" $.Release.Namespace $secretName) }}
--- # the lookup function will return an empty list when dry-running or local rendering
apiVersion: v1
kind: Secret
metadata:
name: {{ $secretName }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "oceanbase-cluster.labels" $ | nindent 4 }}
data:
password: {{ randAlphaNum 16 | b64enc }}
{{- end }}
{{- end }}
{{- end }}
47 changes: 47 additions & 0 deletions charts/oceanbase-cluster/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
clusterName: obcluster
clusterId: 1025

storageClass: local-path

observerConfig:
resource:
cpu: 2
memory: 12Gi
storages:
dataStorage: 50Gi
redoLogStorage: 50Gi
logStorage: 20Gi

monitorEnabled: true
monitorResource:
cpu: 1
memory: 2Gi

parameters:
- name: system_memory
value: 3G

nfsBackupEnabled: false # set true and config volume if you want to enable backup with NFS
nfsBackup:
server: 1.1.1.1
path: /opt/nfs
readOnly: false

generateUserSecrets: true # if set true, all system user secrets will be generated automatically
userSecrets:
root: ob-user-root
proxyro: ob-user-proxyro
monitor: ob-user-monitor
operator: ob-user-operator

topology:
- zone: zone1
replica: 1
- zone: zone2
replica: 1
- zone: zone3
replica: 1
tolerations:
- key: obtopo
value: zone
effect: NoSchedule

0 comments on commit 1142588

Please sign in to comment.