Skip to content

Commit

Permalink
chore: update canal-server application.
Browse files Browse the repository at this point in the history
release version 0.1.0
  • Loading branch information
dellnoantechnp committed Jun 1, 2023
1 parent 959d3c5 commit 1e2c5ce
Show file tree
Hide file tree
Showing 9 changed files with 271 additions and 15 deletions.
Binary file added assets/stacks/canal/img/canal-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/stacks/canal/img/canal-75x80.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions charts/canal-server/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apiVersion: v2
name: canal-server
description: Canal Server is capable of parsing MySQL binlog and subscribe to the data change, while Canal Client can be implemented to broadcast the change to anywhere, e.g. database and Apache Kafka.
description: Canal Server is capable of parsing MySQL binlog and subscribe to the data change, while Canal Client can be implemented to broadcast the change to anywhere,
e.g. database and Apache Kafka.
home: https://github.com/alibaba/canal/wiki
annotations:
ghcr.io/packages: |
Expand All @@ -25,12 +26,13 @@ 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: 0.0.5
version: 0.1.0

# 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.
icon: https://raw.githubusercontent.com/dellnoantechnp/helm-chart-xxl-job-admin/main/assets/stacks/canal/img/canal-75x80.png
appVersion: "1.1.6"
dependencies:
- name: zookeeper
Expand Down
2 changes: 1 addition & 1 deletion charts/canal-server/configs/canal.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ canal.withoutNetty=false
canal.serverMode=tcp

# flush meta cursor/parse position to file
canal.file.data.dir=${canal.conf.dir}
canal.file.data.dir=/data
canal.file.flush.period=1000

## memory store RingBuffer size, should be Math.pow(2,n)
Expand Down
80 changes: 79 additions & 1 deletion charts/canal-server/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ If release name contains chart name it will be used as a full name.
{{- end }}
{{- end }}

{{/*
Create a default fully qualified zookeeper name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "canal-server.zookeeper.fullname" -}}
{{- if .Values.zookeeper.fullnameOverride -}}
{{- .Values.zookeeper.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default "zookeeper" .Values.zookeeper.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
Expand Down Expand Up @@ -113,6 +126,7 @@ e.g: example,example2

{{/*
return zkServers
e.g: server1:2181,server2:2181
*/}}
{{- define "zkServers" -}}
{{- if .Values.zookeeper.enabled }}
Expand All @@ -129,6 +143,28 @@ return zkServers
{{- end }}
{{- end }}

{{/*
return first zkServer address
e.g: zkServer1:2181
return: zkServer1
*/}}
{{- define "zkServer.address" }}
{{- $get_first := mustFirst (mustRegexSplit "," (include "zkServers" .) -1) }}
{{- $s1 := mustRegexSplit ":" $get_first -1 }}
{{- mustFirst $s1 }}
{{- end }}

{{/*
return first zkServer port
e.g: zkServer1:2181
return: 2181
*/}}
{{- define "zkServer.port" }}
{{- $get_first := mustFirst (mustRegexSplit "," (include "zkServers" .) -1) }}
{{- $s1 := mustRegexSplit ":" $get_first -1 }}
{{- mustLast $s1 }}
{{- end }}

{{/*
return canal-server canal.properties mount resouce string.
*/}}
Expand Down Expand Up @@ -160,4 +196,46 @@ canal.instance.detecting.sql=select 1
canal.instance.detecting.interval.time=3
canal.instance.detecting.retry.threshold=3
canal.instance.detecting.heartbeatHaEnable=true
{{- end }}
{{- end }}

{{/*
Return the proper image name (for the init container volume-permissions image)
*/}}
{{- define "canal-server.volumePermissions.image" -}}
{{ include "common.images.image" (dict "imageRoot" .Values.volumePermissions.image "global" .Values.global) }}
{{- end -}}

{{/*
Return the proper Storage Class
*/}}
{{- define "canal-server.storageClass" -}}
{{/*
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
but Helm 2.9 and 2.10 does not support it, so we need to implement this if-else logic.
*/}}
{{- if .Values.global -}}
{{- if .Values.global.storageClass -}}
{{- if (eq "-" .Values.global.storageClass) -}}
{{- printf "storageClassName: \"\"" -}}
{{- else }}
{{- printf "storageClassName: %s" .Values.global.storageClass -}}
{{- end -}}
{{- else -}}
{{- if .Values.persistence.storageClass -}}
{{- if (eq "-" .Values.persistence.storageClass) -}}
{{- printf "storageClassName: \"\"" -}}
{{- else }}
{{- printf "storageClassName: %s" .Values.persistence.storageClass -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- else -}}
{{- if .Values.persistence.storageClass -}}
{{- if (eq "-" .Values.persistence.storageClass) -}}
{{- printf "storageClassName: \"\"" -}}
{{- else }}
{{- printf "storageClassName: %s" .Values.persistence.storageClass -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
33 changes: 33 additions & 0 deletions charts/canal-server/templates/service-headless.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "canal-server.fullname" . }}-headless
labels: {{- include "common.labels.standard" . | nindent 4 }}
app.kubernetes.io/component: canal-server
{{- include "canal-server.labels" . | nindent 4 }}
spec:
type: ClusterIP
clusterIP: None
ports:
- port: {{ .Values.service.ports.canal.port }}
targetPort: tcp-canal
protocol: TCP
name: tcp-canal
{{- if and (contains .Values.service.type "NodePort") (typeIs "int" .Values.service.ports.canal.nodePort) }}
nodePort: {{ .Values.service.ports.canal.nodePort }}
{{- end }}
- port: {{ .Values.service.ports.admin.port }}
targetPort: tcp-admin
protocol: TCP
name: tcp-admin
{{- if and (contains .Values.service.type "NodePort") (typeIs "int" .Values.service.ports.admin.nodePort) }}
nodePort: {{ .Values.service.ports.admin.nodePort }}
{{- end }}
- port: {{ .Values.service.ports.metrics.port }}
targetPort: http-metrics
protocol: TCP
name: http-metrics
{{- if and (contains .Values.service.type "NodePort") (typeIs "int" .Values.service.ports.metrics.nodePort) }}
nodePort: {{ .Values.service.ports.metrics.nodePort }}
{{- end }}
selector: {{- include "common.labels.matchLabels" . | nindent 4 }}
77 changes: 67 additions & 10 deletions charts/canal-server/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{{- $zk_address := include "zkServer.address" . }}
{{- $zk_port := include "zkServer.port" . }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "canal-server.name" . }}
name: {{ include "canal-server.fullname" . }}
labels:
{{- include "canal-server.labels" . | nindent 4 }}
spec:
Expand All @@ -11,6 +13,7 @@ spec:
selector:
matchLabels:
{{- include "canal-server.selectorLabels" . | nindent 6 }}
serviceName: {{ template "canal-server.fullname" . }}-headless
template:
metadata:
{{- with .Values.podAnnotations }}
Expand All @@ -28,27 +31,46 @@ spec:
{{- if .Values.podSecurityContext.enabled }}
securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.initContainers }}
{{- if (include "zkServers" .) }}
initContainers:
{{- if .Values.initContainers }}
{{- include "common.tplvalues.render" (dict "value" .Values.initContainers "context" $) | nindent 8 }}
{{- end }}
{{- if (include "zkServers" .) }}
- name: wait-for-zookeeper
image: docker.io/bitnami/zookeeper:3.7.0-debian-10-r257
imagePullPolicy: Always
command: [ "/bin/bash", "-c", 'echo "ruok" | timeout 2 nc -w 2 {{ $zk_address}} {{ $zk_port }} | grep imok' ]
{{- else }}
- name: test
image: test:latest
command: []
{{ end }}
{{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
- name: volume-permissions
image: {{ template "minio.volumePermissions.image" . }}
image: {{ template "canal-server.volumePermissions.image" . }}
imagePullPolicy: {{ default "" .Values.volumePermissions.image.pullPolicy | quote }}
command:
- /bin/bash
- -ec
- |
chown -R {{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.podSecurityContext.fsGroup }} {{ .Values.persistence.mountPath }}
securityContext: {{- .Values.volumePermissions.containerSecurityContext | toYaml | nindent 12 }}
- chown
args:
- -R
- {{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.podSecurityContext.fsGroup }}
- /bitnami/zookeeper
{{- if .Values.dataLogDir }}
- {{ .Values.dataLogDir }}
{{- end }}
securityContext:
runAsUser: {{- .Values.volumePermissions.containerSecurityContext | toYaml | nindent 12 }}
{{- if .Values.volumePermissions.resources }}
resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
{{- end }}
volumeMounts:
- name: data
mountPath: {{ .Values.persistence.mountPath }}
mountPath: /bitnami/zookeeper
{{- if .Values.dataLogDir }}
- name: data-log
mountPath: {{ .Values.dataLogDir }}
{{- end }}
{{- end }}
{{- end }}
containers:
Expand Down Expand Up @@ -146,7 +168,42 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.sidecars }}
{{- include "common.tplvalues.render" (dict "value" .Values.sidecars "context" $) | nindent 8 }}
{{- end }}
volumes:
- name: config
configMap:
name: {{ include "canal.server.configmap.fullname" . }}
name: {{ include "canal.server.configmap.fullname" . }}
{{- if (empty (include "zkServers" .)) }}
{{- if not .Values.persistence.enabled }}
- name: data
emptyDir: {}
{{- else if .Values.persistence.existingClaim }}
- name: data
persistentVolumeClaim:
claimName: {{ printf "%s" (tpl .Values.persistence.existingClaim .) }}
{{- end }}
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
volumeClaimTemplates:
{{- end }}
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
- metadata:
name: data
{{- if .Values.persistence.annotations }}
annotations: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.annotations "context" $) | nindent 10 }}
{{- end }}
spec:
accessModes:
{{- range .Values.persistence.accessModes }}
- {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- include "canal-server.storageClass" . | nindent 8 }}
{{- if .Values.persistence.selector }}
selector: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.selector "context" $) | nindent 10 }}
{{- end -}}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/canal-server/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ spec:
image: busybox
command: ['wget']
args: ['{{ include "canal-server.fullname" . }}:{{ .Values.service.port }}']
hex_string: {{ printf "%x" "abc" }}
he1x1_string: {{ include "zkServer.address" . }}
restartPolicy: Never
86 changes: 86 additions & 0 deletions charts/canal-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,92 @@ tolerations: []

affinity: {}

## Canal-server container Security Context
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container
## @param containerSecurityContext.enabled Enable container Security Context
## @param containerSecurityContext.runAsUser User ID for the container
## @param containerSecurityContext.runAsNonRoot Avoid running as root User
##
containerSecurityContext:
enabled: true
runAsUser: 1001
runAsNonRoot: true

## Canal-server data Persistent Volume Storage Class
## If defined, storageClassName: <storageClass>
## If set to "-", storageClassName: "", which disables dynamic provisioning
## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack)
##
persistence:
## @param persistence.existingClaim Provide an existing `PersistentVolumeClaim`
## If defined, PVC must be created manually before volume will be bound
## The value is evaluated as a template
##
existingClaim: ""
## @param persistence.enabled Enable Canal-server meta data persistence using PVC
##
enabled: true
## @param persistence.storageClass PVC Storage Class for Canal-server meta data volume
##
storageClass: ""
## @param persistence.accessModes PVC Access modes
##
accessModes:
- ReadWriteOnce
## @param persistence.size PVC Storage Request for Canal-server meta data volume
##
size: 200Mi
## @param persistence.annotations Annotations for the PVC
##
annotations: {}
## @param persistence.selector Selector to match an existing Persistent Volume for Canal-server's data PVC
## If set, the PVC can't have a PV dynamically provisioned for it
## E.g.
## selector:
## matchLabels:
## app: my-app
##
selector: {}

## Init containers parameters:
## volumePermissions: Change the owner and group of the persistent volume mountpoint to runAsUser:fsGroup values from the securityContext section.
##
volumePermissions:
## @param volumePermissions.enabled Enable init container that changes the owner and group of the persistent volume(s) mountpoint to `runAsUser:fsGroup`
##
enabled: false
## @param volumePermissions.image.registry Init container volume-permissions image registry
## @param volumePermissions.image.repository Init container volume-permissions image repository
## @param volumePermissions.image.tag Init container volume-permissions image tag (immutable tags are recommended)
## @param volumePermissions.image.pullPolicy Init container volume-permissions image pull policy
## @param volumePermissions.image.pullSecrets Init container volume-permissions image pull secrets
##
image:
registry: docker.io
repository: bitnami/bitnami-shell
tag: 10-debian-10-r304
pullPolicy: IfNotPresent
## Optionally specify an array of imagePullSecrets.
## Secrets must be manually created in the namespace.
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
## Example:
## pullSecrets:
## - myRegistryKeySecretName
##
pullSecrets: []
## @param volumePermissions.resources Init container resource requests/limit
##
resources: {}
## Init container' Security Context
## Note: the chown of the data folder is done to containerSecurityContext.runAsUser
## and not the below volumePermissions.containerSecurityContext.runAsUser
## @param volumePermissions.containerSecurityContext.runAsUser User ID for the init container
##
containerSecurityContext:
runAsUser: 0

## Zookeeper chart configuration
## https://github.com/bitnami/charts/blob/master/bitnami/zookeeper/values.yaml
##
Expand Down

0 comments on commit 1e2c5ce

Please sign in to comment.