Add proxysql

This commit is contained in:
Micke Nordin 2023-03-27 14:13:32 +02:00
parent 87f0b617cd
commit 82bda1443d
Signed by untrusted user: Micke
GPG key ID: 0DA0A7A5708FE257
14 changed files with 882 additions and 34 deletions

View file

@ -1,11 +0,0 @@
---
apiVersion: v1
kind: Service
metadata:
name: multinode-db
namespace: nextcloud
spec:
type: ExternalName
externalName: multinode-db1.drive.test.sunet.se
ports:
- port: 3306

View file

@ -1,11 +0,0 @@
---
apiVersion: v1
kind: Service
metadata:
name: multinode-db
namespace: nextcloud
spec:
type: ExternalName
externalName: multinode-db2.drive.test.sunet.se
ports:
- port: 3306

View file

@ -1,11 +0,0 @@
---
apiVersion: v1
kind: Service
metadata:
name: multinode-db
namespace: nextcloud
spec:
type: ExternalName
externalName: multinode-db3.drive.test.sunet.se
ports:
- port: 3306

View file

@ -1,5 +1,4 @@
resources:
- db-service.yml
- nextcloud-deployment.yml
- nextcloud-ingress.yml
- nextcloud-namespace.yml

View file

@ -0,0 +1,6 @@
resources:
- proxysql-configmap.yml
- proxysql-db-service.yml
- proxysql-deployment.yml
- proxysql-namespace.yml
- proxysql-service.yml

View file

@ -0,0 +1,408 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: proxysql-configmap
namespace: proxysql
data:
proxysql.cnf: |
datadir="/var/lib/proxysql"
admin_variables=
{
admin_credentials="admin:{{ADMIN_PASSWORD}};cluster:{{CLUSTER_PASSWORD}}"
mysql_ifaces="0.0.0.0:6032"
refresh_interval=2000
cluster_username="cluster"
cluster_password="{{CLUSTER_PASSWORD}}"
}
mysql_variables=
{
threads=4
max_connections=2048
default_query_delay=0
default_query_timeout=36000000
have_compress=true
poll_timeout=2000
interfaces="0.0.0.0:6033;/tmp/proxysql.sock"
default_schema="information_schema"
stacksize=1048576
server_version="8.0.23"
connect_timeout_server=3000
monitor_username="proxysql"
monitor_password="{{MONITOR_PASSWORD}}"
monitor_history=600000
monitor_connect_interval=60000
monitor_ping_interval=10000
monitor_read_only_interval=1500
monitor_read_only_timeout=500
ping_interval_server_msec=120000
ping_timeout_server=500
commands_stats=true
sessions_sort=true
connect_retries_on_failure=10
}
mysql_galera_hostgroups =
(
{
writer_hostgroup=10
backup_writer_hostgroup=20
reader_hostgroup=30
offline_hostgroup=9999
max_writers=1
writer_is_also_reader=2
max_transactions_behind=30
active=1
}
)
mysql_query_rules =
(
{
rule_id=100
active=1
match_pattern="^SELECT .* FOR UPDATE"
destination_hostgroup=10
apply=1
},
{
rule_id=200
active=1
match_pattern="^SELECT .*"
destination_hostgroup=30
apply=1
},
{
rule_id=300
active=1
match_pattern=".*"
destination_hostgroup=10
apply=1
}
)
mysql_servers =
(
{ address="multinode-db1" , port=3306 , hostgroup=10, max_connections=100 },
{ address="multinode-db2" , port=3306 , hostgroup=20, max_connections=100 },
{ address="multinode-db3" , port=3306 , hostgroup=30, max_connections=100 }
)
mysql_users =
(
{
username="nextcloud_antagning"
password="{{ANTAGNING_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_bth"
password="{{BTH_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_chalmers"
password="{{CHALMERS_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_du"
password="{{DU_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_esh"
password="{{ESH_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_fhs"
password="{{FHS_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_gu"
password="{{GU_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_hb"
password="{{HB_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_hhs"
password="{{HHS_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_hig"
password="{{HIG_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_his"
password="{{HIS_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_hj"
password="{{HJ_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_hv"
password="{{HV_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_irf"
password="{{IRF_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_kb"
password="{{KB_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_ki"
password="{{KI_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_kkh"
password="{{KKH_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_kmh"
password="{{KMH_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_konstfack"
password="{{KONSTFACK_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_kth"
password="{{KTH_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_kva"
password="{{KVA_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_liu"
password="{{LIU_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_lnu"
password="{{LNU_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_ltu"
password="{{LTU_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_lu"
password="{{LU_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_mau"
password="{{MAU_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_miun"
password="{{MIUN_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_nordunet"
password="{{NORDUNET_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_nrm"
password="{{NRM_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_oru"
password="{{ORU_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_rkh"
password="{{RKH_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_shh"
password="{{SHH_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_sics"
password="{{SICS_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_slu"
password="{{SLU_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_smhi"
password="{{SMHI_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_sp"
password="{{SP_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_swamid"
password="{{SWAMID_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_ths"
password="{{THS_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_uhr"
password="{{UHR_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_umu"
password="{{UMU_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_uniarts"
password="{{UNIARTS_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_uu"
password="{{UU_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_vinnova"
password="{{VINNOVA_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
{
username="nextcloud_vr"
password="{{VR_PASSWORD}}"
default_hostgroup=10
transaction_persistent=1
active=1
},
)
proxysql_servers =
(
{ hostname = "proxysql-0.proxysqlcluster", port = 6032, weight = 1 },
{ hostname = "proxysql-1.proxysqlcluster", port = 6032, weight = 1 },
{ hostname = "proxysql-2.proxysqlcluster", port = 6032, weight = 1 }
)

View file

@ -0,0 +1,33 @@
---
apiVersion: v1
kind: Service
metadata:
name: multinode-db1
namespace: proxysql
spec:
type: ExternalName
externalName: multinode-db1.drive.test.sunet.se
ports:
- port: 3306
---
apiVersion: v1
kind: Service
metadata:
name: multinode-db2
namespace: proxysql
spec:
type: ExternalName
externalName: multinode-db2.drive.test.sunet.se
ports:
- port: 3306
---
apiVersion: v1
kind: Service
metadata:
name: multinode-db3
namespace: proxysql
spec:
type: ExternalName
externalName: multinode-db3.drive.test.sunet.se
ports:
- port: 3306

View file

@ -0,0 +1,312 @@
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: proxysql
namespace: proxysql
labels:
app: proxysql
spec:
replicas: 3
serviceName: proxysqlcluster
selector:
matchLabels:
app: proxysql
updateStrategy:
type: RollingUpdate
volumeClaimTemplates:
- metadata:
name: proxysql-data
namespace: proxysql
spec:
storageClassName: openebs-jiva-3repl
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
- metadata:
name: proxysql-etc
namespace: proxysql
spec:
storageClassName: openebs-jiva-3repl
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
template:
metadata:
labels:
app: proxysql
spec:
restartPolicy: Always
containers:
- image: proxysql/proxysql:2.3.1
name: proxysql
volumeMounts:
- name: proxysql-data
mountPath: /var/lib/proxysql
subPath: data
- name: proxysql-etc
mountPath: /etc
subPath: etc
ports:
- containerPort: 6033
name: proxysql-mysql
- containerPort: 6032
name: proxysql-admin
initContainers:
- image: docker.sunet.se/sunet/docker-jinja:latest
name: init-config
volumeMounts:
- name: proxysql-config-template
mountPath: /tmp/proxysql.cnf.template
subPath: proxysql.cnf
- name: proxysql-etc
mountPath: /etc
subPath: etc
env:
- name: ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_admin_password"
- name: CLUSTER_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_cluster_password"
- name: MONITOR_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_monitor_password"
- name: ANTAGNING_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_antagning_password"
- name: BTH_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_bth_password"
- name: CHALMERS_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_chalmers_password"
- name: DU_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_du_password"
- name: ESH_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_esh_password"
- name: FHS_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_fhs_password"
- name: GU_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_gu_password"
- name: HB_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_hb_password"
- name: HHS_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_hhs_password"
- name: HIG_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_hig_password"
- name: HIS_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_his_password"
- name: HJ_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_hj_password"
- name: HV_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_hv_password"
- name: IRF_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_irf_password"
- name: KB_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_kb_password"
- name: KI_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_ki_password"
- name: KKH_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_kkh_password"
- name: KMH_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_kmh_password"
- name: KONSTFACK_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_konstfack_password"
- name: KTH_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_kth_password"
- name: KVA_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_kva_password"
- name: LIU_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_liu_password"
- name: LNU_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_lnu_password"
- name: LTU_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_ltu_password"
- name: LU_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_lu_password"
- name: MAU_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_mau_password"
- name: MIUN_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_miun_password"
- name: NORDUNET_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_nordunet_password"
- name: NRM_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_nrm_password"
- name: ORU_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_oru_password"
- name: RKH_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_rkh_password"
- name: SHH_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_shh_password"
- name: SICS_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_sics_password"
- name: SLU_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_slu_password"
- name: SMHI_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_smhi_password"
- name: SP_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_sp_password"
- name: SWAMID_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_swamid_password"
- name: THS_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_ths_password"
- name: UHR_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_uhr_password"
- name: UMU_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_umu_password"
- name: UNIARTS_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_uniarts_password"
- name: UU_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_uu_password"
- name: VINNOVA_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_vinnova_password"
- name: VR_PASSWORD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_vr_password"
command: ["/bin/sh", "-c", "/usr/bin/j2 -f env -o /etc/proxysql.cnf /tmp/proxysql.cnf.template"]
volumes:
- name: proxysql-config-template
configMap:
name: proxysql-configmap
items:
- key: "proxysql.cnf"
path: "proxysql.cnf"

View file

@ -0,0 +1,7 @@
apiVersion: v1
kind: Namespace
metadata:
name: proxysql
spec:
finalizers:
- kubernetes

View file

@ -0,0 +1,38 @@
apiVersion: v1
kind: Service
metadata:
annotations:
labels:
app: proxysql
name: proxysql
namespace: proxysql
spec:
ports:
- name: proxysql-mysql
nodePort: 30033
port: 6033
protocol: TCP
targetPort: 6033
- name: proxysql-admin
nodePort: 30032
port: 6032
protocol: TCP
targetPort: 6032
selector:
app: proxysql
type: NodePort
---
apiVersion: v1
kind: Service
metadata:
name: proxysqlcluster
namespace: proxysql
labels:
app: proxysql
spec:
clusterIP: None
ports:
- port: 6032
name: proxysql-admin
selector:
app: proxysql

View file

@ -0,0 +1,6 @@
apiVersion: 'kustomize.config.k8s.io/v1beta1'
kind: Kustomization
bases:
- ../../base
patchesStrategicMerge:
- proxysql-db-service.yml

View file

@ -0,0 +1,33 @@
---
apiVersion: v1
kind: Service
metadata:
name: multinode-db1
namespace: proxysql
spec:
type: ExternalName
externalName: multinode-db1.drive.test.sunet.se
ports:
- port: 3306
---
apiVersion: v1
kind: Service
metadata:
name: multinode-db2
namespace: proxysql
spec:
type: ExternalName
externalName: multinode-db2.drive.test.sunet.se
ports:
- port: 3306
---
apiVersion: v1
kind: Service
metadata:
name: multinode-db3
namespace: proxysql
spec:
type: ExternalName
externalName: multinode-db3.drive.test.sunet.se
ports:
- port: 3306

View file

@ -0,0 +1,6 @@
apiVersion: 'kustomize.config.k8s.io/v1beta1'
kind: Kustomization
bases:
- ../../base
patchesStrategicMerge:
- proxysql-db-service.yml

View file

@ -0,0 +1,33 @@
---
apiVersion: v1
kind: Service
metadata:
name: multinode-db1
namespace: proxysql
spec:
type: ExternalName
externalName: multinode-db1.drive.test.sunet.se
ports:
- port: 3306
---
apiVersion: v1
kind: Service
metadata:
name: multinode-db2
namespace: proxysql
spec:
type: ExternalName
externalName: multinode-db2.drive.test.sunet.se
ports:
- port: 3306
---
apiVersion: v1
kind: Service
metadata:
name: multinode-db3
namespace: proxysql
spec:
type: ExternalName
externalName: multinode-db3.drive.test.sunet.se
ports:
- port: 3306