Skip to content

Commit ac1023c

Browse files
authored
Merge pull request #23 from hamzy/add-bootstrap-sshd-port
Add a sshd port for the bootstrap node
2 parents b087b6f + 057ba9b commit ac1023c

File tree

9 files changed

+196
-24
lines changed

9 files changed

+196
-24
lines changed

install-ci.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,16 @@ then
201201
exit 1
202202
fi
203203

204+
if [[ ! -v BRANCH ]]
205+
then
206+
BRANCH="master"
207+
fi
208+
204209
git reset --hard HEAD
205210
git clean -fxd .
206-
git checkout master
211+
git checkout ${BRANCH}
207212
git fetch
208-
git checkout -m origin/master install-ci.sh
213+
git checkout -m origin/${BRANCH} install-ci.sh
209214

210215
NEW_INSTALL_CI_SHA1SUM=$(my_sha ${SCRIPT_DIR}/install-ci.sh)
211216
RC=$?
@@ -242,3 +247,12 @@ if ! sudo diff ./libvirt/haproxy/haproxy_$(hostname).cfg /etc/haproxy/haproxy.cf
242247
then
243248
restart_haproxy
244249
fi
250+
251+
FILENAME="./libvirt/tunnel/profile_$(hostname).yaml"
252+
CLUSTER_ID=$(yq eval '.profile.cluster_id' ${FILENAME})
253+
declare -a BASTION_SSH_PORTS=( 1023 1033 1043 1053 1063 1073 )
254+
for I in ${BASTION_SSH_PORTS[*]}
255+
do
256+
sudo firewall-cmd --permanent --zone=libvirt --add-port=$(( ${I} + ${CLUSTER_ID} ))/tcp || true
257+
done
258+
sudo firewall-cmd --reload || true

libvirt/haproxy/haproxy_C155F2U31.cfg

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,42 @@ frontend https-all
145145
acl 03-https-ci req_ssl_sni -m end .libvirt-ppc64le-1-3.ci
146146
use_backend https-workers-03 if 03-https-ci
147147

148+
##---------------------------------------------------------------------
149+
## SSH frontend which proxys to the created bootstrap nodes
150+
##---------------------------------------------------------------------
151+
#frontend ssh-all
152+
# mode tcp
153+
# option tcplog
154+
#
155+
# bind *:1023
156+
#
157+
# tcp-request inspect-delay 5s
158+
# tcp-request content accept if { req_ssl_hello_type 1 }
159+
#
160+
# acl 00-ssh req_ssl_sni -m end .libvirt-ppc64le-1-0
161+
# use_backend ssh-bootstrap-00 if 00-ssh
162+
#
163+
# acl 00-ssh-ci req_ssl_sni -m end .libvirt-ppc64le-1-0.ci
164+
# use_backend ssh-bootstrap-00 if 00-ssh-ci
165+
#
166+
# acl 01-ssh req_ssl_sni -m end .libvirt-ppc64le-1-1
167+
# use_backend ssh-bootstrap-01 if 01-ssh
168+
#
169+
# acl 01-ssh-ci req_ssl_sni -m end .libvirt-ppc64le-1-1.ci
170+
# use_backend ssh-bootstrap-01 if 01-ssh-ci
171+
#
172+
# acl 02-ssh req_ssl_sni -m end .libvirt-ppc64le-1-2
173+
# use_backend ssh-bootstrap-02 if 02-ssh
174+
#
175+
# acl 02-ssh-ci req_ssl_sni -m end .libvirt-ppc64le-1-2.ci
176+
# use_backend ssh-bootstrap-02 if 02-ssh-ci
177+
#
178+
# acl 03-ssh req_ssl_sni -m end .libvirt-ppc64le-1-3
179+
# use_backend ssh-bootstrap-03 if 03-ssh
180+
#
181+
# acl 03-ssh-ci req_ssl_sni -m end .libvirt-ppc64le-1-3.ci
182+
# use_backend ssh-bootstrap-03 if 03-ssh-ci
183+
148184
#---------------------------------------------------------------------
149185
# Master node backends for serving API traffic
150186
#---------------------------------------------------------------------
@@ -260,3 +296,23 @@ backend https-workers-03
260296
#backend node-https
261297
# mode tcp
262298
# server node 127.0.0.1:8443 check
299+
300+
##---------------------------------------------------------------------
301+
## Bootstrap node backends for serving SSH service endpoints
302+
##---------------------------------------------------------------------
303+
#backend ssh-bootstrap-00
304+
# mode tcp
305+
# balance roundrobin
306+
# server bootstrap 192.168.126.10:22 check
307+
#backend ssh-bootstrap-01
308+
# mode tcp
309+
# balance roundrobin
310+
# server bootstrap 192.168.1.10:22 check
311+
#backend ssh-bootstrap-02
312+
# mode tcp
313+
# balance roundrobin
314+
# server bootstrap 192.168.2.10:22 check
315+
#backend ssh-bootstrap-03
316+
# mode tcp
317+
# balance roundrobin
318+
# server bootstrap 192.168.3.10:22 check

libvirt/tunnel/generate-ports.sh

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,34 @@ API_PORT=6443
99
HTTP_PORT=80
1010
HTTPS_PORT=443
1111

12-
for f in profile_*.yaml ; do filename=${f};
13-
if [[ ! -f ${filename} ]]; then
14-
echo "${filename} file missing"
15-
exit 0
16-
fi
17-
ARCH=$(yq eval '.profile.arch' ${filename})
18-
CLUSTER_CAPACITY=$(yq eval '.profile.cluster_capacity' ${filename})
19-
CLUSTER_ID=$(yq eval '.profile.cluster_id' ${filename})
12+
#set -x
13+
declare -a BASTION_SSH_PORTS=( 1023 1033 1043 1053 1063 1073 )
2014

21-
# libvirt ports
22-
yq eval -i '.libvirt.bastion-port='$(( $LIBVIRT_PORT + $CLUSTER_ID ))'' ${filename}
23-
yq eval -i '.libvirt.target-port='$LIBVIRT_PORT'' ${filename}
15+
for FILENAME in profile_*.yaml
16+
do
17+
if [[ ! -f ${FILENAME} ]]
18+
then
19+
echo "${FILENAME} file missing"
20+
exit 0
21+
fi
2422

25-
yq eval -i '.api.bastion-port='$(($API_PORT + $CLUSTER_ID))'' ${filename}
26-
yq eval -i '.api.target-port='$(($API_PORT))'' ${filename}
27-
yq eval -i '.http.bastion-port='$(($HTTP_PORT + $CLUSTER_ID + 8000 ))'' ${filename}
28-
yq eval -i '.http.target-port='$(($HTTP_PORT))'' ${filename}
29-
yq eval -i '.https.bastion-port='$(($HTTPS_PORT + $CLUSTER_ID + 8000 ))'' ${filename}
30-
yq eval -i '.https.target-port='$(($HTTPS_PORT))'' ${filename}
23+
ARCH=$(yq eval '.profile.arch' ${FILENAME})
24+
CLUSTER_CAPACITY=$(yq eval '.profile.cluster_capacity' ${FILENAME})
25+
CLUSTER_ID=$(yq eval '.profile.cluster_id' ${FILENAME})
3126

32-
done
27+
# libvirt ports
28+
yq eval -i '.libvirt.bastion-port='$((${LIBVIRT_PORT} + ${CLUSTER_ID})) ${FILENAME}
29+
yq eval -i '.libvirt.target-port='${LIBVIRT_PORT} ${FILENAME}
30+
yq eval -i '.api.bastion-port='$((${API_PORT} + ${CLUSTER_ID})) ${FILENAME}
31+
yq eval -i '.api.target-port='${API_PORT} ${FILENAME}
32+
yq eval -i '.http.bastion-port='$((${HTTP_PORT} + ${CLUSTER_ID} + 8000)) ${FILENAME}
33+
yq eval -i '.http.target-port='${HTTP_PORT} ${FILENAME}
34+
yq eval -i '.https.bastion-port='$((${HTTPS_PORT} + ${CLUSTER_ID} + 8000)) ${FILENAME}
35+
yq eval -i '.https.target-port='${HTTPS_PORT} ${FILENAME}
36+
for CLUSTER_NUM in $(seq 0 ${CLUSTER_CAPACITY})
37+
do
38+
SSH_PORT=${BASTION_SSH_PORTS[${CLUSTER_NUM}]}
39+
yq eval -i '.bastion'${CLUSTER_NUM}'ssh.bastion-port='$((${SSH_PORT} + ${CLUSTER_ID})) ${FILENAME}
40+
yq eval -i '.bastion'${CLUSTER_NUM}'ssh.target-port=22' ${FILENAME}
41+
done
42+
done

libvirt/tunnel/profile_C155F2U31.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,18 @@ http:
1515
https:
1616
bastion-port: 8444
1717
target-port: 443
18+
bastion0ssh:
19+
bastion-port: 1024
20+
target-port: 22
21+
bastion1ssh:
22+
bastion-port: 1034
23+
target-port: 22
24+
bastion2ssh:
25+
bastion-port: 1044
26+
target-port: 22
27+
bastion3ssh:
28+
bastion-port: 1054
29+
target-port: 22
30+
bastion4ssh:
31+
bastion-port: 1064
32+
target-port: 22

libvirt/tunnel/profile_C155F2U33.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,18 @@ http:
1515
https:
1616
bastion-port: 8443
1717
target-port: 443
18+
bastion0ssh:
19+
bastion-port: 1023
20+
target-port: 22
21+
bastion1ssh:
22+
bastion-port: 1033
23+
target-port: 22
24+
bastion2ssh:
25+
bastion-port: 1043
26+
target-port: 22
27+
bastion3ssh:
28+
bastion-port: 1053
29+
target-port: 22
30+
bastion4ssh:
31+
bastion-port: 1063
32+
target-port: 22

libvirt/tunnel/profile_C155F2U35.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,18 @@ http:
1515
https:
1616
bastion-port: 8445
1717
target-port: 443
18+
bastion0ssh:
19+
bastion-port: 1025
20+
target-port: 22
21+
bastion1ssh:
22+
bastion-port: 1035
23+
target-port: 22
24+
bastion2ssh:
25+
bastion-port: 1045
26+
target-port: 22
27+
bastion3ssh:
28+
bastion-port: 1055
29+
target-port: 22
30+
bastion4ssh:
31+
bastion-port: 1065
32+
target-port: 22

libvirt/tunnel/profile_lnxocp01.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,21 @@ http:
1515
https:
1616
bastion-port: 8443
1717
target-port: 443
18+
bastion0ssh:
19+
bastion-port: 1023
20+
target-port: 22
21+
bastion1ssh:
22+
bastion-port: 1033
23+
target-port: 22
24+
bastion2ssh:
25+
bastion-port: 1043
26+
target-port: 22
27+
bastion3ssh:
28+
bastion-port: 1053
29+
target-port: 22
30+
bastion4ssh:
31+
bastion-port: 1063
32+
target-port: 22
33+
bastion5ssh:
34+
bastion-port: 1073
35+
target-port: 22

libvirt/tunnel/profile_lnxocp02.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,21 @@ http:
1515
https:
1616
bastion-port: 8444
1717
target-port: 443
18+
bastion0ssh:
19+
bastion-port: 1024
20+
target-port: 22
21+
bastion1ssh:
22+
bastion-port: 1034
23+
target-port: 22
24+
bastion2ssh:
25+
bastion-port: 1044
26+
target-port: 22
27+
bastion3ssh:
28+
bastion-port: 1054
29+
target-port: 22
30+
bastion4ssh:
31+
bastion-port: 1064
32+
target-port: 22
33+
bastion5ssh:
34+
bastion-port: 1074
35+
target-port: 22

libvirt/tunnel/tunnel.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,19 @@ elif [[ -z "${PORT_FRWD:-}" ]]; then
4040
fi
4141

4242
# Declaring and setting Bastion and Local ports
43-
PORTS="-R $(yq eval '.libvirt.bastion-port' ${filename}):127.0.0.1:$(yq eval '.libvirt.target-port' ${filename})
44-
-R $(yq eval '.api.bastion-port' ${filename}):127.0.0.1:$(yq eval '.api.target-port' ${filename})
45-
-R $(yq eval '.http.bastion-port' ${filename}):127.0.0.1:$(yq eval '.http.target-port' ${filename})
46-
-R $(yq eval '.https.bastion-port' ${filename}):127.0.0.1:$(yq eval '.https.target-port' ${filename}) "
43+
PORTS="-R $(yq eval '.libvirt.bastion-port' ${filename}):127.0.0.1:$(yq eval '.libvirt.target-port' ${filename})"
44+
PORTS+=" -R $(yq eval '.api.bastion-port' ${filename}):127.0.0.1:$(yq eval '.api.target-port' ${filename})"
45+
PORTS+=" -R $(yq eval '.http.bastion-port' ${filename}):127.0.0.1:$(yq eval '.http.target-port' ${filename})"
46+
PORTS+=" -R $(yq eval '.https.bastion-port' ${filename}):127.0.0.1:$(yq eval '.https.target-port' ${filename})"
47+
48+
declare -a BASTION_ADDRS=( "192.168.126.10" "192.168.1.10" "192.168.2.10" "192.168.3.10" "192.168.4.10" "192.168.6.10" )
49+
50+
for CLUSTER_NUM in $(seq 0 ${CLUSTER_CAPACITY})
51+
do
52+
BASTION_SSH=".bastion${CLUSTER_NUM}ssh"
53+
BASTION_ADDR=${BASTION_ADDRS[${CLUSTER_NUM}]}
54+
PORTS+=" -R $(yq eval ${BASTION_SSH}'.bastion-port' ${filename}):${BASTION_ADDR}:$(yq eval ${BASTION_SSH}'.target-port' ${filename})"
55+
done
4756

4857
if echo "${PORTS}" | grep null 2> /dev/null; then
4958
echo "Error: yq returned null in PORTS variable creation"
@@ -117,6 +126,8 @@ function pid-exists() {
117126
return $?
118127
}
119128

129+
echo "$(timestamp) [INFO] PORTS: ${PORTS}"
130+
120131
trap "kill 0" SIGINT
121132

122133
PID_PORT=-1

0 commit comments

Comments
 (0)