From 1fb1fb8bf6b1a07c727034bf19916da4c01322fd Mon Sep 17 00:00:00 2001 From: Asmund Tokheim Date: Tue, 15 Mar 2022 20:32:30 +0100 Subject: [PATCH 1/7] Make config configurable, move passwords to secrets, eventslog tailing sidecar Signed-off-by: Asmund Tokheim --- proxysql-cluster/files/probe-proxysql.bash | 2 +- proxysql-cluster/files/proxysql.cnf | 84 -------------- proxysql-cluster/templates/_helpers.tpl | 21 ++++ proxysql-cluster/templates/configmap.yaml | 8 +- proxysql-cluster/templates/deployment.yaml | 57 +++++++++- proxysql-cluster/templates/secret.yaml | 13 +++ proxysql-cluster/values.yaml | 122 +++++++++++++++++++++ 7 files changed, 212 insertions(+), 95 deletions(-) delete mode 100644 proxysql-cluster/files/proxysql.cnf create mode 100644 proxysql-cluster/templates/secret.yaml diff --git a/proxysql-cluster/files/probe-proxysql.bash b/proxysql-cluster/files/probe-proxysql.bash index e2ef0c2..2a300c8 100644 --- a/proxysql-cluster/files/probe-proxysql.bash +++ b/proxysql-cluster/files/probe-proxysql.bash @@ -2,7 +2,7 @@ set -e mbin="/usr/bin/mysql" -lcon="-h127.0.0.1 -P6032 -uadmin -padmin" +lcon="-h127.0.0.1 -P6032 -u$ADMIN_USER -p$ADMIN_PASSWORD" opts="-NB" hg0_avail=$($mbin $lcon $opts -e"select count(*) from runtime_mysql_servers where hostgroup_id = 0") diff --git a/proxysql-cluster/files/proxysql.cnf b/proxysql-cluster/files/proxysql.cnf deleted file mode 100644 index 83b6674..0000000 --- a/proxysql-cluster/files/proxysql.cnf +++ /dev/null @@ -1,84 +0,0 @@ -datadir="/var/lib/proxysql" - -admin_variables= -{ - admin_credentials="admin:admin;radmin:radmin" - mysql_ifaces="0.0.0.0:6032" -} - -mysql_variables= -{ - threads=2 - max_connections=2048 - default_query_delay=0 - default_query_timeout=36000000 - have_compress=true - poll_timeout=2000 - interfaces="0.0.0.0:6033" - default_schema="information_schema" - stacksize=1048576 - server_version="8.0.20" - connect_timeout_server=3000 - monitor_username="monitor" - monitor_password="monitor" - monitor_history=600000 - monitor_connect_interval=5000 - monitor_ping_interval=2000 - monitor_read_only_interval=1500 - monitor_read_only_timeout=500 - ping_interval_server_msec=15000 - ping_timeout_server=500 - commands_stats=true - sessions_sort=true - connect_retries_on_failure=10 -} - -# defines all the MySQL servers -mysql_servers = -( - { address="mysql-8.default.svc.cluster.local" , port=3306 , hostgroup=1, max_connections=5000 }, - { address="mysql-8-slave.default.svc.cluster.local" , port=3306 , hostgroup=1, max_connections=5000 }, -) - - -# defines all the MySQL users -mysql_users: -( - { username = "root" , password = "XHCO2ydDXj" , default_hostgroup = 0 , active = 1 } -) - - - -#defines MySQL Query Rules -mysql_query_rules: -( - { - rule_id=1 - active=1 - match_pattern="^SELECT .* FOR UPDATE$" - destination_hostgroup=0 - apply=1 - }, - { - rule_id=2 - active=1 - match_pattern="^SELECT" - destination_hostgroup=1 - apply=1 - } -) - -scheduler= -( -) - - -mysql_replication_hostgroups= -( - { - writer_hostgroup=0 - reader_hostgroup=1 - comment="RHG1" - } -) - diff --git a/proxysql-cluster/templates/_helpers.tpl b/proxysql-cluster/templates/_helpers.tpl index 50d07f2..0d19ba4 100644 --- a/proxysql-cluster/templates/_helpers.tpl +++ b/proxysql-cluster/templates/_helpers.tpl @@ -43,3 +43,24 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end -}} + +{{- define "proxysql.pwd" -}} +{{- if not .password }} +{{- $_ := set . "password" (randAlphaNum 20) }} +{{- end -}} +{{ .password }} +{{- end -}} + +{{- define "proxysql.cfgmapdump" -}} +{{ range $key, $val := . -}} +{{ $key }}={{ $val }} +{{ end -}} +{{- end -}} + +{{- define "proxysql.cfglistdump" -}} +{{- range $idx, $val := . -}} +{ + {{ include "proxysql.cfgmapdump" $val | nindent 2 }} +}, +{{ end -}} +{{- end -}} diff --git a/proxysql-cluster/templates/configmap.yaml b/proxysql-cluster/templates/configmap.yaml index bd92c2a..ac944f9 100644 --- a/proxysql-cluster/templates/configmap.yaml +++ b/proxysql-cluster/templates/configmap.yaml @@ -1,9 +1,9 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ .Release.Name }}-proxysqlcm -data: - proxysql.cnf: | -{{ tpl (.Files.Get "files/proxysql.cnf") . | indent 4 }} + name: {{ include "proxysql.fullname" . }}-cm + labels: + {{- include "proxysql.labels" . | nindent 4 }} +data: probe-proxysql.bash: | {{ tpl (.Files.Get "files/probe-proxysql.bash") . | indent 4 }} diff --git a/proxysql-cluster/templates/deployment.yaml b/proxysql-cluster/templates/deployment.yaml index a5c93e5..b0c4ba6 100644 --- a/proxysql-cluster/templates/deployment.yaml +++ b/proxysql-cluster/templates/deployment.yaml @@ -1,3 +1,4 @@ +{{- $root := . }} apiVersion: apps/v1 kind: Deployment metadata: @@ -13,12 +14,18 @@ spec: template: metadata: labels: - app.kubernetes.io/name: {{ include "proxysql.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} + {{ include "proxysql.labels" . | nindent 8 }} + annotations: + checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} + {{- end }} + {{- if .Values.securityContext.enabled }} + securityContext: + fsGroup: {{ .Values.securityContext.fsGroup }} + runAsUser: {{ .Values.securityContext.runAsUser }} {{- end }} containers: - name: {{ .Chart.Name }} @@ -32,12 +39,28 @@ spec: containerPort: 6032 protocol: TCP volumeMounts: - - name: {{ .Release.Name }}-config + - name: probe-config mountPath: /usr/local/bin/probe-proxysql.bash subPath: probe-proxysql.bash - - name: {{ .Release.Name }}-config + readOnly: true + - name: proxy-config mountPath: /etc/proxysql.cnf subPath: proxysql.cnf + readOnly: true + - name: datadir + mountPath: {{ .Values.config.datadir }} + {{- if .Values.eventsLog.enabled }} + - name: eventslog + mountPath: {{ .Values.eventsLog.directory }} + {{- end }} + env: + {{- range $index, $envName := .Values.secretEnvs }} + - name: {{ $envName }} + valueFrom: + secretKeyRef: + name: {{ include "proxysql.fullname" $root }}-secret + key: {{ $envName }} + {{- end }} livenessProbe: exec: command: ["/bin/bash","/usr/local/bin/probe-proxysql.bash"] @@ -46,6 +69,19 @@ spec: command: ["/bin/bash","/usr/local/bin/probe-proxysql.bash"] resources: {{- toYaml .Values.resources | nindent 12 }} + {{- if and .Values.eventsLog.enabled .Values.eventsLog.tailer.enabled }} + - name: "eventslog" + image: "{{ .Values.eventsLog.tailer.image.repository }}:{{ .Values.eventsLog.tailer.image.tag }}" + imagePullPolicy: "{{ .Values.eventsLog.tailer.image.pullPolicy }}" + command: + - "xtail" + - "/logs/" + resources: + {{- toYaml .Values.eventsLog.tailer.resources | nindent 12 }} + volumeMounts: + - name: eventslog + mountPath: /logs + {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} @@ -59,6 +95,15 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} volumes: - - name: {{ .Release.Name }}-config + - name: probe-config configMap: - name: {{ .Release.Name }}-proxysqlcm + name: {{ include "proxysql.fullname" . }}-cm + - name: proxy-config + secret: + secretName: {{ include "proxysql.fullname" . }}-secret + - name: datadir + emptyDir: {} + {{- if .Values.eventsLog.enabled }} + - name: eventslog + emptyDir: {} + {{- end }} diff --git a/proxysql-cluster/templates/secret.yaml b/proxysql-cluster/templates/secret.yaml new file mode 100644 index 0000000..86f6c1c --- /dev/null +++ b/proxysql-cluster/templates/secret.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "proxysql.fullname" . }}-secret + labels: + {{- include "proxysql.labels" . | nindent 4 }} +stringData: + proxysql.cnf: | + {{- tpl .Values.config.template . | nindent 4 }} + ADMIN_PASSWORD: {{ include "proxysql.pwd" .Values.credentials.admin }} + ADMIN_USER: {{ .Values.credentials.admin.user }} + RADMIN_PASSWORD: {{ include "proxysql.pwd" .Values.credentials.radmin }} + RADMIN_USER: {{ .Values.credentials.radmin.user }} diff --git a/proxysql-cluster/values.yaml b/proxysql-cluster/values.yaml index eb85767..3eafbc0 100644 --- a/proxysql-cluster/values.yaml +++ b/proxysql-cluster/values.yaml @@ -17,6 +17,123 @@ service: type: ClusterIP port: 6033 +secretEnvs: ["ADMIN_USER", "ADMIN_PASSWORD", "RADMIN_USER", "RADMIN_PASSWORD"] + +credentials: + admin: + user: admin + #if blank a random password is created + password: "" + + radmin: + user: radmin + #if blank a random password is created + password: "" + +eventsLog: + enabled: false + directory: /var/log/proxysql/eventslog/ + filename: queries + tailer: + # sidecar for outputting query log, hopefully made redundant by + # https://github.com/sysown/proxysql/issues/3805 + enabled: false + image: + repository: "rickw/debian-exim-send" + tag: "latest" + pullPolicy: "IfNotPresent" + resources: {} + # limits: + # cpu: 10m + # memory: 10Mi + # requests: + # cpu: 5m + # memory: 10Mi + + +mysql: + servers: + - address: '"192.168.0.1"' + port: 3306 + hostgroup: 0 + max_connections: 5000 + - address: '"192.168.1.1"' + users: + - username: '"user"' + password: '"password"' + default_hostgroup: 0 + active: 1 + queryRules: + - rule_id: 1 + active: 1 + match_digest: '"."' + log: 1 + destination_hostgroup: 0 + apply: 1 + variables: + threads: 2 + max_connections: 2048 + default_query_delay: 0 + default_query_timeout: "3600000" + have_compress: true + poll_timeout: 2000 + interfaces: '"0.0.0.0:6033"' + stacksize: "1048576" + server_version: '"8.0.20"' + connect_timeout_server: 3000 + monitor_username: '"user"' + monitor_password: '"password"' + monitor_history: 600000 + monitor_connect_interval: 5000 + monitor_ping_interval: 2000 + monitor_read_only_interval: 1500 + monitor_read_only_timeout: 500 + ping_interval_server_msec: 15000 + ping_timeout_server: 500 + commands_stats: true + sessions_sort: true + connect_retries_on_failure: 10 + + +config: + datadir: /var/lib/proxysql + template: | + datadir="{{ .Values.config.datadir }}" + + admin_variables= + { + admin_credentials="{{ .Values.credentials.admin.user }}:{{ include "proxysql.pwd" .Values.credentials.admin }};{{ .Values.credentials.radmin.user }}:{{ include "proxysql.pwd" .Values.credentials.radmin }}" + mysql_ifaces="0.0.0.0:6032" + } + + mysql_variables= + { + {{ include "proxysql.cfgmapdump" .Values.mysql.variables | nindent 2 }} + + {{- if .Values.eventsLog.enabled }} + eventslog_filename="{{ .Values.eventsLog.directory }}{{ .Values.eventsLog.filename }}" + eventslog_format=2 + {{- end }} + } + + # defines all the MySQL servers + mysql_servers = + ( + {{ include "proxysql.cfglistdump" .Values.mysql.servers | nindent 2 }} + ) + + # defines all the MySQL users + mysql_users: + ( + {{ include "proxysql.cfglistdump" .Values.mysql.users | nindent 2 }} + ) + + #defines MySQL Query Rules + mysql_query_rules: + ( + {{ include "proxysql.cfglistdump" .Values.mysql.queryRules | nindent 2 }} + ) + ingress: enabled: false annotations: {} @@ -48,3 +165,8 @@ nodeSelector: {} tolerations: [] affinity: {} + +securityContext: + enabled: true + fsGroup: 1000 + runAsUser: 1000 From 07ab6308793153ea8a0bd422d61fc67c29164906 Mon Sep 17 00:00:00 2001 From: Asmund Tokheim Date: Fri, 18 Mar 2022 08:59:46 +0100 Subject: [PATCH 2/7] Added logrotation to eventslog Signed-off-by: Asmund Tokheim --- proxysql-cluster/files/cleanlogs.bash | 16 +++++++++++++ proxysql-cluster/templates/configmap.yaml | 4 ++++ proxysql-cluster/templates/deployment.yaml | 26 ++++++++++++++++++++-- proxysql-cluster/values.yaml | 17 ++++++++++++++ 4 files changed, 61 insertions(+), 2 deletions(-) create mode 100755 proxysql-cluster/files/cleanlogs.bash diff --git a/proxysql-cluster/files/cleanlogs.bash b/proxysql-cluster/files/cleanlogs.bash new file mode 100755 index 0000000..de63e0d --- /dev/null +++ b/proxysql-cluster/files/cleanlogs.bash @@ -0,0 +1,16 @@ +#!/bin/bash +set -e + +TAIL_CMD=$(($KEEP_FILES+1)) + +cd $DIR + +while true +do + ls -tp | grep -v '/$' | tail -n +$TAIL_CMD | while read line + do + echo "Removing file $line" + rm $line + done + sleep 5 +done diff --git a/proxysql-cluster/templates/configmap.yaml b/proxysql-cluster/templates/configmap.yaml index ac944f9..742ee99 100644 --- a/proxysql-cluster/templates/configmap.yaml +++ b/proxysql-cluster/templates/configmap.yaml @@ -7,3 +7,7 @@ metadata: data: probe-proxysql.bash: | {{ tpl (.Files.Get "files/probe-proxysql.bash") . | indent 4 }} + {{- if and .Values.eventsLog.enabled .Values.eventsLog.logrotate.enabled }} + cleanlogs.bash: | +{{ tpl (.Files.Get "files/cleanlogs.bash") . | indent 4 }} + {{- end }} diff --git a/proxysql-cluster/templates/deployment.yaml b/proxysql-cluster/templates/deployment.yaml index b0c4ba6..27714d8 100644 --- a/proxysql-cluster/templates/deployment.yaml +++ b/proxysql-cluster/templates/deployment.yaml @@ -39,7 +39,7 @@ spec: containerPort: 6032 protocol: TCP volumeMounts: - - name: probe-config + - name: script-config mountPath: /usr/local/bin/probe-proxysql.bash subPath: probe-proxysql.bash readOnly: true @@ -82,6 +82,28 @@ spec: - name: eventslog mountPath: /logs {{- end }} + {{- if and .Values.eventsLog.enabled .Values.eventsLog.logrotate.enabled }} + - name: "logrotate" + image: "{{ .Values.eventsLog.logrotate.image.repository }}:{{ .Values.eventsLog.logrotate.image.tag }}" + imagePullPolicy: "{{ .Values.eventsLog.logrotate.image.pullPolicy }}" + env: + - name: DIR + value: /logs + - name: KEEP_FILES + value: {{ .Values.eventsLog.logrotate.copies | quote }} + command: + - /bin/sh + - /script/cleanlogs.bash + resources: + {{- toYaml .Values.eventsLog.logrotate.resources | nindent 12 }} + volumeMounts: + - name: eventslog + mountPath: /logs + - name: script-config + mountPath: /script/cleanlogs.bash + subPath: cleanlogs.bash + readOnly: true + {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} @@ -95,7 +117,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} volumes: - - name: probe-config + - name: script-config configMap: name: {{ include "proxysql.fullname" . }}-cm - name: proxy-config diff --git a/proxysql-cluster/values.yaml b/proxysql-cluster/values.yaml index 3eafbc0..f72cede 100644 --- a/proxysql-cluster/values.yaml +++ b/proxysql-cluster/values.yaml @@ -34,6 +34,23 @@ eventsLog: enabled: false directory: /var/log/proxysql/eventslog/ filename: queries + logrotate: + # clean up old logs + enabled: false + copies: 3 + + image: + repository: "alpine" + tag: "3.14.4" + pullPolicy: "IfNotPresent" + resources: {} + # limits: + # cpu: 10m + # memory: 10Mi + # requests: + # cpu: 5m + # memory: 10Mi + tailer: # sidecar for outputting query log, hopefully made redundant by # https://github.com/sysown/proxysql/issues/3805 From 201922751247b6ae3fe74cf3eb0c8f6a307dd5a8 Mon Sep 17 00:00:00 2001 From: Asmund Tokheim Date: Fri, 18 Mar 2022 13:09:06 +0100 Subject: [PATCH 3/7] Added pdb --- proxysql-cluster/values.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/proxysql-cluster/values.yaml b/proxysql-cluster/values.yaml index f72cede..e640b18 100644 --- a/proxysql-cluster/values.yaml +++ b/proxysql-cluster/values.yaml @@ -48,7 +48,7 @@ eventsLog: # cpu: 10m # memory: 10Mi # requests: - # cpu: 5m + # cpu: 3m # memory: 10Mi tailer: @@ -64,7 +64,7 @@ eventsLog: # cpu: 10m # memory: 10Mi # requests: - # cpu: 5m + # cpu: 1m # memory: 10Mi @@ -183,6 +183,8 @@ tolerations: [] affinity: {} +podDisruptionBudget: {} + securityContext: enabled: true fsGroup: 1000 From 264339d12d00442a1ad9c4e0477ef45d743ebe56 Mon Sep 17 00:00:00 2001 From: Asmund Tokheim Date: Fri, 18 Mar 2022 14:18:40 +0100 Subject: [PATCH 4/7] Set up gitlab-pages helm repo, added pdb Signed-off-by: Asmund Tokheim --- .github/workflows/helmrelease.yaml | 33 +++++++++++++++++++ .../proxysql-cluster-controller}/Chart.yaml | 0 .../files/hg-scheduler.bash | 0 .../files/probe-proxysql.bash | 0 .../files/proxysql.cnf | 0 .../templates/NOTES.txt | 0 .../templates/_helpers.tpl | 0 .../templates/configmap.yaml | 0 .../templates/ingress.yaml | 0 .../templates/service.yaml | 0 .../templates/statefulset.yaml | 0 .../templates/storage-class.yaml | 0 .../templates/tests/test-connection.yaml | 0 .../proxysql-cluster-controller}/values.yaml | 0 .../proxysql-cluster-passive}/Chart.yaml | 0 .../files/probe-proxysql.bash | 0 .../files/proxysql.cnf | 0 .../templates/NOTES.txt | 0 .../templates/_helpers.tpl | 0 .../templates/configmap.yaml | 0 .../templates/deployment.yaml | 0 .../templates/ingress.yaml | 0 .../templates/service.yaml | 0 .../templates/tests/test-connection.yaml | 0 .../proxysql-cluster-passive}/values.yaml | 0 .../proxysql-cluster}/.helmignore | 0 .../proxysql-cluster}/Chart.yaml | 0 .../proxysql-cluster}/files/cleanlogs.bash | 0 .../files/probe-proxysql.bash | 0 .../proxysql-cluster}/templates/NOTES.txt | 0 .../proxysql-cluster}/templates/_helpers.tpl | 0 .../templates/configmap.yaml | 0 .../templates/deployment.yaml | 0 .../proxysql-cluster}/templates/ingress.yaml | 0 helm/proxysql-cluster/templates/pdb.yaml | 14 ++++++++ .../proxysql-cluster}/templates/secret.yaml | 0 .../proxysql-cluster}/templates/service.yaml | 0 .../templates/tests/test-connection.yaml | 0 .../proxysql-cluster}/values.yaml | 0 .../proxysql-sidecar-cascade}/Chart.yaml | 0 .../files/probe-proxysql.bash | 0 .../files/proxysql.cnf | 0 .../templates/NOTES.txt | 0 .../templates/_helpers.tpl | 0 .../templates/configmap.yaml | 0 .../templates/deployment.yaml | 0 .../templates/ingress.yaml | 0 .../templates/service.yaml | 0 .../templates/tests/test-connection.yaml | 0 .../proxysql-sidecar-cascade}/values.yaml | 0 50 files changed, 47 insertions(+) create mode 100644 .github/workflows/helmrelease.yaml rename {proxysql-cluster-controller => helm/proxysql-cluster-controller}/Chart.yaml (100%) rename {proxysql-cluster-controller => helm/proxysql-cluster-controller}/files/hg-scheduler.bash (100%) rename {proxysql-cluster-controller => helm/proxysql-cluster-controller}/files/probe-proxysql.bash (100%) rename {proxysql-cluster-controller => helm/proxysql-cluster-controller}/files/proxysql.cnf (100%) rename {proxysql-cluster-controller => helm/proxysql-cluster-controller}/templates/NOTES.txt (100%) rename {proxysql-cluster-controller => helm/proxysql-cluster-controller}/templates/_helpers.tpl (100%) rename {proxysql-cluster-controller => helm/proxysql-cluster-controller}/templates/configmap.yaml (100%) rename {proxysql-cluster-controller => helm/proxysql-cluster-controller}/templates/ingress.yaml (100%) rename {proxysql-cluster-controller => helm/proxysql-cluster-controller}/templates/service.yaml (100%) rename {proxysql-cluster-controller => helm/proxysql-cluster-controller}/templates/statefulset.yaml (100%) rename {proxysql-cluster-controller => helm/proxysql-cluster-controller}/templates/storage-class.yaml (100%) rename {proxysql-cluster-controller => helm/proxysql-cluster-controller}/templates/tests/test-connection.yaml (100%) rename {proxysql-cluster-controller => helm/proxysql-cluster-controller}/values.yaml (100%) rename {proxysql-cluster-passive => helm/proxysql-cluster-passive}/Chart.yaml (100%) rename {proxysql-cluster-passive => helm/proxysql-cluster-passive}/files/probe-proxysql.bash (100%) rename {proxysql-cluster-passive => helm/proxysql-cluster-passive}/files/proxysql.cnf (100%) rename {proxysql-cluster-passive => helm/proxysql-cluster-passive}/templates/NOTES.txt (100%) rename {proxysql-cluster-passive => helm/proxysql-cluster-passive}/templates/_helpers.tpl (100%) rename {proxysql-cluster-passive => helm/proxysql-cluster-passive}/templates/configmap.yaml (100%) rename {proxysql-cluster-passive => helm/proxysql-cluster-passive}/templates/deployment.yaml (100%) rename {proxysql-cluster-passive => helm/proxysql-cluster-passive}/templates/ingress.yaml (100%) rename {proxysql-cluster-passive => helm/proxysql-cluster-passive}/templates/service.yaml (100%) rename {proxysql-cluster-passive => helm/proxysql-cluster-passive}/templates/tests/test-connection.yaml (100%) rename {proxysql-cluster-passive => helm/proxysql-cluster-passive}/values.yaml (100%) rename {proxysql-cluster => helm/proxysql-cluster}/.helmignore (100%) rename {proxysql-cluster => helm/proxysql-cluster}/Chart.yaml (100%) rename {proxysql-cluster => helm/proxysql-cluster}/files/cleanlogs.bash (100%) rename {proxysql-cluster => helm/proxysql-cluster}/files/probe-proxysql.bash (100%) rename {proxysql-cluster => helm/proxysql-cluster}/templates/NOTES.txt (100%) rename {proxysql-cluster => helm/proxysql-cluster}/templates/_helpers.tpl (100%) rename {proxysql-cluster => helm/proxysql-cluster}/templates/configmap.yaml (100%) rename {proxysql-cluster => helm/proxysql-cluster}/templates/deployment.yaml (100%) rename {proxysql-cluster => helm/proxysql-cluster}/templates/ingress.yaml (100%) create mode 100644 helm/proxysql-cluster/templates/pdb.yaml rename {proxysql-cluster => helm/proxysql-cluster}/templates/secret.yaml (100%) rename {proxysql-cluster => helm/proxysql-cluster}/templates/service.yaml (100%) rename {proxysql-cluster => helm/proxysql-cluster}/templates/tests/test-connection.yaml (100%) rename {proxysql-cluster => helm/proxysql-cluster}/values.yaml (100%) rename {proxysql-sidecar-cascade => helm/proxysql-sidecar-cascade}/Chart.yaml (100%) rename {proxysql-sidecar-cascade => helm/proxysql-sidecar-cascade}/files/probe-proxysql.bash (100%) rename {proxysql-sidecar-cascade => helm/proxysql-sidecar-cascade}/files/proxysql.cnf (100%) rename {proxysql-sidecar-cascade => helm/proxysql-sidecar-cascade}/templates/NOTES.txt (100%) rename {proxysql-sidecar-cascade => helm/proxysql-sidecar-cascade}/templates/_helpers.tpl (100%) rename {proxysql-sidecar-cascade => helm/proxysql-sidecar-cascade}/templates/configmap.yaml (100%) rename {proxysql-sidecar-cascade => helm/proxysql-sidecar-cascade}/templates/deployment.yaml (100%) rename {proxysql-sidecar-cascade => helm/proxysql-sidecar-cascade}/templates/ingress.yaml (100%) rename {proxysql-sidecar-cascade => helm/proxysql-sidecar-cascade}/templates/service.yaml (100%) rename {proxysql-sidecar-cascade => helm/proxysql-sidecar-cascade}/templates/tests/test-connection.yaml (100%) rename {proxysql-sidecar-cascade => helm/proxysql-sidecar-cascade}/values.yaml (100%) diff --git a/.github/workflows/helmrelease.yaml b/.github/workflows/helmrelease.yaml new file mode 100644 index 0000000..1906416 --- /dev/null +++ b/.github/workflows/helmrelease.yaml @@ -0,0 +1,33 @@ +name: Release Charts + +on: + push: + - cfg-template + paths: + - "helm/**" + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Install Helm + uses: azure/setup-helm@v2.0 + with: + version: v3.7.1 + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.3.0 + with: + charts_dir: deploy/kubernetes/helm + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/proxysql-cluster-controller/Chart.yaml b/helm/proxysql-cluster-controller/Chart.yaml similarity index 100% rename from proxysql-cluster-controller/Chart.yaml rename to helm/proxysql-cluster-controller/Chart.yaml diff --git a/proxysql-cluster-controller/files/hg-scheduler.bash b/helm/proxysql-cluster-controller/files/hg-scheduler.bash similarity index 100% rename from proxysql-cluster-controller/files/hg-scheduler.bash rename to helm/proxysql-cluster-controller/files/hg-scheduler.bash diff --git a/proxysql-cluster-controller/files/probe-proxysql.bash b/helm/proxysql-cluster-controller/files/probe-proxysql.bash similarity index 100% rename from proxysql-cluster-controller/files/probe-proxysql.bash rename to helm/proxysql-cluster-controller/files/probe-proxysql.bash diff --git a/proxysql-cluster-controller/files/proxysql.cnf b/helm/proxysql-cluster-controller/files/proxysql.cnf similarity index 100% rename from proxysql-cluster-controller/files/proxysql.cnf rename to helm/proxysql-cluster-controller/files/proxysql.cnf diff --git a/proxysql-cluster-controller/templates/NOTES.txt b/helm/proxysql-cluster-controller/templates/NOTES.txt similarity index 100% rename from proxysql-cluster-controller/templates/NOTES.txt rename to helm/proxysql-cluster-controller/templates/NOTES.txt diff --git a/proxysql-cluster-controller/templates/_helpers.tpl b/helm/proxysql-cluster-controller/templates/_helpers.tpl similarity index 100% rename from proxysql-cluster-controller/templates/_helpers.tpl rename to helm/proxysql-cluster-controller/templates/_helpers.tpl diff --git a/proxysql-cluster-controller/templates/configmap.yaml b/helm/proxysql-cluster-controller/templates/configmap.yaml similarity index 100% rename from proxysql-cluster-controller/templates/configmap.yaml rename to helm/proxysql-cluster-controller/templates/configmap.yaml diff --git a/proxysql-cluster-controller/templates/ingress.yaml b/helm/proxysql-cluster-controller/templates/ingress.yaml similarity index 100% rename from proxysql-cluster-controller/templates/ingress.yaml rename to helm/proxysql-cluster-controller/templates/ingress.yaml diff --git a/proxysql-cluster-controller/templates/service.yaml b/helm/proxysql-cluster-controller/templates/service.yaml similarity index 100% rename from proxysql-cluster-controller/templates/service.yaml rename to helm/proxysql-cluster-controller/templates/service.yaml diff --git a/proxysql-cluster-controller/templates/statefulset.yaml b/helm/proxysql-cluster-controller/templates/statefulset.yaml similarity index 100% rename from proxysql-cluster-controller/templates/statefulset.yaml rename to helm/proxysql-cluster-controller/templates/statefulset.yaml diff --git a/proxysql-cluster-controller/templates/storage-class.yaml b/helm/proxysql-cluster-controller/templates/storage-class.yaml similarity index 100% rename from proxysql-cluster-controller/templates/storage-class.yaml rename to helm/proxysql-cluster-controller/templates/storage-class.yaml diff --git a/proxysql-cluster-controller/templates/tests/test-connection.yaml b/helm/proxysql-cluster-controller/templates/tests/test-connection.yaml similarity index 100% rename from proxysql-cluster-controller/templates/tests/test-connection.yaml rename to helm/proxysql-cluster-controller/templates/tests/test-connection.yaml diff --git a/proxysql-cluster-controller/values.yaml b/helm/proxysql-cluster-controller/values.yaml similarity index 100% rename from proxysql-cluster-controller/values.yaml rename to helm/proxysql-cluster-controller/values.yaml diff --git a/proxysql-cluster-passive/Chart.yaml b/helm/proxysql-cluster-passive/Chart.yaml similarity index 100% rename from proxysql-cluster-passive/Chart.yaml rename to helm/proxysql-cluster-passive/Chart.yaml diff --git a/proxysql-cluster-passive/files/probe-proxysql.bash b/helm/proxysql-cluster-passive/files/probe-proxysql.bash similarity index 100% rename from proxysql-cluster-passive/files/probe-proxysql.bash rename to helm/proxysql-cluster-passive/files/probe-proxysql.bash diff --git a/proxysql-cluster-passive/files/proxysql.cnf b/helm/proxysql-cluster-passive/files/proxysql.cnf similarity index 100% rename from proxysql-cluster-passive/files/proxysql.cnf rename to helm/proxysql-cluster-passive/files/proxysql.cnf diff --git a/proxysql-cluster-passive/templates/NOTES.txt b/helm/proxysql-cluster-passive/templates/NOTES.txt similarity index 100% rename from proxysql-cluster-passive/templates/NOTES.txt rename to helm/proxysql-cluster-passive/templates/NOTES.txt diff --git a/proxysql-cluster-passive/templates/_helpers.tpl b/helm/proxysql-cluster-passive/templates/_helpers.tpl similarity index 100% rename from proxysql-cluster-passive/templates/_helpers.tpl rename to helm/proxysql-cluster-passive/templates/_helpers.tpl diff --git a/proxysql-cluster-passive/templates/configmap.yaml b/helm/proxysql-cluster-passive/templates/configmap.yaml similarity index 100% rename from proxysql-cluster-passive/templates/configmap.yaml rename to helm/proxysql-cluster-passive/templates/configmap.yaml diff --git a/proxysql-cluster-passive/templates/deployment.yaml b/helm/proxysql-cluster-passive/templates/deployment.yaml similarity index 100% rename from proxysql-cluster-passive/templates/deployment.yaml rename to helm/proxysql-cluster-passive/templates/deployment.yaml diff --git a/proxysql-cluster-passive/templates/ingress.yaml b/helm/proxysql-cluster-passive/templates/ingress.yaml similarity index 100% rename from proxysql-cluster-passive/templates/ingress.yaml rename to helm/proxysql-cluster-passive/templates/ingress.yaml diff --git a/proxysql-cluster-passive/templates/service.yaml b/helm/proxysql-cluster-passive/templates/service.yaml similarity index 100% rename from proxysql-cluster-passive/templates/service.yaml rename to helm/proxysql-cluster-passive/templates/service.yaml diff --git a/proxysql-cluster-passive/templates/tests/test-connection.yaml b/helm/proxysql-cluster-passive/templates/tests/test-connection.yaml similarity index 100% rename from proxysql-cluster-passive/templates/tests/test-connection.yaml rename to helm/proxysql-cluster-passive/templates/tests/test-connection.yaml diff --git a/proxysql-cluster-passive/values.yaml b/helm/proxysql-cluster-passive/values.yaml similarity index 100% rename from proxysql-cluster-passive/values.yaml rename to helm/proxysql-cluster-passive/values.yaml diff --git a/proxysql-cluster/.helmignore b/helm/proxysql-cluster/.helmignore similarity index 100% rename from proxysql-cluster/.helmignore rename to helm/proxysql-cluster/.helmignore diff --git a/proxysql-cluster/Chart.yaml b/helm/proxysql-cluster/Chart.yaml similarity index 100% rename from proxysql-cluster/Chart.yaml rename to helm/proxysql-cluster/Chart.yaml diff --git a/proxysql-cluster/files/cleanlogs.bash b/helm/proxysql-cluster/files/cleanlogs.bash similarity index 100% rename from proxysql-cluster/files/cleanlogs.bash rename to helm/proxysql-cluster/files/cleanlogs.bash diff --git a/proxysql-cluster/files/probe-proxysql.bash b/helm/proxysql-cluster/files/probe-proxysql.bash similarity index 100% rename from proxysql-cluster/files/probe-proxysql.bash rename to helm/proxysql-cluster/files/probe-proxysql.bash diff --git a/proxysql-cluster/templates/NOTES.txt b/helm/proxysql-cluster/templates/NOTES.txt similarity index 100% rename from proxysql-cluster/templates/NOTES.txt rename to helm/proxysql-cluster/templates/NOTES.txt diff --git a/proxysql-cluster/templates/_helpers.tpl b/helm/proxysql-cluster/templates/_helpers.tpl similarity index 100% rename from proxysql-cluster/templates/_helpers.tpl rename to helm/proxysql-cluster/templates/_helpers.tpl diff --git a/proxysql-cluster/templates/configmap.yaml b/helm/proxysql-cluster/templates/configmap.yaml similarity index 100% rename from proxysql-cluster/templates/configmap.yaml rename to helm/proxysql-cluster/templates/configmap.yaml diff --git a/proxysql-cluster/templates/deployment.yaml b/helm/proxysql-cluster/templates/deployment.yaml similarity index 100% rename from proxysql-cluster/templates/deployment.yaml rename to helm/proxysql-cluster/templates/deployment.yaml diff --git a/proxysql-cluster/templates/ingress.yaml b/helm/proxysql-cluster/templates/ingress.yaml similarity index 100% rename from proxysql-cluster/templates/ingress.yaml rename to helm/proxysql-cluster/templates/ingress.yaml diff --git a/helm/proxysql-cluster/templates/pdb.yaml b/helm/proxysql-cluster/templates/pdb.yaml new file mode 100644 index 0000000..392b23e --- /dev/null +++ b/helm/proxysql-cluster/templates/pdb.yaml @@ -0,0 +1,14 @@ +{{- if .Values.podDisruptionBudget -}} +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: {{ include "proxysql.fullname" . }} + labels: + {{- include "proxysql.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + app.kubernetes.io/name: {{ include "proxysql.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + {{ toYaml .Values.podDisruptionBudget | nindent 2 }} +{{- end -}} diff --git a/proxysql-cluster/templates/secret.yaml b/helm/proxysql-cluster/templates/secret.yaml similarity index 100% rename from proxysql-cluster/templates/secret.yaml rename to helm/proxysql-cluster/templates/secret.yaml diff --git a/proxysql-cluster/templates/service.yaml b/helm/proxysql-cluster/templates/service.yaml similarity index 100% rename from proxysql-cluster/templates/service.yaml rename to helm/proxysql-cluster/templates/service.yaml diff --git a/proxysql-cluster/templates/tests/test-connection.yaml b/helm/proxysql-cluster/templates/tests/test-connection.yaml similarity index 100% rename from proxysql-cluster/templates/tests/test-connection.yaml rename to helm/proxysql-cluster/templates/tests/test-connection.yaml diff --git a/proxysql-cluster/values.yaml b/helm/proxysql-cluster/values.yaml similarity index 100% rename from proxysql-cluster/values.yaml rename to helm/proxysql-cluster/values.yaml diff --git a/proxysql-sidecar-cascade/Chart.yaml b/helm/proxysql-sidecar-cascade/Chart.yaml similarity index 100% rename from proxysql-sidecar-cascade/Chart.yaml rename to helm/proxysql-sidecar-cascade/Chart.yaml diff --git a/proxysql-sidecar-cascade/files/probe-proxysql.bash b/helm/proxysql-sidecar-cascade/files/probe-proxysql.bash similarity index 100% rename from proxysql-sidecar-cascade/files/probe-proxysql.bash rename to helm/proxysql-sidecar-cascade/files/probe-proxysql.bash diff --git a/proxysql-sidecar-cascade/files/proxysql.cnf b/helm/proxysql-sidecar-cascade/files/proxysql.cnf similarity index 100% rename from proxysql-sidecar-cascade/files/proxysql.cnf rename to helm/proxysql-sidecar-cascade/files/proxysql.cnf diff --git a/proxysql-sidecar-cascade/templates/NOTES.txt b/helm/proxysql-sidecar-cascade/templates/NOTES.txt similarity index 100% rename from proxysql-sidecar-cascade/templates/NOTES.txt rename to helm/proxysql-sidecar-cascade/templates/NOTES.txt diff --git a/proxysql-sidecar-cascade/templates/_helpers.tpl b/helm/proxysql-sidecar-cascade/templates/_helpers.tpl similarity index 100% rename from proxysql-sidecar-cascade/templates/_helpers.tpl rename to helm/proxysql-sidecar-cascade/templates/_helpers.tpl diff --git a/proxysql-sidecar-cascade/templates/configmap.yaml b/helm/proxysql-sidecar-cascade/templates/configmap.yaml similarity index 100% rename from proxysql-sidecar-cascade/templates/configmap.yaml rename to helm/proxysql-sidecar-cascade/templates/configmap.yaml diff --git a/proxysql-sidecar-cascade/templates/deployment.yaml b/helm/proxysql-sidecar-cascade/templates/deployment.yaml similarity index 100% rename from proxysql-sidecar-cascade/templates/deployment.yaml rename to helm/proxysql-sidecar-cascade/templates/deployment.yaml diff --git a/proxysql-sidecar-cascade/templates/ingress.yaml b/helm/proxysql-sidecar-cascade/templates/ingress.yaml similarity index 100% rename from proxysql-sidecar-cascade/templates/ingress.yaml rename to helm/proxysql-sidecar-cascade/templates/ingress.yaml diff --git a/proxysql-sidecar-cascade/templates/service.yaml b/helm/proxysql-sidecar-cascade/templates/service.yaml similarity index 100% rename from proxysql-sidecar-cascade/templates/service.yaml rename to helm/proxysql-sidecar-cascade/templates/service.yaml diff --git a/proxysql-sidecar-cascade/templates/tests/test-connection.yaml b/helm/proxysql-sidecar-cascade/templates/tests/test-connection.yaml similarity index 100% rename from proxysql-sidecar-cascade/templates/tests/test-connection.yaml rename to helm/proxysql-sidecar-cascade/templates/tests/test-connection.yaml diff --git a/proxysql-sidecar-cascade/values.yaml b/helm/proxysql-sidecar-cascade/values.yaml similarity index 100% rename from proxysql-sidecar-cascade/values.yaml rename to helm/proxysql-sidecar-cascade/values.yaml From df6317a2f86022b17d7c752fa10de303bc2bf3df Mon Sep 17 00:00:00 2001 From: Asmund Tokheim Date: Fri, 18 Mar 2022 14:26:29 +0100 Subject: [PATCH 5/7] Fix action yaml --- .github/workflows/helmrelease.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/helmrelease.yaml b/.github/workflows/helmrelease.yaml index 1906416..390b04b 100644 --- a/.github/workflows/helmrelease.yaml +++ b/.github/workflows/helmrelease.yaml @@ -2,9 +2,10 @@ name: Release Charts on: push: - - cfg-template - paths: - - "helm/**" + branches: + - cfg-template + paths: + - "helm/**" jobs: release: From 8a30165ee62eb0d893b3f3b67bfe2609b92cdfd6 Mon Sep 17 00:00:00 2001 From: Asmund Tokheim Date: Fri, 18 Mar 2022 14:30:48 +0100 Subject: [PATCH 6/7] bump chart version to trigger release --- helm/proxysql-cluster/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/proxysql-cluster/Chart.yaml b/helm/proxysql-cluster/Chart.yaml index a7151c9..6339fdc 100644 --- a/helm/proxysql-cluster/Chart.yaml +++ b/helm/proxysql-cluster/Chart.yaml @@ -2,4 +2,4 @@ apiVersion: v1 appVersion: "1.0" description: A Helm chart to deploy ProxySQL on Kubernetes name: proxysql -version: 0.1.0 +version: 0.2.0 From ebb3b9d0a4b47895896fc9f717888f7522088344 Mon Sep 17 00:00:00 2001 From: Asmund Tokheim Date: Fri, 18 Mar 2022 14:33:10 +0100 Subject: [PATCH 7/7] Fix config folder, bump for release --- .github/workflows/helmrelease.yaml | 2 +- helm/proxysql-cluster/Chart.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/helmrelease.yaml b/.github/workflows/helmrelease.yaml index 390b04b..496432d 100644 --- a/.github/workflows/helmrelease.yaml +++ b/.github/workflows/helmrelease.yaml @@ -29,6 +29,6 @@ jobs: - name: Run chart-releaser uses: helm/chart-releaser-action@v1.3.0 with: - charts_dir: deploy/kubernetes/helm + charts_dir: helm env: CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/helm/proxysql-cluster/Chart.yaml b/helm/proxysql-cluster/Chart.yaml index 6339fdc..c960f0d 100644 --- a/helm/proxysql-cluster/Chart.yaml +++ b/helm/proxysql-cluster/Chart.yaml @@ -2,4 +2,4 @@ apiVersion: v1 appVersion: "1.0" description: A Helm chart to deploy ProxySQL on Kubernetes name: proxysql -version: 0.2.0 +version: 0.2.1