477934f6 by Adam Heath

First pass of new set of helmfiles for composable installs.

1 parent ff4bd467
1 apiVersion: kustomize.config.k8s.io/v1beta1
2 kind: Kustomization
3
4 resources:
5 - ./restore-from-empty.yaml
6
1 apiVersion: batch/v1
2 kind: Job
3 metadata:
4 name: mariadb-restore-from-empty
5 spec:
6 #replicas: 1
7 #progressDeadlineSeconds: 600
8 template:
9 spec:
10 restartPolicy: OnFailure
11 securityContext:
12 runAsUser: 0
13 runAsGroup: 0
14
15 volumes:
16 - name: mariadb-entrypoint-initdb
17 persistentVolumeClaim:
18 claimName: mariadb-entrypoint-initdb
19 - name: mariadb-scripts
20 configMap:
21 name: mariadb-scripts
22 defaultMode: 0755
23
24 containers:
25 - name: restore-from-empty
26 image: debian
27 command: ["/scripts/restore-from-empty"]
28 volumeMounts:
29 - name: mariadb-entrypoint-initdb
30 mountPath: /docker-entrypoint-initdb.d
31 - name: mariadb-scripts
32 mountPath: /scripts
33
1 ---
2 apiVersion: v1
3 kind: ConfigMap
4 metadata:
5 name: mariadb-config
6 data:
7 MARIADB_DATABASE: ""
8 MARIADB_USER: ""
9 ---
10 apiVersion: v1
11 kind: Secret
12 metadata:
13 name: mariadb-secret
14 stringData:
15 MARIADB_PASSWORD: "CHANGEME"
16 MARIADB_ROOT_PASSWORD: "CHANGEME"
17 ---
18 apiVersion: v1
19 kind: PersistentVolumeClaim
20 metadata:
21 name: mariadb-data
22 spec:
23 accessModes:
24 - ReadWriteOnce
25 resources:
26 requests:
27 storage: 10Gi
28 ---
29 apiVersion: v1
30 kind: PersistentVolumeClaim
31 metadata:
32 name: mariadb-entrypoint-initdb
33 spec:
34 accessModes:
35 - ReadWriteOnce
36 resources:
37 requests:
38 storage: 10Gi
39 ---
40
41
1 environments:
2 default:
3 values:
4 - namespace: mariadb
5 namePrefix: "test-"
6 restoreFromEmpty:
7 enabled: true
8 mariadbServer:
9 jsonPatches: []
10 strategicMergePatches: []
11 rootPassword: CHANGEME
12 password: CHANGEME
13 database: CHANGEME
14 user: CHANGEME
15 images:
16 debian: "debian:bullseye-20211220"
17 mariadb: "mariadb"
18
19 ---
20
21 releases:
22 - name: {{ .Values.namePrefix }}mariadb-restore-from-empty
23 namespace: {{ .Values.namespace }}
24 chart: charts/restore-from-empty
25 condition: restoreFromEmpty.enabled
26 values:
27 - set-common-values.yaml.gotmpl
28 strategicMergePatches:
29 - apiVersion: batch/v1
30 kind: Job
31 metadata:
32 name: {{ .Values.namePrefix }}mariadb-restore-from-empty
33 namespace: {{ .Values.namespace }}
34 spec:
35 template:
36 spec:
37 volumes:
38 - name: mariadb-entrypoint-initdb
39 persistentVolumeClaim:
40 claimName: {{ .Values.namePrefix }}mariadb-entrypoint-initdb
41 - name: mariadb-scripts
42 configMap:
43 name: {{ .Values.namePrefix }}mariadb-scripts
44
45 - name: {{ .Values.namePrefix }}mariadb-server
46 namespace: {{ .Values.namespace }}
47 chart: .
48 values:
49 - set-common-values.yaml.gotmpl
50 jsonPatches:
51 {{- if not (empty (.Values.mariadbServer.jsonPatches)) }}
52 {{- .Values.mariadbServer.jsonPatches | toYaml | indent 6 }}
53 {{- end }}
54 strategicMergePatches:
55 - apiVersion: apps/v1
56 kind: Deployment
57 metadata:
58 name: {{ .Values.namePrefix }}mariadb-server
59 namespace: {{ .Values.namespace }}
60 spec:
61 selector:
62 matchLabels:
63 app: {{ .Values.namePrefix }}mariadb-server
64 template:
65 metadata:
66 labels:
67 app: {{ .Values.namePrefix }}mariadb-server
68 spec:
69 volumes:
70 - name: mariadb-data
71 persistentVolumeClaim:
72 claimName: {{ .Values.namePrefix }}mariadb-data
73 - name: mariadb-config
74 configMap:
75 name: {{ .Values.namePrefix }}mariadb-config
76 - name: mariadb-scripts
77 configMap:
78 name: {{ .Values.namePrefix }}mariadb-scripts
79 - name: mariadb-secret
80 secret:
81 secretName: {{ .Values.namePrefix }}mariadb-secret
82 - apiVersion: v1
83 kind: Service
84 metadata:
85 name: {{ .Values.namePrefix }}mariadb
86 namespace: {{ .Values.namespace }}
87 spec:
88 selector:
89 app: {{ .Values.namePrefix }}mariadb-server
90 {{- if not (empty (.Values.mariadbServer.strategicMergePatches)) }}
91 {{- .Values.mariadbServer.strategicMergePatches | toYaml | indent 6 }}
92 {{- end }}
93 - apiVersion: v1
94 kind: ConfigMap
95 metadata:
96 name: {{ .Values.namePrefix }}mariadb-config
97 namespace: {{ .Values.namespace }}
98 data:
99 MARIADB_DATABASE: {{ .Values.mariadbServer.database }}
100 MARIADB_USER: {{ .Values.mariadbServer.user }}
101 - apiVersion: v1
102 kind: Secret
103 metadata:
104 name: {{ .Values.namePrefix }}mariadb-secret
105 namespace: {{ .Values.namespace }}
106 stringData:
107 MARIADB_PASSWORD: {{ .Values.mariadbServer.password }}
108 MARIADB_ROOT_PASSWORD: {{ .Values.mariadbServer.rootPassword }}
109
1 apiVersion: kustomize.config.k8s.io/v1beta1
2 kind: Kustomization
3
4 resources:
5 - ./config.yaml
6 - ./mariadb-server.yaml
7
8 generatorOptions:
9 disableNameSuffixHash: true
10 configMapGenerator:
11 - name: mariadb-scripts
12 files:
13 - ./scripts/wait-for-file
14 - ./scripts/mariadb-is-ready
15 - ./scripts/restore-from-empty
16
1 ---
2 apiVersion: v1
3 kind: Service
4 metadata:
5 name: mariadb
6 spec:
7 selector:
8 app: mariadb-server
9 ports:
10 - name: mysql
11 protocol: TCP
12 port: 3306
13 targetPort: 3306
14 ---
15 apiVersion: apps/v1
16 kind: Deployment
17 metadata:
18 name: mariadb-server
19 labels:
20 app: mariadb-server
21 spec:
22 replicas: 1
23 progressDeadlineSeconds: 600
24 selector:
25 matchLabels:
26 app: mariadb-server
27 template:
28 metadata:
29 labels:
30 app: mariadb-server
31 spec:
32 restartPolicy: Always
33 securityContext:
34 runAsUser: 0
35 runAsGroup: 0
36
37 volumes:
38 - name: mariadb-data
39 persistentVolumeClaim:
40 claimName: mariadb-data
41 - name: mariadb-entrypoint-initdb
42 persistentVolumeClaim:
43 claimName: mariadb-entrypoint-initdb
44 - name: mariadb-scripts
45 configMap:
46 name: mariadb-scripts
47 defaultMode: 0755
48 - name: mariadb-config
49 configMap:
50 name: mariadb-config
51 - name: mariadb-secret
52 secret:
53 secretName: mariadb-secret
54 - name: database-restore
55 emptyDir: {}
56
57 initContainers:
58 - name: wait-for-file
59 image: debian
60 command: ["/scripts/wait-for-file"]
61 volumeMounts:
62 - name: mariadb-entrypoint-initdb
63 mountPath: /docker-entrypoint-initdb.d
64 - name: mariadb-scripts
65 mountPath: /scripts
66 env:
67 - name: WAIT_FOR_FILE
68 value: /docker-entrypoint-initdb.d/.restored
69
70 containers:
71 - name: mariadb
72 image: mariadb
73 volumeMounts:
74 - name: mariadb-data
75 mountPath: /var/lib/mysql
76 - name: mariadb-config
77 mountPath: /var/mariadb-config
78 - name: mariadb-secret
79 mountPath: /var/mariadb-secret
80 - name: mariadb-entrypoint-initdb
81 mountPath: /docker-entrypoint-initdb.d
82 env:
83 - name: MARIADB_DATABASE_FILE
84 value: /var/mariadb-config/MARIADB_DATABASE
85 - name: MARIADB_USER_FILE
86 value: /var/mariadb-config/MARIADB_USER
87 - name: MARIADB_PASSWORD_FILE
88 value: /var/mariadb-secret/MARIADB_PASSWORD
89 - name: MARIADB_ROOT_PASSWORD_FILE
90 value: /var/mariadb-secret/MARIADB_ROOT_PASSWORD
91
1 #!/bin/sh
2
3 set -e
4 trap 'exit' TERM
5
6 check_mysqldb() {
7 mysql --connect-timeout=1 --host="${MYSQL_HOST}" --user="${MYSQL_USER}" --password="${MYSQL_PASSWORD}" --port="${MYSQL_PORT:-3306}" -e "SELECT 'Ok' AS 'Healthy'"
8 }
9 while ! check_mysqldb; do
10 echo "Waiting for database" 1>&2
11 sleep 1
12 count=5
13 while [ $count -gt 0 ] && ! check_mysqldb; do
14 count=$(($count - 1))
15 sleep 1
16 done
17 done
18
1 #!/bin/sh
2
3 set -e
4
5 touch /docker-entrypoint-initdb.d/.restored
1 #!/bin/sh
2
3 set -ex
4 trap 'exit' TERM
5
6 while ! [ -e $WAIT_FOR_FILE ]; do
7 echo "Waiting for file: $WAIT_FOR_FILE" 1>&2
8 sleep 1
9 count=5
10 while ! [ -e $WAIT_FOR_FILE && $count -gt 0 ]; do
11 count=$(($count - 1))
12 sleep 1
13 done
14 done
15
1 namePrefix: {{ .Values.namePrefix }}
2 namespace: {{ .Values.namespace }}
3 images:
4 - name: debian
5 newName: {{ .Values.images.debian }}
6 - name: mariadb
7 newName: {{ .Values.images.mariadb }}
8
1 ---
2 apiVersion: v1
3 kind: ConfigMap
4 metadata:
5 name: nfs-config
6 data:
7 ---
8 apiVersion: v1
9 kind: PersistentVolumeClaim
10 metadata:
11 name: nfs-data
12 spec:
13 accessModes:
14 - ReadWriteOnce
15 resources:
16 requests:
17 storage: 10Gi
18 ---
19
20
1 environments:
2 default:
3 values:
4 - namespace: nfs-server
5 namePrefix: "test-"
6 images:
7 debian: "debian:bullseye-20211220"
8 volume-nfs: k8s.gcr.io/volume-nfs:0.8
9 ---
10
11 releases:
12 - name: {{ .Values.namePrefix }}nfs-server
13 namespace: {{ .Values.namespace }}
14 chart: .
15 values:
16 - set-common-values.yaml.gotmpl
17 strategicMergePatches:
18 - apiVersion: v1
19 kind: ReplicationController
20 metadata:
21 name: {{ .Values.namePrefix }}nfs-server
22 namespace: {{ .Values.namespace }}
23 spec:
24 template:
25 spec:
26 volumes:
27 - name: nfs-data
28 persistentVolumeClaim:
29 claimName: {{ .Values.namePrefix }}nfs-data
30
1 apiVersion: kustomize.config.k8s.io/v1beta1
2 kind: Kustomization
3
4 resources:
5 - ./config.yaml
6 - ./nfs-server.yaml
7
8 generatorOptions:
9 disableNameSuffixHash: true
10 configMapGenerator:
11 - name: nfs-scripts
12 files:
13 - ./scripts/wait-for-file
14
1 ---
2 apiVersion: v1
3 kind: Service
4 metadata:
5 name: nfs-server
6 spec:
7 selector:
8 app: nfs-server
9 ports:
10 - name: mountd
11 port: 20048
12 - name: nfs
13 port: 2049
14 - name: rpcbind
15 port: 111
16 ---
17 apiVersion: v1
18 kind: ReplicationController
19 metadata:
20 name: nfs-server
21 spec:
22 replicas: 1
23 selector:
24 app: nfs-server
25 template:
26 metadata:
27 labels:
28 app: nfs-server
29 spec:
30 volumes:
31 - name: nfs-data
32 persistentVolumeClaim:
33 claimName: nfs-data
34
35 containers:
36 - name: nfs-server
37 image: k8s.gcr.io/volume-nfs:0.8
38 ports:
39 - name: nfs
40 containerPort: 2049
41 - name: mountd
42 containerPort: 20048
43 - name: rpcbind
44 containerPort: 111
45 securityContext:
46 privileged: true
47 volumeMounts:
48 - name: nfs-data
49 mountPath: /exports
50 ---
1 #!/bin/sh
2
3 set -ex
4 trap 'exit' TERM
5
6 while ! [ -e $WAIT_FOR_FILE ]; do
7 echo "Waiting for file: $WAIT_FOR_FILE" 1>&2
8 sleep 1
9 count=5
10 while ! [ -e $WAIT_FOR_FILE && $count -gt 0 ]; do
11 count=$(($count - 1))
12 sleep 1
13 done
14 done
15
1 namePrefix: {{ .Values.namePrefix }}
2 namespace: {{ .Values.namespace }}
3 images:
4 - name: debian
5 newName: {{ .Values.images.debian }}
6 - name: k8s.gcr.io/volume-nfs:0.8
7 newName: {{ .Values.images | get "volume-nfs" }}
8
1 apiVersion: v1
2 kind: ConfigMap
3 metadata:
4 name: wordpress-config
5 data:
6 WORDPRESS_DB_HOST: mariadb
7 WORDPRESS_DB_NAME: wordpress
8 WORDPRESS_DB_USER: wordpress
9 ---
10 apiVersion: v1
11 kind: Secret
12 metadata:
13 name: wordpress-secret
14 stringData:
15 WORDPRESS_DB_PASSWORD: wordpress
16 WORDPRESS_TABLE_PREFIX: wp_
17 ---
1 environments:
2 default:
3 values:
4 - namespace: wordpress
5 namePrefix: "test-"
6 wordpress:
7 jsonPatches: []
8 strategicMergePatches: []
9 database:
10 name: "wordpress"
11 user: "wordpress"
12 password: "wordpress"
13 prefix: "wp_"
14 mariadbServer:
15 rootPassword: "CHANGEME"
16
17 ---
18
19 helmfiles:
20 - path: ../mariadb-server/helmfile.yaml
21 values:
22 - namespace: {{ .Values.namespace }}
23 namePrefix: {{ .Values.namePrefix }}wordpress-
24 - mariadbServer:
25 rootPassword: {{ .Values.mariadbServer.rootPassword }}
26 database: {{ .Values.wordpress.database.name }}
27 user: {{ .Values.wordpress.database.user }}
28 password: {{ .Values.wordpress.database.password }}
29
30 releases:
31 - name: {{ .Values.namePrefix }}wordpress
32 namespace: {{ .Values.namespace }}
33 chart: .
34 values:
35 - set-common-values.yaml.gotmpl
36 jsonPatches:
37 {{- if not (empty (.Values.wordpress.jsonPatches)) }}
38 {{- .Values.wordpress.jsonPatches | toYaml | indent 6 }}
39 {{- end }}
40 strategicMergePatches:
41 - apiVersion: v1
42 kind: ConfigMap
43 metadata:
44 name: {{ .Values.namePrefix }}wordpress-config
45 namespace: {{ .Values.namespace }}
46 data:
47 WORDPRESS_DB_HOST: {{ .Values.namePrefix }}wordpress-mariadb
48 WORDPRESS_DB_NAME: {{ .Values.wordpress.database.name }}
49 WORDPRESS_DB_USER: {{ .Values.wordpress.database.user }}
50 - apiVersion: v1
51 kind: Secret
52 metadata:
53 name: {{ .Values.namePrefix }}wordpress-secret
54 namespace: {{ .Values.namespace }}
55 stringData:
56 WORDPRESS_DB_PASSWORD: {{ .Values.wordpress.database.password }}
57 WORDPRESS_TABLE_PREFIX: {{ .Values.wordpress.database.prefix }}
58 {{- if not (empty (.Values.wordpress.strategicMergePatches)) }}
59 {{- .Values.wordpress.strategicMergePatches | toYaml | indent 6 }}
60 {{- end }}
1 apiVersion: kustomize.config.k8s.io/v1beta1
2 kind: Kustomization
3
4 resources:
5 - ./config.yaml
6 generatorOptions:
7 disableNameSuffixHash: true
8 configMapGenerator:
9
1 namePrefix: {{ .Values.namePrefix }}
2 namespace: {{ .Values.namespace }}
3