Skip to content

Commit 116ba52

Browse files
committed
ovnkube.sh: Add new overwriting options for the gateway options and kubernetes node name
This commit adds: a) options to change ovn_gateway_opts and ovn_gateway_router_subnet by a container inside the same POD. the idea is that a init container can do an IP allocation write the output to a file and we will consume those values from the file. b) in case of ovnkube in DPU mode, we are running ovnkube on behalf of a different host, however the way we identify that is using the DPU hostname. to bypass the latter we will use the OVS metadata external_ids:host-k8s-nodename. This is already used by the ovn-node (OVN central where we have a single global zone). c) extend stateless network policies for ovnkube running in different mode types: ovn-master, ovnkube-controller and ovnkube-controller-with-node. this is useful for offloading RDMA traffic. Signed-off-by: Alin Gabriel Serdean <[email protected]>
1 parent 11ca0ec commit 116ba52

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

dist/images/ovnkube.sh

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,17 @@ ovn_nohostsubnet_label=${OVN_NOHOSTSUBNET_LABEL:-""}
324324
# should be set to true when dpu nodes are in the cluster
325325
ovn_disable_requestedchassis=${OVN_DISABLE_REQUESTEDCHASSIS:-false}
326326

327+
# external_ids:host-k8s-nodename is set on an Open_vSwitch enabled system if the ovnkube pod
328+
# should function on behalf of a different host than external_ids:host
329+
# overwrite the K8S_NODE env var with the one found within the OVS metadata in this case
330+
if [[ ${ovnkube_node_mode} == "dpu" ]]; then
331+
K8S_NODE=$(ovs-vsctl --if-exists get Open_vSwitch . external_ids:host-k8s-nodename | tr -d '\"')
332+
if [[ ${K8S_NODE} == "" ]]; then
333+
echo "Trying to run in DPU mode and couldn't get the required Host K8s Nodename. Exiting..."
334+
exit 1
335+
fi
336+
fi
337+
327338
# Determine the ovn rundir.
328339
if [[ -f /usr/bin/ovn-appctl ]]; then
329340
# ovn-appctl is present. Use new ovn run dir path.
@@ -1356,6 +1367,7 @@ ovn-master() {
13561367
${network_qos_enabled_flag} \
13571368
${ovn_enable_dnsnameresolver_flag} \
13581369
${nohostsubnet_label_option} \
1370+
${ovn_stateless_netpol_enable_flag} \
13591371
${ovn_disable_requestedchassis_flag} \
13601372
--cluster-subnets ${net_cidr} --k8s-service-cidr=${svc_cidr} \
13611373
--gateway-mode=${ovn_gateway_mode} ${ovn_gateway_opts} \
@@ -1626,6 +1638,13 @@ ovnkube-controller() {
16261638
fi
16271639
echo "ovn_observ_enable_flag=${ovn_observ_enable_flag}"
16281640

1641+
1642+
ovn_stateless_netpol_enable_flag=
1643+
if [[ ${ovn_stateless_netpol_enable} == "true" ]]; then
1644+
ovn_stateless_netpol_enable_flag="--enable-stateless-netpol"
1645+
fi
1646+
echo "ovn_stateless_netpol_enable_flag: ${ovn_stateless_netpol_enable_flag}"
1647+
16291648
echo "=============== ovnkube-controller ========== MASTER ONLY"
16301649
/usr/bin/ovnkube --init-ovnkube-controller ${K8S_NODE} \
16311650
${anp_enabled_flag} \
@@ -2054,6 +2073,11 @@ ovnkube-controller-with-node() {
20542073
fi
20552074
echo "ovn_observ_enable_flag=${ovn_observ_enable_flag}"
20562075

2076+
ovn_stateless_netpol_enable_flag=
2077+
if [[ ${ovn_stateless_netpol_enable} == "true" ]]; then
2078+
ovn_stateless_netpol_enable_flag="--enable-stateless-netpol"
2079+
fi
2080+
20572081
echo "=============== ovnkube-controller-with-node --init-ovnkube-controller-with-node=========="
20582082
/usr/bin/ovnkube --init-ovnkube-controller ${K8S_NODE} --init-node ${K8S_NODE} \
20592083
${anp_enabled_flag} \
@@ -2399,8 +2423,13 @@ ovn-node() {
23992423
wait_for_event ovs_ready
24002424
fi
24012425

2402-
echo "=============== ovn-node - (wait for ready_to_start_node)"
2403-
wait_for_event ready_to_start_node
2426+
if [[ ${ovnkube_node_mode} != "dpu-host" ]] && [[ ${ovn_enable_interconnect} != "true" ]]; then
2427+
# ready_to_start_node checks for the NB/SB readiness state.
2428+
# This is not available on the DPU host when interconnect is enabled,
2429+
# because the DBs will run locally on the DPU
2430+
echo "=============== ovn-node - (wait for ready_to_start_node)"
2431+
wait_for_event ready_to_start_node
2432+
fi
24042433

24052434
echo "ovn_nbdb ${ovn_nbdb} ovn_sbdb ${ovn_sbdb} ovn_nbdb_conn ${ovn_nbdb_conn}"
24062435

@@ -2578,12 +2607,6 @@ ovn-node() {
25782607
fi
25792608

25802609
if [[ ${ovnkube_node_mode} == "dpu" ]]; then
2581-
# in the case of dpu mode we want the host K8s Node Name and not the DPU K8s Node Name
2582-
K8S_NODE=$(ovs-vsctl --if-exists get Open_vSwitch . external_ids:host-k8s-nodename | tr -d '\"')
2583-
if [[ ${K8S_NODE} == "" ]]; then
2584-
echo "Couldn't get the required Host K8s Nodename. Exiting..."
2585-
exit 1
2586-
fi
25872610
if [[ ${ovn_gateway_opts} == "" ]]; then
25882611
# get the gateway interface
25892612
gw_iface=$(ovs-vsctl --if-exists get Open_vSwitch . external_ids:ovn-gw-interface | tr -d \")

0 commit comments

Comments
 (0)