Skip to content

Commit 733bc6f

Browse files
committed
(openvpn) deploy mariadb operator
1 parent e8a33c9 commit 733bc6f

File tree

13 files changed

+264
-0
lines changed

13 files changed

+264
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: mariadb-operator
3+
defaultNamespace: &name mariadb-system
4+
namespaceLabels:
5+
lsst.io/discover: "true"
6+
labels:
7+
bundle: *name
8+
helm:
9+
chart: mariadb-operator
10+
releaseName: mariadb-operator
11+
repo: https://helm.mariadb.com/mariadb-operator
12+
version: 0.38.1
13+
waitForJobs: true
14+
timeoutSeconds: 900
15+
values:
16+
crds:
17+
enabled: true
18+
ha:
19+
enabled: true
20+
replicas: 2
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: metallb.io/v1beta1
2+
kind: IPAddressPool
3+
metadata:
4+
name: openvpndb
5+
namespace: metallb-system
6+
spec:
7+
addresses:
8+
- 139.229.144.10/32
9+
autoAssign: false
10+
---
11+
apiVersion: metallb.io/v1beta1
12+
kind: L2Advertisement
13+
metadata:
14+
name: openvpndb
15+
namespace: metallb-system
16+
spec:
17+
ipAddressPools:
18+
- openvpndb
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apiVersion: external-secrets.io/v1
2+
kind: ExternalSecret
3+
metadata:
4+
name: dockerhub-secret
5+
namespace: openvpn-db
6+
spec:
7+
secretStoreRef:
8+
kind: ClusterSecretStore
9+
name: onepassword
10+
target:
11+
name: dockerhub-secret
12+
creationPolicy: Owner
13+
template:
14+
type: kubernetes.io/dockerconfigjson
15+
data:
16+
.dockerconfigjson: |
17+
{
18+
"auths": {
19+
"docker.io": {
20+
"username": "{{ .dockerhub_username }}",
21+
"password": "{{ .dockerhub_token }}",
22+
"auth": "{{ printf "%s:%s" .dockerhub_username .dockerhub_token | b64enc }}"
23+
}
24+
}
25+
}
26+
data:
27+
- secretKey: dockerhub_username
28+
remoteRef:
29+
key: lsstitadmin-docker-hub
30+
property: username
31+
- secretKey: dockerhub_token
32+
remoteRef:
33+
key: lsstitadmin-docker-hub
34+
property: docker hub api token
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: external-secrets.io/v1
2+
kind: ExternalSecret
3+
metadata:
4+
name: mariadb
5+
namespace: openvpn-db
6+
spec:
7+
secretStoreRef:
8+
kind: ClusterSecretStore
9+
name: onepassword
10+
target:
11+
name: mariadb
12+
creationPolicy: Owner
13+
data:
14+
- secretKey: mariadb-root-password
15+
remoteRef:
16+
key: openvpn-mariadb-credentials
17+
property: mariadb-root-password
18+
- secretKey: mariadb-replication-password
19+
remoteRef:
20+
key: openvpn-mariadb-credentials
21+
property: mariadb-replication-password
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
resources:
2+
- external-secret-dockerhub.yaml
3+
- external-secret-openvpndb.yaml
4+
- mariadb-headless-service.yaml
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: mariadb-galera
5+
namespace: openvpn-db
6+
spec:
7+
clusterIP: None
8+
selector:
9+
app.kubernetes.io/name: mariadb
10+
ports:
11+
- protocol: TCP
12+
port: 3306
13+
targetPort: 3306
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
defaultNamespace: openvpn-db
2+
labels:
3+
bundle: openvpn-db-pre
4+
name: openvpn-db-pre
5+
kustomize:
6+
dir: base

fleet/lib/openvpn-db/fleet.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: openvpn-db
2+
defaultNamespace: &name openvpn-db
3+
labels:
4+
bundle: *name
5+
dependsOn:
6+
- name: mariadb-operator
7+
namespace: mariadb-system
8+
- name: openvpn-db-pre
9+
namespace: openvpn-db
10+
targetCustomizations:
11+
- name: ayekan
12+
clusterSelector:
13+
matchExpressions:
14+
- key: management.cattle.io/cluster-display-name
15+
operator: In
16+
values:
17+
- ayekan
18+
kustomize:
19+
dir: overlays/ayekan
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
resources:
2+
- mariadb-cr.yaml
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
apiVersion: k8s.mariadb.com/v1alpha1
2+
kind: MariaDB
3+
metadata:
4+
name: mariadb
5+
namespace: openvpn-db
6+
spec:
7+
replicas: 3
8+
galera:
9+
enabled: true
10+
primary:
11+
podIndex: 0
12+
automaticFailover: true
13+
sst: mariabackup
14+
15+
rootPasswordSecretKeyRef:
16+
name: mariadb
17+
key: mariadb-root-password
18+
username: mariadb
19+
passwordSecretKeyRef:
20+
name: mariadb
21+
key: mariadb-root-password
22+
database: mariadb
23+
24+
image: docker.io/library/mariadb:11.4.5
25+
imagePullPolicy: IfNotPresent
26+
imagePullSecrets:
27+
- name: dockerhub-secret
28+
29+
storage:
30+
size: 100Gi
31+
storageClassName: rook-ceph-block
32+
33+
connection:
34+
secretName: connection-mariadb
35+
secretTemplate:
36+
key: dsn
37+
healthCheck:
38+
interval: 10s
39+
retryInterval: 3s
40+
params:
41+
parseTime: "true"
42+
43+
myCnf: |
44+
[mariadb]
45+
bind-address=*
46+
skip-name-resolve
47+
connect_timeout=30
48+
wait_timeout=28800
49+
interactive_timeout=28800
50+
net_read_timeout=60
51+
net_write_timeout=60
52+
max_connections=500
53+
max_allowed_packet=64M
54+
thread_cache_size=100
55+
table_open_cache=2048
56+
open_files_limit=65535
57+
default_storage_engine=InnoDB
58+
binlog_format=row
59+
innodb_autoinc_lock_mode=2
60+
innodb_buffer_pool_size=1024M
61+
62+
livenessProbe:
63+
exec:
64+
command:
65+
- bash
66+
- -c
67+
- mysqladmin ping -u root -p"$MARIADB_ROOT_PASSWORD" --silent
68+
periodSeconds: 10
69+
timeoutSeconds: 5
70+
71+
readinessProbe:
72+
exec:
73+
command:
74+
- bash
75+
- -c
76+
- >
77+
mariadb -u root -p"$MARIADB_ROOT_PASSWORD" -e "
78+
SHOW STATUS LIKE 'wsrep_ready';
79+
SHOW STATUS LIKE 'wsrep_local_state_comment';" |
80+
grep -q 'ON' && grep -q 'Synced'
81+
periodSeconds: 10
82+
timeoutSeconds: 5
83+
84+
service:
85+
type: ClusterIP
86+
primaryService:
87+
type: LoadBalancer
88+
metadata:
89+
annotations:
90+
metallb.universe.tf/address-pool: openvpndb
91+
loadBalancerIP: 139.229.144.10
92+
secondaryService:
93+
type: ClusterIP
94+
95+
affinity:
96+
podAntiAffinity:
97+
requiredDuringSchedulingIgnoredDuringExecution:
98+
- labelSelector:
99+
matchLabels:
100+
app.kubernetes.io/name: mariadb
101+
topologyKey: kubernetes.io/hostname
102+
topologySpreadConstraints:
103+
- maxSkew: 1
104+
topologyKey: kubernetes.io/hostname
105+
whenUnsatisfiable: DoNotSchedule
106+
labelSelector:
107+
matchLabels:
108+
app.kubernetes.io/name: mariadb
109+
110+
podDisruptionBudget:
111+
minAvailable: 2
112+
113+
terminationGracePeriodSeconds: 180
114+
115+
podSecurityContext:
116+
runAsUser: 999
117+
runAsGroup: 999
118+
fsGroup: 999
119+
securityContext:
120+
allowPrivilegeEscalation: false
121+
readOnlyRootFilesystem: true
122+
123+
metrics:
124+
enabled: true

0 commit comments

Comments
 (0)