Skip to content

Commit

Permalink
users in containers
Browse files Browse the repository at this point in the history
  • Loading branch information
szachovy committed Jul 17, 2024
1 parent d265255 commit 76823a0
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 59 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ With the [Requirements](#requirements) satisfied, you can build and run the enti

Explore [docs](docs/) for further information about the setup, or visit [additional resources](#additional-resources) to learn more about Superset and MySQL components as a whole.

...default username and password for Web UI, database etc, how to change, under what user nodes/containers are operating...

### Example

Expand Down
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
17 changes: 5 additions & 12 deletions services/mysql-mgmt/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,27 @@ RUN \
"superset" \
--create-home \
--home-dir \
"/home/superset" \
"/opt" \
--shell \
"/bin/bash" \
superset \
&& \
mkdir \
"/opt/initcontainer" \
&& \
chown \
--recursive \
superset:superset \
"/opt/initcontainer" \
&& \
rm \
--recursive \
--force \
"/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"

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"
ENV PATH="${PATH}:/opt/${MYSQL_SHELL_VERSION}/bin:/opt/${MYSQL_ROUTER_VERSION}/bin"
ENV MYSQL_TEST_LOGIN_FILE="/opt/.mylogin.cnf"

WORKDIR "/home/superset"
WORKDIR "/opt"

RUN \
wget \
Expand All @@ -74,7 +67,7 @@ RUN \
&& \
chmod \
744 \
"/home/superset/envsubst-Linux-x86_64" \
"/opt/envsubst-Linux-x86_64" \
&& \
rm \
"${MYSQL_SHELL_VERSION}.tar.gz" \
Expand Down
4 changes: 3 additions & 1 deletion services/mysql-mgmt/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ services:
initcontainer:
build: "/opt/superset-cluster/mysql-mgmt"
image: "mysql-mgmt"
entrypoint: "sleep infinity" #[ "/home/superset/entrypoint.sh" ]
user: "root"
entrypoint: [ "/opt/entrypoint.sh" ]

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
container_name: "mysql-mgmt-initcontainer"
network_mode: "host"
restart: "no"
Expand All @@ -19,6 +20,7 @@ services:

maincontainer:
image: "mysql-mgmt"
user: "superset"
entrypoint: [ "sh", "-c", "keepalived --use-file /opt/initcontainer/keepalived.conf && mysqlrouter --config /opt/initcontainer/mysql_router/mysqlrouter.conf" ]

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

View workflow job for this annotation

GitHub Actions / run-ansible-lint

yaml[line-length]

Line too long (163 > 160 characters)

Check failure on line 24 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
container_name: "mysql-mgmt"
restart: "always"
Expand Down
13 changes: 7 additions & 6 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,12 @@ 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/superset-user.sql"
mysqlsh --login-path="${PRIMARY_MYSQL_NODE}" --sql --file="/opt/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/superset/envsubst-Linux-x86_64 < "/home/superset/keepalived.conf.tpl" > "/opt/initcontainer/keepalived.conf"
mysqlrouter --user "superset" --bootstrap "superset:cluster@${PRIMARY_MYSQL_NODE}:3306" --directory "/opt/initcontainer/mysql_router" --conf-use-sockets
/opt/envsubst-Linux-x86_64 < "/opt/keepalived.conf.tpl" > "/opt/initcontainer/keepalived.conf"
chown "superset:superset" "/opt/initcontainer/keepalived.conf"
13 changes: 0 additions & 13 deletions services/mysql-mgmt/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,3 @@ 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
25 changes: 15 additions & 10 deletions services/superset/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ FROM apache/superset

USER superset

ARG PRELOAD_EXAMPLES=false
ARG VIRTUAL_IP_ADDRESS
ARG PRELOAD_EXAMPLES="false"

COPY --chown=superset superset_config.py /app/
ENV SUPERSET_CONFIG_PATH /app/superset_config.py
COPY --chown=superset "superset_config.py" "/app/"

ENV SUPERSET_CONFIG_PATH="/app/superset_config.py"
ENV VIRTUAL_IP_ADDRESS="${VIRTUAL_IP_ADDRESS}"

RUN \

Check failure on line 13 in services/superset/Dockerfile

View workflow job for this annotation

GitHub Actions / run-docker-hadolint

DL3013 warning: Pin versions in pip. Instead of `pip install <package>` use `pip install <package>==<version>` or `pip install --requirement <requirements file>`

Check failure on line 13 in services/superset/Dockerfile

View workflow job for this annotation

GitHub Actions / run-docker-hadolint

DL3042 warning: Avoid use of cache directory with pip. Use `pip install --no-cache-dir <package>`
pip \
Expand All @@ -17,25 +20,27 @@ RUN \
fab \
create-admin \
--username \
superset \
"superset" \
--firstname \
superset \
"superset" \
--lastname \
superset \
"superset" \
--email \
[email protected] \
"[email protected]" \
--password \
cluster \
"cluster" \
&& \
superset \
db \
upgrade \
&& \
if ${PRELOAD_EXAMPLES}; then \
if "${PRELOAD_EXAMPLES}"; then \
superset load_examples; \
fi \
&& \
superset \
init

ENTRYPOINT $(pwd)/services/superset/entrypoint.sh
ENTRYPOINT [ "sh", "-c", \
"celery --app superset.tasks.celery_app:app worker --pool prefork --concurrency 4 -O fair --detach && /usr/bin/run-server.sh" \
]
10 changes: 0 additions & 10 deletions services/superset/entrypoint.sh

This file was deleted.

2 changes: 1 addition & 1 deletion services/superset/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ VIRTUAL_IP_ADDRESS="${1}"
PRELOAD_EXAMPLES="${2}"

docker build \
--build-arg VIRTUAL_IP_ADDRESS="${VIRTUAL_IP_ADDRESS}" \
--build-arg PRELOAD_EXAMPLES="${PRELOAD_EXAMPLES}" \
--tag superset \
$(pwd)/services/superset
Expand All @@ -13,5 +14,4 @@ docker run \
--name superset \
--network superset-network \
--publish 8088:8088 \
--env "VIRTUAL_IP_ADDRESS=${VIRTUAL_IP_ADDRESS}" \
superset
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 76823a0

Please sign in to comment.