Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/helmrelease.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release Charts

on:
push:
branches:
- 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: helm
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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.1
16 changes: 16 additions & 0 deletions helm/proxysql-cluster/files/cleanlogs.bash
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
13 changes: 13 additions & 0 deletions helm/proxysql-cluster/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "proxysql.fullname" . }}-cm
labels:
{{- include "proxysql.labels" . | nindent 4 }}
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 }}
131 changes: 131 additions & 0 deletions helm/proxysql-cluster/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{{- $root := . }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "proxysql.fullname" . }}
labels:
{{ include "proxysql.labels" . | indent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "proxysql.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
{{ 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 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: proxysql
containerPort: 6033
protocol: TCP
- name: admin
containerPort: 6032
protocol: TCP
volumeMounts:
- name: script-config
mountPath: /usr/local/bin/probe-proxysql.bash
subPath: probe-proxysql.bash
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"]
readinessProbe:
exec:
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 }}
{{- 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 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: script-config
configMap:
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 }}
14 changes: 14 additions & 0 deletions helm/proxysql-cluster/templates/pdb.yaml
Original file line number Diff line number Diff line change
@@ -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 -}}
13 changes: 13 additions & 0 deletions helm/proxysql-cluster/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
Loading