Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions examples/mysql-persistent-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,62 @@
}
},
"spec": {
"initContainers": [
{
"name": "mysql-init",
"image": " ",
"command": [ "/usr/bin/run-mysqld", "init" ],
"env": [
{
"name": "MYSQL_USER",
"valueFrom": {
"secretKeyRef" : {
"name" : "${DATABASE_SERVICE_NAME}",
"key" : "database-user"
}
}
},
{
"name": "MYSQL_PASSWORD",
"valueFrom": {
"secretKeyRef" : {
"name" : "${DATABASE_SERVICE_NAME}",
"key" : "database-password"
}
}
},
{
"name": "MYSQL_ROOT_PASSWORD",
"valueFrom": {
"secretKeyRef" : {
"name" : "${DATABASE_SERVICE_NAME}",
"key" : "database-root-password"
}
}
},
{
"name": "MYSQL_DATABASE",
"valueFrom": {
"secretKeyRef" : {
"name" : "${DATABASE_SERVICE_NAME}",
"key" : "database-name"
}
}
}
],
"resources": {
"limits": {
"memory": "${MEMORY_LIMIT}"
}
},
"volumeMounts": [
{
"name": "${DATABASE_SERVICE_NAME}-data",
"mountPath": "/var/lib/mysql/data"
}
]
}
],
"containers": [
{
"name": "mysql",
Expand Down
6 changes: 6 additions & 0 deletions root-common/usr/bin/run-mysqld
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

init_only=false && [ "$1" == "init" ] && init_only=true && shift

export_vars=$(cgroup-limits); export $export_vars
source ${CONTAINER_SCRIPTS_PATH}/common.sh
set -eu
Expand All @@ -20,6 +22,10 @@ else
start_local_mysql "$@"
fi

if $init_only; then
exit 0
fi

# set mysql_flags and admin_flagsadmin_flags properly
if [ -z "${MYSQL_ROOT_PASSWORD:-}" ] || is_allowing_connection_with_empty_password; then
mysql_flags="-u root --socket=$MYSQL_LOCAL_SOCKET"
Expand Down