Switch to bitnami/mariadb, which allows for in initContainer phase.
Showing
5 changed files
with
76 additions
and
4 deletions
... | @@ -14,7 +14,7 @@ environments: | ... | @@ -14,7 +14,7 @@ environments: |
14 | user: CHANGEME | 14 | user: CHANGEME |
15 | images: | 15 | images: |
16 | debian: "debian:bullseye-20211220" | 16 | debian: "debian:bullseye-20211220" |
17 | mariadb: "mariadb" | 17 | mariadb: "bitnami/mariadb:10.3.32-debian-10-r67" |
18 | 18 | ||
19 | --- | 19 | --- |
20 | 20 | ... | ... |
... | @@ -13,4 +13,6 @@ configMapGenerator: | ... | @@ -13,4 +13,6 @@ configMapGenerator: |
13 | - ./scripts/wait-for-file | 13 | - ./scripts/wait-for-file |
14 | - ./scripts/mariadb-is-ready | 14 | - ./scripts/mariadb-is-ready |
15 | - ./scripts/restore-from-empty | 15 | - ./scripts/restore-from-empty |
16 | - ./scripts/bitnami-mariadb-entrypoint-container.sh | ||
17 | - ./scripts/bitnami-mariadb-entrypoint-initContainer.sh | ||
16 | 18 | ... | ... |
... | @@ -53,6 +53,8 @@ spec: | ... | @@ -53,6 +53,8 @@ spec: |
53 | secretName: mariadb-secret | 53 | secretName: mariadb-secret |
54 | - name: database-restore | 54 | - name: database-restore |
55 | emptyDir: {} | 55 | emptyDir: {} |
56 | - name: etc | ||
57 | emptyDir: {} | ||
56 | 58 | ||
57 | initContainers: | 59 | initContainers: |
58 | - name: wait-for-file | 60 | - name: wait-for-file |
... | @@ -67,18 +69,22 @@ spec: | ... | @@ -67,18 +69,22 @@ spec: |
67 | - name: WAIT_FOR_FILE | 69 | - name: WAIT_FOR_FILE |
68 | value: /docker-entrypoint-initdb.d/.restored | 70 | value: /docker-entrypoint-initdb.d/.restored |
69 | 71 | ||
70 | containers: | 72 | - name: init-mariadb |
71 | - name: mariadb | ||
72 | image: mariadb | 73 | image: mariadb |
74 | command: ["/var/scripts/bitnami-mariadb-entrypoint-initContainer.sh"] | ||
73 | volumeMounts: | 75 | volumeMounts: |
76 | - name: mariadb-scripts | ||
77 | mountPath: /var/scripts | ||
74 | - name: mariadb-data | 78 | - name: mariadb-data |
75 | mountPath: /var/lib/mysql | 79 | mountPath: /bitnami/mariadb |
76 | - name: mariadb-config | 80 | - name: mariadb-config |
77 | mountPath: /var/mariadb-config | 81 | mountPath: /var/mariadb-config |
78 | - name: mariadb-secret | 82 | - name: mariadb-secret |
79 | mountPath: /var/mariadb-secret | 83 | mountPath: /var/mariadb-secret |
80 | - name: mariadb-entrypoint-initdb | 84 | - name: mariadb-entrypoint-initdb |
81 | mountPath: /docker-entrypoint-initdb.d | 85 | mountPath: /docker-entrypoint-initdb.d |
86 | - name: etc | ||
87 | mountPath: /runtime-etc | ||
82 | env: | 88 | env: |
83 | - name: MARIADB_DATABASE_FILE | 89 | - name: MARIADB_DATABASE_FILE |
84 | value: /var/mariadb-config/MARIADB_DATABASE | 90 | value: /var/mariadb-config/MARIADB_DATABASE |
... | @@ -89,3 +95,19 @@ spec: | ... | @@ -89,3 +95,19 @@ spec: |
89 | - name: MARIADB_ROOT_PASSWORD_FILE | 95 | - name: MARIADB_ROOT_PASSWORD_FILE |
90 | value: /var/mariadb-secret/MARIADB_ROOT_PASSWORD | 96 | value: /var/mariadb-secret/MARIADB_ROOT_PASSWORD |
91 | 97 | ||
98 | containers: | ||
99 | - name: mariadb | ||
100 | image: mariadb | ||
101 | #securityContext: | ||
102 | # runAsUser: 1001 | ||
103 | # runAsGroup: 1001 | ||
104 | command: ["/var/scripts/bitnami-mariadb-entrypoint-container.sh"] | ||
105 | args: ["/opt/bitnami/scripts/mariadb/run.sh"] | ||
106 | volumeMounts: | ||
107 | - name: mariadb-scripts | ||
108 | mountPath: /var/scripts | ||
109 | - name: mariadb-data | ||
110 | mountPath: /bitnami/mariadb | ||
111 | - name: etc | ||
112 | mountPath: /etc | ||
113 | ... | ... |
1 | #!/bin/bash | ||
2 | |||
3 | # shellcheck disable=SC1091 | ||
4 | |||
5 | set -o errexit | ||
6 | set -o nounset | ||
7 | set -o pipefail | ||
8 | # set -o xtrace # Uncomment this line for debugging purposes | ||
9 | |||
10 | # Load libraries | ||
11 | . /opt/bitnami/scripts/libbitnami.sh | ||
12 | . /opt/bitnami/scripts/libmariadb.sh | ||
13 | |||
14 | # Load MySQL environment variables | ||
15 | . /opt/bitnami/scripts/mariadb-env.sh | ||
16 | |||
17 | print_welcome_page | ||
18 | |||
19 | set -x | ||
20 | id | ||
21 | cat /etc/passwd | ||
22 | ls -la /bitnami/mariadb /bitnami/mariadb/data/ /opt/bitnami/mariadb/ | ||
23 | chown -R $DB_DAEMON_USER:$DB_DAEMON_GROUP /opt/bitnami/mariadb/tmp /opt/bitnami/mariadb/logs | ||
24 | exec bash -x "$@" |
1 | #!/bin/bash | ||
2 | |||
3 | # shellcheck disable=SC1091 | ||
4 | |||
5 | set -o errexit | ||
6 | set -o nounset | ||
7 | set -o pipefail | ||
8 | # set -o xtrace # Uncomment this line for debugging purposes | ||
9 | |||
10 | # Load libraries | ||
11 | . /opt/bitnami/scripts/libbitnami.sh | ||
12 | . /opt/bitnami/scripts/libmariadb.sh | ||
13 | |||
14 | # Load MySQL environment variables | ||
15 | . /opt/bitnami/scripts/mariadb-env.sh | ||
16 | |||
17 | print_welcome_page | ||
18 | |||
19 | info "** Starting MariaDB setup **" | ||
20 | /opt/bitnami/scripts/mariadb/setup.sh | ||
21 | info "** MariaDB setup finished! **" | ||
22 | ls -la /bitnami/mariadb /bitnami/mariadb/data/ /opt/bitnami/mariadb/ | ||
23 | cp -a /etc/* /runtime-etc/ | ||
24 | cat /etc/passwd |
-
Please register or sign in to post a comment