Skip to content
This repository was archived by the owner on Mar 23, 2020. It is now read-only.

Commit 55bcc6e

Browse files
committed
configure networking explicitly on each node
Due to a bug in kubernetes-nmstate/nmstate/NM, we get a random MAC address on our bridge after reboot. Because of that we get a different IP address and lose the host. With this patch, we explicitly request MAC of the NIC on the bridge. Signed-off-by: Petr Horacek <[email protected]>
1 parent 115a917 commit 55bcc6e

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

CNV/configure-network.sh

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,38 @@ BRIDGE_NAME=brext
77

88
export KUBECONFIG=${KUBECONFIG:-../OpenShift/ocp/auth/kubeconfig}
99

10+
nodes=$(oc get nodes -o jsonpath='{range .items[*]}{.metadata.name} {end}')
11+
1012
echo "Configuring networks on nodes"
13+
for node in $nodes; do
14+
echo "Detecting the default interface"
15+
while ! default_iface=$(oc get nodenetworkstate ${node} -o jsonpath="{.status.currentState.routes.running[?(@.destination==\"${MACHINE_CIDR}\")].next-hop-interface}" | cut -d " " -f 1); do
16+
sleep 10
17+
done
1118

12-
echo "Detecting the default interface"
13-
while ! default_iface=$(oc get nodenetworkstate ${node} -o jsonpath="{.items[0].status.currentState.routes.running[?(@.destination==\"${MACHINE_CIDR}\")].next-hop-interface}" | cut -d " " -f 1); do
14-
sleep 10
15-
done
19+
if [ "${default_iface}" == "${BRIDGE_NAME}" ]; then
20+
echo "Bridge ${BRIDGE_NAME} seems to be already configured as the default interface on node ${node}, skipping the rest of network setup"
21+
continue
22+
fi
1623

17-
if [ "${default_iface}" == "${BRIDGE_NAME}" ]; then
18-
echo "Bridge ${BRIDGE_NAME} seems to be already configured as the default interface, skipping the rest of network setup"
19-
exit 0
20-
fi
24+
echo "Detecting MAC address of the default interface"
25+
default_iface_mac=$(oc get nodenetworkstate ${node} -o jsonpath="{.status.currentState.interfaces[?(@.name==\"${default_iface}\")].mac-address}")
2126

22-
echo "Applying node network configuration policy"
23-
cat <<EOF | oc apply -f -
27+
echo "Applying node network configuration policy"
28+
cat <<EOF | oc apply -f -
2429
apiVersion: nmstate.io/v1alpha1
2530
kind: NodeNetworkConfigurationPolicy
2631
metadata:
27-
name: kni-policy
32+
name: kni-${node}
2833
spec:
34+
nodeSelector:
35+
kubernetes.io/hostname: ${node}
2936
desiredState:
3037
interfaces:
3138
- name: ${BRIDGE_NAME}
3239
type: linux-bridge
3340
state: up
41+
mac-address: ${default_iface_mac}
3442
ipv4:
3543
dhcp: true
3644
enabled: true
@@ -44,10 +52,10 @@ spec:
4452
port:
4553
- name: ${default_iface}
4654
EOF
55+
done
4756

4857
echo "Waiting until the configuration is done, it may take up to 5 minutes until keepalived gets reconfigured"
49-
nodes=$(oc get nodes -o jsonpath='{range .items[*]}{.metadata.name} {end}')
5058
for node in $nodes; do
5159
until [ "$(oc get nodenetworkstate ${node} -o jsonpath="{.status.currentState.routes.running[?(@.destination==\"${MACHINE_CIDR}\")].next-hop-interface}")" == "${BRIDGE_NAME}" ]; do sleep 10; done
60+
oc wait node ${node} --for condition=Ready --timeout=10m
5261
done
53-
oc wait node --all --for condition=Ready --timeout=10m

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,9 @@ The deployment process will use scripts to perform the following on the configur
8383
(#5)](https://github.com/openshift-kni/install-scripts/issues/5)
8484
for image storage.
8585
1. [Deploy
86-
CNV](https://github.com/openshift-kni/install-scripts/blob/master/CNV/deploy-cnv.sh). [Configure
87-
a bridge on the `External` interface on OpenShift nodes
88-
(#18)](https://github.com/openshift-kni/install-scripts/issues/18)
89-
to allow VMs access this network.
86+
CNV](https://github.com/openshift-kni/install-scripts/blob/master/CNV/deploy-cnv.sh).
87+
1. [Configure bridge as the default interface](https://github.com/openshift-kni/install-scripts/blob/master/CNV/configure-network.sh).
88+
Please note that this configuration has to be retriggered when new nodes are added.
9089
1. Temporarily install Ripsaw, carry out some performance tests, and
9190
capture the results.
9291

0 commit comments

Comments
 (0)