Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
JunRuiLee committed Jan 23, 2024
1 parent c7c63c3 commit f383c3c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
21 changes: 16 additions & 5 deletions Dockerfile-ubuntu.template
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,22 @@ RUN set -ex; \
chown -R flink:flink .; \
\
# Replace default REST/RPC endpoint bind address to use the container's network interface \
sed -i 's/rest.address: localhost/rest.address: 0.0.0.0/g' $FLINK_HOME/conf/flink-conf.yaml; \
sed -i 's/rest.bind-address: localhost/rest.bind-address: 0.0.0.0/g' $FLINK_HOME/conf/flink-conf.yaml; \
sed -i 's/jobmanager.bind-host: localhost/jobmanager.bind-host: 0.0.0.0/g' $FLINK_HOME/conf/flink-conf.yaml; \
sed -i 's/taskmanager.bind-host: localhost/taskmanager.bind-host: 0.0.0.0/g' $FLINK_HOME/conf/flink-conf.yaml; \
sed -i '/taskmanager.host: localhost/d' $FLINK_HOME/conf/flink-conf.yaml;
CONF_FILE="$FLINK_HOME/conf/flink-conf.yaml"; \
if [ ! -e "$FLINK_HOME/conf/flink-conf.yaml" ]; then \
CONF_FILE="${FLINK_HOME}/conf/config.yaml"; \
/bin/bash "$FLINK_HOME/bin/config-parser-utils.sh" "${FLINK_HOME}/conf" "${FLINK_HOME}/bin" "${FLINK_HOME}/lib" \
"-repKV" "rest.address,localhost,0.0.0.0" \
"-repKV" "rest.bind-address,localhost,0.0.0.0" \
"-repKV" "jobmanager.bind-host,localhost,0.0.0.0" \
"-repKV" "taskmanager.bind-host,localhost,0.0.0.0" \
"-rmKV" "taskmanager.host=localhost"; \
else \
sed -i 's/rest.address: localhost/rest.address: 0.0.0.0/g' "$CONF_FILE"; \
sed -i 's/rest.bind-address: localhost/rest.bind-address: 0.0.0.0/g' "$CONF_FILE"; \
sed -i 's/jobmanager.bind-host: localhost/jobmanager.bind-host: 0.0.0.0/g' "$CONF_FILE"; \
sed -i 's/taskmanager.bind-host: localhost/taskmanager.bind-host: 0.0.0.0/g' "$CONF_FILE"; \
sed -i '/taskmanager.host: localhost/d' "$CONF_FILE"; \
fi;

# Configure container
COPY docker-entrypoint.sh /
Expand Down
29 changes: 17 additions & 12 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ COMMAND_HISTORY_SERVER="history-server"

# If unspecified, the hostname of the container is taken as the JobManager address
JOB_MANAGER_RPC_ADDRESS=${JOB_MANAGER_RPC_ADDRESS:-$(hostname -f)}
CONF_FILE="${FLINK_HOME}/conf/flink-conf.yaml"

drop_privs_cmd() {
if [ $(id -u) != 0 ]; then
# Don't need to drop privs if EUID != 0
Expand Down Expand Up @@ -60,18 +58,25 @@ copy_plugins_if_required() {
}

set_config_option() {
local option=$1
local value=$2
local config_parser_script="$FLINK_HOME/bin/config-parser-utils.sh"
local config_dir="$FLINK_HOME/conf"
local bin_dir="$FLINK_HOME/bin"
local lib_dir="$FLINK_HOME/lib"

# escape periods for usage in regular expressions
local escaped_option=$(echo ${option} | sed -e "s/\./\\\./g")
local config_params=""

# either override an existing entry, or append a new one
if grep -E "^${escaped_option}:.*" "${CONF_FILE}" > /dev/null; then
sed -i -e "s/${escaped_option}:.*/$option: $value/g" "${CONF_FILE}"
else
echo "${option}: ${value}" >> "${CONF_FILE}"
fi
while [ $# -gt 0 ]; do
local key="$1"
local value="$2"

config_params+=" -D${key}=${value}"

shift 2
done

if [ ! -z "${config_params}" ]; then
eval "${config_parser_script} ${config_dir} ${bin_dir} ${lib_dir} ${config_params}"
fi
}

prepare_configuration() {
Expand Down

0 comments on commit f383c3c

Please sign in to comment.