Skip to content

Commit

Permalink
Move kindnet workaround to deploy script
Browse files Browse the repository at this point in the history
Since the workaround is Submariner specific, it should be part of the
deploy stage and not part of the cluster creation stage which is
agnostic to Submariner.

Signed-off-by: Mike Kolesnik <[email protected]>
  • Loading branch information
mkolesnik committed Dec 12, 2023
1 parent c2655fe commit 4a9aa75
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
20 changes: 20 additions & 0 deletions scripts/shared/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,25 @@ function declare_global_cidrs() {
done
}

# This is a workaround and can be removed once we switch the CNI from kindnet to a different one.
# In order to support health-check and hostNetwork use-cases, submariner requires an IPaddress from the podCIDR
# for each node in the cluster. Normally, most of the CNIs create a cniInterface on the host and assign an IP
# from the podCIDR to the interface. Submariner relies on this interface to support the aforementioned use-cases.
# However, with kindnet CNI, it was seen that it does not create a dedicated CNI Interface on the nodes.
# But as soon as a pod is scheduled on a node, it creates a veth-xxx interface which has an IPaddress from the
# podCIDR. In this workaround, we are scheduling a dummy pod as a demonSet on the cluster to trigger the creation
# of this veth-xxx interface which can be used as a cniInterface and we can continue to validate Submariner use-cases.
function schedule_dummy_pod() {
[[ -z "${cluster_cni[$cluster]}" ]] || return 0
local ns="subm-kindnet-workaround"
source "${SCRIPTS_DIR}"/lib/deploy_funcs
import_image "${REPO}/nettest"

echo "Creating the ${ns} namespace..."
kubectl create namespace "${ns}" || :
deploy_resource "${RESOURCES_DIR}"/dummypod.yaml "$ns"
}

### Main ###

load_settings
Expand All @@ -123,6 +142,7 @@ declare_kubeconfig

load_library deploy DEPLOYTOOL
deploytool_prereqs
[[ "$PROVIDER" == kind ]] || run_all_clusters schedule_dummy_pod

run_if_defined pre_deploy

Expand Down
19 changes: 0 additions & 19 deletions scripts/shared/lib/clusters_kind
Original file line number Diff line number Diff line change
Expand Up @@ -116,29 +116,10 @@ function provider_create_cluster() {
kind create cluster ${image_flag:+"$image_flag"} --name="${cluster}" --config="${RESOURCES_DIR}/${cluster}-config.yaml"
kind_fixup_config

[[ -n "${cluster_cni[$cluster]}" ]] || delete_cluster_on_fail schedule_dummy_pod
[[ "$LOAD_BALANCER" != true ]] || delete_cluster_on_fail deploy_load_balancer
[[ "$AIR_GAPPED" != true ]] || air_gap_iptables
}

# This is a workaround and can be removed once we switch the CNI from kindnet to a different one.
# In order to support health-check and hostNetwork use-cases, submariner requires an IPaddress from the podCIDR
# for each node in the cluster. Normally, most of the CNIs create a cniInterface on the host and assign an IP
# from the podCIDR to the interface. Submariner relies on this interface to support the aforementioned use-cases.
# However, with kindnet CNI, it was seen that it does not create a dedicated CNI Interface on the nodes.
# But as soon as a pod is scheduled on a node, it creates a veth-xxx interface which has an IPaddress from the
# podCIDR. In this workaround, we are scheduling a dummy pod as a demonSet on the cluster to trigger the creation
# of this veth-xxx interface which can be used as a cniInterface and we can continue to validate Submariner use-cases.
function schedule_dummy_pod() {
local ns="subm-kindnet-workaround"
source "${SCRIPTS_DIR}"/lib/deploy_funcs
import_image "${REPO}/nettest"

echo "Creating the ${ns} namespace..."
kubectl create namespace "${ns}" || :
deploy_resource "${RESOURCES_DIR}"/dummypod.yaml "$ns"
}

function delete_cluster_on_fail() {
( "$@"; ) &
if ! wait $! ; then
Expand Down

0 comments on commit 4a9aa75

Please sign in to comment.