diff --git a/cluster-up/cluster/kind-1.28/provider.sh b/cluster-up/cluster/kind-1.28/provider.sh index 0acd74b2b7..b462421336 100755 --- a/cluster-up/cluster/kind-1.28/provider.sh +++ b/cluster-up/cluster/kind-1.28/provider.sh @@ -37,6 +37,7 @@ function up() { cp $KIND_MANIFESTS_DIR/kind.yaml ${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/kind.yaml _add_kubeadm_cpu_manager_config_patch _add_extra_mounts + _add_extra_portmapping export CONFIG_WORKER_CPU_MANAGER=true kind_up diff --git a/cluster-up/cluster/kind-1.31/provider.sh b/cluster-up/cluster/kind-1.31/provider.sh index 3f10e2bc54..3c67e97e69 100755 --- a/cluster-up/cluster/kind-1.31/provider.sh +++ b/cluster-up/cluster/kind-1.31/provider.sh @@ -37,6 +37,7 @@ function up() { cp $KIND_MANIFESTS_DIR/kind.yaml ${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/kind.yaml _add_kubeadm_cpu_manager_config_patch _add_extra_mounts + _add_extra_portmapping export CONFIG_WORKER_CPU_MANAGER=true kind_up diff --git a/cluster-up/cluster/kind/common.sh b/cluster-up/cluster/kind/common.sh index 7b5666dee6..af4870463e 100755 --- a/cluster-up/cluster/kind/common.sh +++ b/cluster-up/cluster/kind/common.sh @@ -12,6 +12,10 @@ CONFIG_WORKER_CPU_MANAGER=${CONFIG_WORKER_CPU_MANAGER:-false} # avaliable value: ipv4, ipv6, dual IPFAMILY=${IPFAMILY} +# setup the port mapping for kind cluster, this is needed for some e2e tests +# KIND_PORT_MAPPING=cluster_port:host_port e.g. KIND_PORT_MAPPING=30001:30002 +KIND_PORT_MAPPING=${KIND_PORT_MAPPING} + # check CPU arch PLATFORM=$(uname -m) case ${PLATFORM} in @@ -263,6 +267,21 @@ EOF fi } +function _add_extra_portmapping() { + if [[ "$KIND_PORT_MAPPING" != "" ]]; then + IFS=':' read -r container_port host_port <<< "$KIND_PORT_MAPPING" + if [[ -z "$container_port" || -z "$host_port" ]]; then + echo "Invalid KIND_PORT_MAPPING format. Expected 'container_port:host_port'." + exit 1 + fi + cat <> ${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/kind.yaml + extraPortMappings: + - containerPort: $container_port + hostPort: $host_port +EOF +fi +} + function _add_kubeadm_cpu_manager_config_patch() { cat << EOF >> ${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/kind.yaml kubeadmConfigPatches: