Skip to content

Commit

Permalink
Merge branch 'apecloud:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
yabinji authored Mar 12, 2024
2 parents 789c77b + 0ef41ab commit c123bb6
Show file tree
Hide file tree
Showing 47 changed files with 1,745 additions and 101 deletions.
2 changes: 1 addition & 1 deletion addons/apecloud-mysql/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: ApeCloud MySQL is a database that is compatible with MySQL syntax a

type: application

version: 0.9.0-beta.9
version: 0.9.0-beta.10

# This is the version number of the ApeCloud MySQL being deployed,
# rather than the version number of ApeCloud MySQL-Scale itself.
Expand Down
2 changes: 1 addition & 1 deletion addons/apecloud-mysql/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ wesqlscale:
# if the value of wesqlscale.image.registry is not specified using `--set`, it will be set to the value of 'image.registry' by default
registry: ""
repository: apecloud/apecloud-mysql-scale
tag: "0.2.5"
tag: "0.2.6"
pullPolicy: IfNotPresent

## @param resourceNamePrefix Prefix for all resources name created by this chart, that can avoid name conflict
Expand Down
38 changes: 36 additions & 2 deletions addons/elasticsearch/templates/clusterdefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,24 @@ spec:
securityContext:
runAsUser: 0
privileged: true
- name: install-plugins
# analysis-ik must be downloaded and installed instead of using the elasticsearch-plugin install command
# https://github.com/infinilabs/analysis-ik/issues/808
- name: download-install-plugins
imagePullPolicy: IfNotPresent
command:
- sh
- -c
- |
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v{{ .Chart.AppVersion }}/elasticsearch-analysis-ik-{{ .Chart.AppVersion }}.zip
mkdir -p /opt/bitnami/elasticsearch/plugins/ik
unzip elasticsearch-analysis-ik-{{ .Chart.AppVersion }}.zip -d /opt/bitnami/elasticsearch/plugins/ik
securityContext:
runAsUser: 0
privileged: true
volumeMounts:
- mountPath: /opt/bitnami/elasticsearch/plugins
name: plugins
- name: native-install-plugins
imagePullPolicy: IfNotPresent
command:
- sh
Expand Down Expand Up @@ -272,7 +289,24 @@ spec:
securityContext:
runAsUser: 0
privileged: true
- name: install-plugins
# analysis-ik must be downloaded and installed instead of using the elasticsearch-plugin install command
# https://github.com/infinilabs/analysis-ik/issues/808
- name: download-install-plugins
imagePullPolicy: IfNotPresent
command:
- sh
- -c
- |
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v{{ $.Chart.AppVersion }}/elasticsearch-analysis-ik-{{ $.Chart.AppVersion }}.zip
mkdir -p /opt/bitnami/elasticsearch/plugins/ik
unzip elasticsearch-analysis-ik-{{ $.Chart.AppVersion }}.zip -d /opt/bitnami/elasticsearch/plugins/ik
securityContext:
runAsUser: 0
privileged: true
volumeMounts:
- mountPath: /opt/bitnami/elasticsearch/plugins
name: plugins
- name: native-install-plugins
imagePullPolicy: IfNotPresent
command:
- sh
Expand Down
10 changes: 8 additions & 2 deletions addons/elasticsearch/templates/clusterversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ spec:
- name: sysctl
image: {{ .Values.image.registry | default "docker.io" }}/busybox:1.35
imagePullPolicy: {{ default .Values.image.pullPolicy "IfNotPresent" }}
- name: install-plugins
- name: download-install-plugins
image: {{ .Values.image.registry | default "docker.io" }}/busybox:1.35
imagePullPolicy: {{ default .Values.image.pullPolicy "IfNotPresent" }}
- name: native-install-plugins
image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}
imagePullPolicy: {{ default .Values.image.pullPolicy "IfNotPresent" }}
containers:
Expand All @@ -36,7 +39,10 @@ spec:
- name: sysctl
image: {{ .Values.image.registry | default "docker.io" }}/busybox:latest
imagePullPolicy: {{ default .Values.image.pullPolicy "IfNotPresent" }}
- name: install-plugins
- name: download-install-plugins
image: {{ .Values.image.registry | default "docker.io" }}/busybox:1.35
imagePullPolicy: {{ default .Values.image.pullPolicy "IfNotPresent" }}
- name: native-install-plugins
image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}
imagePullPolicy: {{ default .Values.image.pullPolicy "IfNotPresent" }}
containers:
Expand Down
4 changes: 2 additions & 2 deletions addons/elasticsearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ roles:
role: "master"

plugins:
- name: analysis-ik
url: https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v8.8.2/elasticsearch-analysis-ik-8.8.2.zip
#- name: analysis-ik
# url: https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v8.8.2/elasticsearch-analysis-ik-8.8.2.zip
2 changes: 1 addition & 1 deletion addons/kafka-cluster/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:
alias: extra

type: application
version: 0.8.0
version: 0.8.1
appVersion: 3.3.2

home: https://github.com/apecloud/kubeblocks/tree/main/deploy/kafka-cluster
Expand Down
6 changes: 5 additions & 1 deletion addons/kafka-cluster/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
labels: {{ include "kblib.clusterLabels" . | nindent 4 }}
annotations:
"kubeblocks.io/extra-env": '{"KB_KAFKA_ENABLE_SASL":"{{ $.Values.saslEnable }}","KB_KAFKA_BROKER_HEAP":"{{ $.Values.brokerHeap }}","KB_KAFKA_CONTROLLER_HEAP":"{{ $.Values.controllerHeap }}","KB_KAFKA_PUBLIC_ACCESS":"{{ $.Values.extra.publiclyAccessible }}", "KB_KAFKA_BROKER_NODEPORT": "{{ $.Values.nodePortEnabled }}"}'
{{ include "kafka-cluster.brokerAddrFeatureGate" . | nindent 4 }}
{{- include "kafka-cluster.brokerAddrFeatureGate" . | nindent 4 }}
spec:
clusterDefinitionRef: kafka # ref clusterdefinition.name
clusterVersionRef: {{ .Values.version }}
Expand All @@ -16,7 +16,11 @@ spec:
serviceName: bootstrap
componentSelector: broker
spec:
{{- if .Values.nodePortEnabled }}
type: NodePort
{{- else }}
type: ClusterIP
{{- end }}
ports:
- name: kafka-client
targetPort: 9092
Expand Down
23 changes: 18 additions & 5 deletions addons/mogdb-cluster/templates/rbac.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
{{- include "kblib.rbac" . }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
kind: Role
metadata:
name: kubeblocks-switchover-pod-role
name: {{ printf "%s-switchover-role" (include "kblib.clusterName" .) }}
labels:
app.kubernetes.io/instance: kubeblocks
app.kubernetes.io/name: kubeblocks
{{- include "kblib.clusterLabels" . | nindent 4 }}
app.kubernetes.io/required-by: pod
rules:
- apiGroups: [""]
resources: ["pods/exec"]
verbs: ["create"]
---
{{- include "kblib.rbac" . }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ printf "%s-switchover" (include "kblib.clusterName" .) }}
labels:
{{- include "kblib.clusterLabels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ printf "%s-switchover-role" (include "kblib.clusterName" .) }}
subjects:
- kind: ServiceAccount
name: {{ printf "kb-%s" (include "kblib.clusterName" .) }}
namespace: {{ .Release.Namespace }}
8 changes: 4 additions & 4 deletions addons/mogdb-cluster/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"number",
"string"
],
"default": 0.5,
"minimum": 0.5,
"default": 1,
"minimum": 1,
"maximum": 64,
"multipleOf": 0.5
},
Expand All @@ -39,8 +39,8 @@
"number",
"string"
],
"default": 0.5,
"minimum": 0.5,
"default": 1,
"minimum": 1,
"maximum": 1000
},
"storage": {
Expand Down
12 changes: 5 additions & 7 deletions addons/mogdb-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ version: mogdb-5.0.5

## @param mode postgresql cluster topology mode, standalone, replication
##
mode: standalone
mode: replication

## @param replicas specify cluster replicas
##
replicas: 1
replicas: 2

## @param cpu
##
cpu: 0.5
cpu: 1

## @param memory, the unit is Gi
##
memory: 0.5
memory: 1

## @param requests.cpu if not set, use cpu
## @param requests.memory, if not set, use memory
Expand All @@ -31,6 +31,4 @@ requests:

## @param storage size, the unit is Gi
##
storage: 20

customRBAC: true
storage: 20
53 changes: 42 additions & 11 deletions addons/mogdb/templates/swithover.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
type: string
candidate:
description: |
candidate instance name(pod Name). if candidate is not empty, will promote it to primary.
candidate instance name(pod Name). if candidate is not empty, will promote it to primary.
otherwise promote a randomly selected pod to primary.
type: string
type: object
Expand All @@ -31,13 +31,44 @@ spec:
image: docker.io/apecloud/kubeblocks-tools:latest
imagePullPolicy: IfNotPresent
command:
- sh
- /scripts/switchover.sh
volumeMounts:
- name: scripts
mountPath: /scripts
volumes:
- name: scripts
configMap:
name: mogdb-scripts
defaultMode: 0777
- /bin/sh
- -c
- |
set -x
# do switchover
echo "INFO: doing switchover.."
echo "INFO: candidate: ${candidate}"
kubectl exec -it ${candidate} -c mogdb -- gosu omm gs_ctl switchover
# check if switchover successfully.
echo "INFO: start to check if switchover successfully, timeout is 60s"
executedUnix=$(date +%s)
while true; do
sleep 5
if [ ! -z ${candidate} ]; then
# if candidate specified, only check it
role=$(kubectl get pod ${candidate} -ojson | jq -r '.metadata.labels["kubeblocks.io/role"]')
if [ "$role" == "Primary" ] || [ "$role" == "primary" ] || [ "$role" == "leader" ] || [ "$role" == "master" ]; then
echo "INFO: switchover successfully, ${candidate} is ${role}"
exit 0
fi
else
# check if the candidate instance has been promote to primary
pods=$(kubectl get pod -l apps.kubeblocks.io/component-name=${KB_COMP_NAME},app.kubernetes.io/instance=${KB_CLUSTER_NAME} | awk 'NR > 1 {print $1}')
for podName in ${pods}; do
if [ "${podName}" != "${primary}" ];then
role=$(kubectl get pod ${podName} -ojson | jq -r '.metadata.labels["kubeblocks.io/role"]')
if [ "$role" == "Primary" ] || [ "$role" == "primary" ] || [ "$role" == "leader" ] || [ "$role" == "master" ]; then
echo "INFO: switchover successfully, ${podName} is ${role}"
exit 0
fi
fi
done
fi
currentUnix=$(date +%s)
diff_time=$((${currentUnix}-${executedUnix}))
if [ ${diff_time} -ge 60 ]; then
echo "ERROR: switchover failed."
exit 1
fi
done
4 changes: 2 additions & 2 deletions addons/mysql/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ description: MySQL is a widely used, open-source relational database management

type: application

version: 0.9.0
version: 0.9.1

# This is the version number of the ApeCloud MySQL being deployed,
# rather than the version number of ApeCloud MySQL-Scale itself.
# From a user's perspective, the version number of the frontend
# proxy of the MySQL being used is not relevant.
# appVersion: "8.0.33"
appVersion: "5.7.42"
appVersion: "5.7.44"

home: https://kubeblocks.io/
icon: https://kubeblocks.io/img/logo.png
Expand Down
9 changes: 9 additions & 0 deletions addons/mysql/config/mysql5.7-config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ max_binlog_size=134217728
# binlog_transaction_dependency_tracking=WRITESET #Default Commit Order, Aws not set
log_slave_updates=ON

# audit log
loose_audit_log_handler=FILE # FILE, SYSLOG
loose_audit_log_file={{ $data_root }}/auditlog/audit.log
loose_audit_log_buffer_size=1Mb
loose_audit_log_policy=ALL # ALL, LOGINS, QUERIES, NONE
loose_audit_log_strategy=ASYNCHRONOUS
loose_audit_log_rotate_on_size=10485760
loose_audit_log_rotations=5

# replay log
# relay_log_info_repository=TABLE
# From mysql8.0.23 is deprecated.
Expand Down
14 changes: 14 additions & 0 deletions addons/mysql/config/mysql8.0-config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,20 @@ relay_log_recovery=ON
relay_log=relay-bin
relay_log_index=relay-bin.index

# audit log
loose_audit_log_handler=FILE # FILE, SYSLOG
loose_audit_log_file={{ $data_root }}/auditlog/audit.log
loose_audit_log_buffer_size=1Mb
loose_audit_log_policy=ALL # ALL, LOGINS, QUERIES, NONE
loose_audit_log_strategy=ASYNCHRONOUS
loose_audit_log_rotate_on_size=10485760
loose_audit_log_rotations=5

# semi sync, it works
# loose_rpl-semi-sync-source-enabled = 1
# loose_rpl_semi_sync_source_timeout = 0
# loose_rpl-semi-sync-replica-enabled = 1

pid-file=/var/run/mysqld/mysqld.pid
socket=/var/run/mysqld/mysqld.sock

Expand Down
2 changes: 1 addition & 1 deletion addons/mysql/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,4 @@ service:
pipelines:
metrics:
receivers: [ apecloudmysql, prometheus ]
{{- end }}
{{- end }}
4 changes: 3 additions & 1 deletion addons/mysql/templates/clusterdefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ spec:
- command:
- bash
- -c
- "mkdir -p /var/lib/mysql/{log,binlog}; chown -R mysql:root /var/lib/mysql;"
- |
mkdir -p {{ .Values.dataMountPath }}/{log,binlog,auditlog}
cp /usr/lib/mysql/plugin/ {{ .Values.dataMountPath }}/plugin -r
imagePullPolicy: Always
name: init-data
volumeMounts:
Expand Down
Loading

0 comments on commit c123bb6

Please sign in to comment.