Skip to content
This repository was archived by the owner on Jun 22, 2024. It is now read-only.

Commit 8b43efb

Browse files
Enable deployment of selenium docker images to restrictive Kubernetes (SeleniumHQ#1414)
* Enable deployment of selenium docker images to restrictive Kubernetes contexts * Remove Directory creation after merge request feedback Co-authored-by: Diego Molina <[email protected]>
1 parent bad545c commit 8b43efb

File tree

4 files changed

+47
-29
lines changed

4 files changed

+47
-29
lines changed

NodeBase/Dockerfile.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ ENV DISPLAY :99.0
162162
ENV DISPLAY_NUM 99
163163
ENV START_XVFB true
164164
ENV START_NO_VNC true
165+
# Path to the Configfile
166+
ENV CONFIG_FILE=/opt/selenium/config.toml
167+
ENV GENERATE_CONFIG true
165168

166169
#========================
167170
# Selenium Configuration

NodeBase/generate_config

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,48 @@ function short_version() {
66
echo "${__version_split[0]}.${__version_split[1]}"
77
}
88

9+
10+
if [[ -z "$CONFIG_FILE" ]]; then
11+
FILENAME="/opt/selenium/config.toml"
12+
else
13+
FILENAME="$CONFIG_FILE"
14+
fi
15+
916
echo "[events]
1017
publish = \"tcp://${SE_EVENT_BUS_HOST}:${SE_EVENT_BUS_PUBLISH_PORT}\"
1118
subscribe = \"tcp://${SE_EVENT_BUS_HOST}:${SE_EVENT_BUS_SUBSCRIBE_PORT}\"
12-
" > /opt/selenium/config.toml
19+
" > "$FILENAME"
1320

1421
if [[ -z "${SE_NODE_HOST}" ]] && [[ -z "${SE_NODE_PORT}" ]]; then
1522
echo "Configuring server..."
1623
else
17-
echo "[server]" >> /opt/selenium/config.toml
24+
echo "[server]" >> "$FILENAME"
1825
fi
1926

2027
if [[ -z "${SE_NODE_HOST}" ]]; then
2128
echo "Setting up SE_NODE_HOST..."
2229
else
23-
echo "host = \"${SE_NODE_HOST}\"" >> /opt/selenium/config.toml
30+
echo "host = \"${SE_NODE_HOST}\"" >> "$FILENAME"
2431
fi
2532

2633
if [[ -z "${SE_NODE_PORT}" ]]; then
2734
echo "Setting up SE_NODE_PORT..."
2835
else
29-
echo "port = \"${SE_NODE_PORT}\"" >> /opt/selenium/config.toml
36+
echo "port = \"${SE_NODE_PORT}\"" >> "$FILENAME"
3037
fi
3138

32-
echo "[node]" >> /opt/selenium/config.toml
39+
echo "[node]" >> "$FILENAME"
3340
# String, Url where the Grid can be reached
3441
if [[ -z "${SE_NODE_GRID_URL}" ]]; then
3542
echo "Setting up SE_NODE_GRID_URL..."
3643
else
37-
echo "grid-url = \"${SE_NODE_GRID_URL}\"" >> /opt/selenium/config.toml
44+
echo "grid-url = \"${SE_NODE_GRID_URL}\"" >> "$FILENAME"
3845
fi
39-
echo "session-timeout = \"${SE_NODE_SESSION_TIMEOUT}\"" >> /opt/selenium/config.toml
40-
echo "override-max-sessions = ${SE_NODE_OVERRIDE_MAX_SESSIONS}" >> /opt/selenium/config.toml
41-
echo "detect-drivers = false" >> /opt/selenium/config.toml
46+
echo "session-timeout = \"${SE_NODE_SESSION_TIMEOUT}\"" >> "$FILENAME"
47+
echo "override-max-sessions = ${SE_NODE_OVERRIDE_MAX_SESSIONS}" >> "$FILENAME"
48+
echo "detect-drivers = false" >> "$FILENAME"
4249
echo "max-sessions = ${SE_NODE_MAX_SESSIONS}
43-
" >> /opt/selenium/config.toml
50+
" >> "$FILENAME"
4451

4552
SE_NODE_BROWSER_NAME=$(cat /opt/selenium/browser_name)
4653
if [[ "${SE_NODE_BROWSER_NAME}" == "chrome" ]]; then
@@ -52,11 +59,11 @@ elif [[ "${SE_NODE_BROWSER_NAME}" == "MicrosoftEdge" ]]; then
5259
fi
5360

5461
SE_NODE_STEREOTYPE="{\"browserName\": \"${SE_NODE_BROWSER_NAME}\", \"browserVersion\": \"${SE_NODE_BROWSER_VERSION}\", \"platformName\": \"Linux\"}"
55-
echo "[[node.driver-configuration]]" >> /opt/selenium/config.toml
56-
echo "display-name = \"${SE_NODE_BROWSER_NAME}\"" >> /opt/selenium/config.toml
57-
echo "stereotype = '${SE_NODE_STEREOTYPE}'" >> /opt/selenium/config.toml
62+
echo "[[node.driver-configuration]]" >> "$FILENAME"
63+
echo "display-name = \"${SE_NODE_BROWSER_NAME}\"" >> "$FILENAME"
64+
echo "stereotype = '${SE_NODE_STEREOTYPE}'" >> "$FILENAME"
5865
echo "max-sessions = ${SE_NODE_MAX_SESSIONS}
59-
" >> /opt/selenium/config.toml
66+
" >> "$FILENAME"
6067

6168

6269

NodeBase/start-selenium-node.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ if [ ! -z "$SE_OPTS" ]; then
3131
echo "Appending Selenium options: ${SE_OPTS}"
3232
fi
3333

34-
/opt/bin/generate_config
35-
34+
if [ "$GENERATE_CONFIG" = true ]; then
35+
echo "Generating Selenium Config"
36+
/opt/bin/generate_config
37+
fi
3638
echo "Selenium Grid Node configuration: "
37-
cat /opt/selenium/config.toml
39+
cat "$CONFIG_FILE"
3840
echo "Starting Selenium Grid Node..."
3941
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar node \
40-
--config /opt/selenium/config.toml \
42+
--config "$CONFIG_FILE" \
4143
${SE_OPTS}

Standalone/generate_config

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,28 @@ function short_version() {
66
echo "${__version_split[0]}.${__version_split[1]}"
77
}
88

9+
if [[ -z "$CONFIG_FILE" ]]; then
10+
FILENAME="/opt/selenium/config.toml"
11+
else
12+
FILENAME="$CONFIG_FILE"
13+
fi
14+
915
echo "[network]
1016
relax-checks = ${SE_RELAX_CHECKS}
11-
" > /opt/selenium/config.toml
17+
" > "$FILENAME"
1218

13-
echo "[node]" >> /opt/selenium/config.toml
19+
echo "[node]" >> "$FILENAME"
1420
# String, Url where the Grid can be reached
1521
if [[ -z "${SE_NODE_GRID_URL}" ]]; then
1622
echo "Setting up SE_NODE_GRID_URL..."
1723
else
18-
echo "grid-url = \"${SE_NODE_GRID_URL}\"" >> /opt/selenium/config.toml
24+
echo "grid-url = \"${SE_NODE_GRID_URL}\"" >> "$FILENAME"
1925
fi
20-
echo "session-timeout = \"${SE_NODE_SESSION_TIMEOUT}\"" >> /opt/selenium/config.toml
21-
echo "override-max-sessions = ${SE_NODE_OVERRIDE_MAX_SESSIONS}" >> /opt/selenium/config.toml
22-
echo "detect-drivers = false" >> /opt/selenium/config.toml
26+
echo "session-timeout = \"${SE_NODE_SESSION_TIMEOUT}\"" >> "$FILENAME"
27+
echo "override-max-sessions = ${SE_NODE_OVERRIDE_MAX_SESSIONS}" >> "$FILENAME"
28+
echo "detect-drivers = false" >> "$FILENAME"
2329
echo "max-sessions = ${SE_NODE_MAX_SESSIONS}
24-
" >> /opt/selenium/config.toml
30+
" >> "$FILENAME"
2531

2632
SE_NODE_BROWSER_NAME=$(cat /opt/selenium/browser_name)
2733
if [[ "${SE_NODE_BROWSER_NAME}" == "chrome" ]]; then
@@ -33,11 +39,11 @@ elif [[ "${SE_NODE_BROWSER_NAME}" == "MicrosoftEdge" ]]; then
3339
fi
3440

3541
SE_NODE_STEREOTYPE="{\"browserName\": \"${SE_NODE_BROWSER_NAME}\", \"browserVersion\": \"${SE_NODE_BROWSER_VERSION}\", \"platformName\": \"Linux\"}"
36-
echo "[[node.driver-configuration]]" >> /opt/selenium/config.toml
37-
echo "display-name = \"${SE_NODE_BROWSER_NAME}\"" >> /opt/selenium/config.toml
38-
echo "stereotype = '${SE_NODE_STEREOTYPE}'" >> /opt/selenium/config.toml
42+
echo "[[node.driver-configuration]]" >> "$FILENAME"
43+
echo "display-name = \"${SE_NODE_BROWSER_NAME}\"" >> "$FILENAME"
44+
echo "stereotype = '${SE_NODE_STEREOTYPE}'" >> "$FILENAME"
3945
echo "max-sessions = ${SE_NODE_MAX_SESSIONS}
40-
" >> /opt/selenium/config.toml
46+
" >> "$FILENAME"
4147

4248

4349

0 commit comments

Comments
 (0)