Skip to content

Commit

Permalink
doing
Browse files Browse the repository at this point in the history
  • Loading branch information
szachovy committed Jul 16, 2024
1 parent 989c9cc commit d265255
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 40 deletions.
8 changes: 4 additions & 4 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ start_superset() {
}

initialize_nodes
superset_node_address=$(get_superset_node_ip ${superset_network_interface})
docker_swarm_token=$(init_and_get_docker_swarm_token ${superset_node_address})
clusterize_nodes
start_superset
# superset_node_address=$(get_superset_node_ip ${superset_network_interface})
# docker_swarm_token=$(init_and_get_docker_swarm_token ${superset_node_address})
# clusterize_nodes
# start_superset
39 changes: 23 additions & 16 deletions services/mysql-mgmt/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM ubuntu:22.04

COPY . "/opt"

RUN \

Check failure on line 5 in services/mysql-mgmt/Dockerfile

View workflow job for this annotation

GitHub Actions / run-docker-hadolint

DL3027 warning: Do not use apt as it is meant to be a end-user tool, use apt-get or apt-cache instead
apt \
update \
Expand All @@ -15,39 +17,42 @@ RUN \
&& \
groupadd \
--system \
superset \
"superset" \
&& \
useradd \
--system \
--gid \
superset \
"superset" \
--create-home \
--home-dir \
/home/superset \
"/home/superset" \
--shell \
/bin/bash \
"/bin/bash" \
superset \
&& \
mkdir \
"/opt/initcontainer" \
&& \
chown \
--recursive \
superset:superset \
/opt/initcontainer \
"/opt/initcontainer" \
&& \
rm \
--recursive \
--force \
/var/lib/apt/lists/*
"/var/lib/apt/lists/*"

USER superset

ARG MYSQL_SHELL_VERSION "mysql-shell-8.3.0-linux-glibc2.28-x86-64bit"
ARG MYSQL_ROUTER_VERSION "mysql-router-8.3.0-linux-glibc2.28-x86_64"
ARG MYSQL_SHELL_VERSION="mysql-shell-8.3.0-linux-glibc2.28-x86-64bit"
ARG MYSQL_ROUTER_VERSION="mysql-router-8.3.0-linux-glibc2.28-x86_64"

ENV DEBIAN_FRONTEND "noninteractive"
ENV PATH "${PATH}:${HOME}/${MYSQL_SHELL_VERSION}/bin:${HOME}/${MYSQL_ROUTER_VERSION}/bin"
ENV DEBIAN_FRONTEND="noninteractive"
ENV PATH="${PATH}:/home/superset/${MYSQL_SHELL_VERSION}/bin:/home/superset/${MYSQL_ROUTER_VERSION}/bin"
# ENV MYSQL_TEST_LOGIN_FILE="/home/superset/.mylogin.cnf"

COPY . "${HOME}"
WORKDIR "${HOME}"
WORKDIR "/home/superset"

RUN \
wget \
Expand All @@ -69,8 +74,10 @@ RUN \
&& \
chmod \
744 \
"${HOME}/envsubst-Linux-x86_64" \
"/home/superset/envsubst-Linux-x86_64" \
&& \
rm \
"${MYSQL_SHELL_VERSION}.tar.gz" \
"${MYSQL_ROUTER_VERSION}.tar.xz"
rm \
"${MYSQL_SHELL_VERSION}.tar.gz" \
"${MYSQL_ROUTER_VERSION}.tar.xz"

ENTRYPOINT [ "sleep", "infinity" ]
2 changes: 1 addition & 1 deletion services/mysql-mgmt/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
initcontainer:
build: "/opt/superset-cluster/mysql-mgmt"
image: "mysql-mgmt"
entrypoint: [ "/opt/entrypoint.sh" ]
entrypoint: "sleep infinity" #[ "/home/superset/entrypoint.sh" ]
container_name: "mysql-mgmt-initcontainer"

Check failure on line 7 in services/mysql-mgmt/docker-compose.yml

View workflow job for this annotation

GitHub Actions / run-ansible-lint

yaml[brackets]

Too many spaces inside brackets
network_mode: "host"
restart: "no"
Expand Down
10 changes: 5 additions & 5 deletions services/mysql-mgmt/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ if [ "${IS_PRIMARY_MGMT_NODE}" == "true" ]; then
export STATE="MASTER"
export PRIORITY="100"

for mysql_node_ip_address in "${PRIMARY_MYSQL_NODE}" "${SECONDARY_FIRST_MYSQL_NODE}" "${SECONDARY_SECOND_MYSQL_NODE}"; do
mysqlsh --login-path="${mysql_node_ip_address}" --execute="dba.configureInstance('${mysql_node_ip_address}')"
done
# for mysql_node_ip_address in "${PRIMARY_MYSQL_NODE}" "${SECONDARY_FIRST_MYSQL_NODE}" "${SECONDARY_SECOND_MYSQL_NODE}"; do
# mysqlsh --login-path="${mysql_node_ip_address}" --execute="dba.configureInstance('${mysql_node_ip_address}')"
# done

mysqlsh --login-path="${PRIMARY_MYSQL_NODE}" --execute="dba.createCluster('superset');"

Expand All @@ -17,11 +17,11 @@ if [ "${IS_PRIMARY_MGMT_NODE}" == "true" ]; then
mysqlsh --login-path="${PRIMARY_MYSQL_NODE}" --execute="dba.getCluster('superset').addInstance('${secondary_node_ip}',{recoveryMethod:'incremental'});"
done

mysqlsh --login-path="${PRIMARY_MYSQL_NODE}" --sql --file="${HOME}/superset-user.sql"
mysqlsh --login-path="${PRIMARY_MYSQL_NODE}" --sql --file="/home/superset/superset-user.sql"
else
export STATE="BACKUP"
export PRIORITY="90"
fi

mysqlrouter --bootstrap "superset:cluster@${PRIMARY_MYSQL_NODE}:3306" --directory "/opt/initcontainer/mysql_router" --conf-use-sockets
${HOME}/envsubst-Linux-x86_64 < "${HOME}/keepalived.conf.tpl" > "/opt/initcontainer/keepalived.conf"
/home/superset/envsubst-Linux-x86_64 < "/home/superset/keepalived.conf.tpl" > "/opt/initcontainer/keepalived.conf"
13 changes: 13 additions & 0 deletions services/mysql-mgmt/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,16 @@ export SECONDARY_SECOND_MYSQL_NODE="${6}"

cd /opt/superset-cluster/mysql-mgmt
docker compose up initcontainer && docker compose up maincontainer --detach
docker compose up initcontainer -d
docker exec -it mysql-mgmt-initcontainer bash
export IS_PRIMARY_MGMT_NODE=true
export VIRTUAL_IP_ADDRESS=10.145.211.155
export VIRTUAL_NETWORK_INTERFACE=eth0
export PRIMARY_MYSQL_NODE=wiktor-ctl
export SECONDARY_FIRST_MYSQL_NODE=wiktor-srv
export SECONDARY_SECOND_MYSQL_NODE=wiktor-pxy

# cd /opt/superset-cluster/mysql-mgmt
# docker compose up initcontainer -d
# docker exec -it mysql-mgmt-initcontainer bash
# docker exec -it mysql bash
46 changes: 35 additions & 11 deletions services/mysql-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ FROM mysql:8.0-debian
ARG SERVER_ID
ENV SERVER_ID="${SERVER_ID}"

COPY . "/opt"

RUN \

Check failure on line 8 in services/mysql-server/Dockerfile

View workflow job for this annotation

GitHub Actions / run-docker-hadolint

DL3027 warning: Do not use apt as it is meant to be a end-user tool, use apt-get or apt-cache instead
apt \
update \
Expand All @@ -17,42 +19,64 @@ RUN \
--location \
--output \
envsubst \
https://github.com/a8m/envsubst/releases/download/v1.2.0/envsubst-Linux-x86_64 \
"https://github.com/a8m/envsubst/releases/download/v1.2.0/envsubst-Linux-x86_64" \
&& \
chmod \
744 \
700 \
envsubst \
&& \
./envsubst < "/opt/mysql_config.cnf.tpl" > "/etc/mysql/conf.d/mysql_config.cnf" \
&& \
groupadd \
--system \
superset \
"superset" \
&& \
useradd \
--system \
--gid \
superset \
"superset" \
--create-home \
--home-dir \
/home/superset \
"/home/superset" \
--shell \
/bin/bash \
"/bin/bash" \
superset \
&& \
mv \
"/opt/entrypoint.sh" \
"/opt/store_credentials" \
"/home/superset" \
&& \
if [ -f "/opt/.mylogin.cnf" ]; then \
mv "/opt/.mylogin.cnf" "/home/superset/"; \
fi \
&& \
chown \
--recursive \
superset:superset \
/var/run/mysqld \
"/var/lib/mysql" \
"/var/run/mysqld" \
"/home/superset" \
&& \
chmod \
500 \
"/home/superset/entrypoint.sh" \
&& \
chmod \
500 \
"/home/superset/store_credentials" \
&& \
rm \
--recursive \
--force \
/var/lib/apt/lists/*
"/var/lib/apt/lists/*"

USER superset

COPY . "${HOME}"
WORKDIR "${HOME}"
WORKDIR "/home/superset"

ENV MYSQL_TEST_LOGIN_FILE="/home/superset/.mylogin.cnf"

# ENTRYPOINT [ "sh", "-c", "sleep infinity" ]

CMD [ "${HOME}/entrypoint.sh" ]
ENTRYPOINT [ "/home/superset/entrypoint.sh" ]
5 changes: 3 additions & 2 deletions services/mysql-server/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/bash

export MYSQL_ROOT_PASSWORD=$(openssl rand -hex 9)
export MYSQL_ROOT_PASSWORD=mysql
#$(openssl rand -hex 9)

/opt/store_credentials
/home/superset/store_credentials
docker-entrypoint.sh mysqld &

unset MYSQL_ROOT_PASSWORD
Expand Down
2 changes: 1 addition & 1 deletion src/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ initialize_nodes() {
for mgmt_node in "${mgmt_nodes[@]}"; do
ssh root@${mgmt_node} "mkdir --parents /opt/superset-cluster"
scp -r ${_path_to_root_catalog}/services/mysql-mgmt "root@${mgmt_node}:/opt/superset-cluster"
ssh root@${mgmt_node} "/opt/superset-cluster/mysql-mgmt/init.sh ${IS_PRIMARY_MGMT_NODE} ${virtual_ip_address} ${virtual_network_interface} $(array_to_string_converter ${mysql_nodes[@]})"
# ssh root@${mgmt_node} "/opt/superset-cluster/mysql-mgmt/init.sh ${IS_PRIMARY_MGMT_NODE} ${virtual_ip_address} ${virtual_network_interface} $(array_to_string_converter ${mysql_nodes[@]})"
IS_PRIMARY_MGMT_NODE=false
done
}
Expand Down

0 comments on commit d265255

Please sign in to comment.