This commit is contained in:
Andrei Kvapil
2024-02-06 09:34:01 +01:00
parent 8811cdbb0b
commit 67b1e56916
5 changed files with 19 additions and 150 deletions

View File

@@ -1,29 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-secondary-haproxy
labels:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
data:
haproxy.cfg: |
global
maxconn 2048
defaults
mode tcp
option dontlognull
timeout queue 20s
timeout connect 1s
timeout client 3s
timeout server 10s
timeout check 2s
frontend mysql
bind :::3306 v4v6
default_backend mysql_backend
backend mysql_backend
balance roundrobin
default-server observe layer4 error-limit 3 on-error mark-down
server secondary {{ .Release.Name }}-secondary:3306 check
server backup {{ .Release.Name }}:3306 backup

View File

@@ -1,67 +0,0 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-secondary-haproxy
labels:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
# TODO
# There is an issue with 'externalTraficPolicy: Local' and VMs accessing externalIP services from
# internal network, trafic is not routed due to fact their hipervisor have no local workload running
# Current workaround that all the nodes of parnet cluster must have at least one replica per node
# which are running the virtual machnes of child cluster.
# Consider moving to KubeVirt so all local VMs will get local identities, so internalTrafficPolicy will
# considered for them instead of externalTraficPolicy
replicas: 2
selector:
matchLabels:
app: {{ .Release.Name }}-secondary-haproxy
template:
metadata:
labels:
app: {{ .Release.Name }}-secondary-haproxy
annotations:
checksum/config: {{ include (print $.Template.BasePath "/haproxy/configmap.yaml") . | sha256sum }}
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/instance
operator: In
values:
- {{ .Release.Name }}
- key: app.kubernetes.io/name
operator: In
values:
- mariadb
topologyKey: kubernetes.io/hostname
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- {{ .Release.Name }}-secondary-haproxy
topologyKey: kubernetes.io/hostname
containers:
- image: haproxy:latest
name: haproxy
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- mountPath: /usr/local/etc/haproxy
name: config
volumes:
- configMap:
name: {{ .Release.Name }}-secondary-haproxy
name: config

View File

@@ -1,23 +0,0 @@
---
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-secondary-haproxy
labels:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
annotations:
metallb.universe.tf/address-pool: {{ .Values.secondaryService2.ipPool }}
metallb.universe.tf/ip-allocated-from-pool: {{ .Values.secondaryService2.ipPool }}
metallb.universe.tf/loadBalancerIPs: {{ .Values.secondaryService2.ipAddress }}
spec:
type: LoadBalancer
externalTrafficPolicy: Local
allocateLoadBalancerNodePorts: false
selector:
app: {{ .Release.Name }}-secondary-haproxy
ports:
- name: mysql
protocol: TCP
port: 3306
targetPort: mysql

View File

@@ -54,21 +54,18 @@ spec:
key: config
volumeClaimTemplate:
{{- toYaml .Values.volumeClaimTemplate | nindent 4 }}
resources:
requests:
storage: {{ .Values.size }}
accessModes:
- ReadWriteOnce
# All possible annotations must be included in the service
# https://github.com/mariadb-operator/mariadb-operator/issues/256
{{- if .Values.external }}
primaryService:
type: LoadBalancer
annotations:
metallb.universe.tf/address-pool: {{ .Values.primaryService.ipPool }}
metallb.universe.tf/ip-allocated-from-pool: {{ .Values.primaryService.ipPool }}
metallb.universe.tf/loadBalancerIPs: {{ .Values.primaryService.ipAddress }}
{{- end }}
secondaryService:
type: LoadBalancer
annotations:
metallb.universe.tf/address-pool: {{ .Values.secondaryService.ipPool }}
metallb.universe.tf/ip-allocated-from-pool: {{ .Values.secondaryService.ipPool }}
metallb.universe.tf/loadBalancerIPs: {{ .Values.secondaryService.ipAddress }}
#secondaryService:
# type: LoadBalancer

View File

@@ -1,32 +1,23 @@
volumeClaimTemplate:
resources:
requests:
storage: 100Gi
accessModes:
- ReadWriteOnce
primaryService:
ipPool: private-ips
ipAddress: 10.100.255.15
secondaryService:
ipPool: private-ips
ipAddress: 10.100.255.16
secondaryService2:
ipPool: private-ips
ipAddress: 10.100.255.116
external: false
size: 10Gi
users:
root:
password: strongpassword
user1:
privileges: ['ALL']
maxUserConnections: 1000
password: hackme
user2:
privileges: ['SELECT']
maxUserConnections: 1000
password: hackme
databases:
- wordpress1
- wordpress2
- wordpress3
- wordpress4
backup:
enabled: false