Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[proxysql-cluster] Change suggestion to work more as normal charts #3

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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 "[email protected]"

- name: Install Helm
uses: azure/[email protected]
with:
version: v3.7.1

- name: Run chart-releaser
uses: helm/[email protected]
with:
charts_dir: helm
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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
@@ -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")
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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 }}
File renamed without changes.
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 }}
File renamed without changes.
191 changes: 191 additions & 0 deletions helm/proxysql-cluster/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
# Default values for proxysql.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 2

image:
repository: pondix/proxysqlk8s
tag: 2.0.10
pullPolicy: IfNotPresent

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

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
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: 3m
# memory: 10Mi

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: 1m
# 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: {}
# kubernetes.io/ingress.class: proxysql
# kubernetes.io/tls-acme: "true"
hosts:
- host: 10.18.120.41
paths: []

tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 1024Mi
# requests:
# cpu: 100m
# memory: 1024Mi

nodeSelector: {}

tolerations: []

affinity: {}

podDisruptionBudget: {}

securityContext:
enabled: true
fsGroup: 1000
runAsUser: 1000
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
84 changes: 0 additions & 84 deletions proxysql-cluster/files/proxysql.cnf

This file was deleted.

64 changes: 0 additions & 64 deletions proxysql-cluster/templates/deployment.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions proxysql-sidecar-cascade/templates/configmap.yaml

This file was deleted.

50 changes: 0 additions & 50 deletions proxysql-sidecar-cascade/values.yaml

This file was deleted.