Skip to content

Commit

Permalink
[hack] KinD setup - get podman network info (#8008)
Browse files Browse the repository at this point in the history
* get podman network info

* don't disable IPv6 anymore

* ip-family option

* install istio script to enable dual stack if ipv6 is not disabled
  • Loading branch information
jmazzitelli authored Dec 20, 2024
1 parent a715717 commit 34ff12b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
17 changes: 16 additions & 1 deletion hack/istio/install-istio-via-istioctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ while [[ $# -gt 0 ]]; do
shift;shift
;;
-d6|--disable-ipv6)
DISABLE_IPV6="$2"
if [ "${2}" == "true" ] || [ "${2}" == "false" ]; then
DISABLE_IPV6="$2"
else
echo "ERROR: The --disable-ipv6 flag must be 'true' or 'false'"
exit 1
fi
shift;shift
;;
-pu|--purge-uninstall)
Expand Down Expand Up @@ -376,6 +381,15 @@ if [ "${CONFIG_PROFILE}" == "ambient" ] && [ "${DISABLE_IPV6}" == "true" ]; then
echo "Disabling Ambient CNI IPv6"
fi

if [ "${DISABLE_IPV6}" == "false" ]; then
DUALSTACK_OPTIONS=" \
--set meshConfig.defaultConfig.proxyMetadata.ISTIO_DUAL_STACK=true \
--set values.pilot.env.ISTIO_DUAL_STACK=true \
--set values.pilot.ipFamilyPolicy=RequireDualStack \
--set values.gateways.istio-ingressgateway.ipFamilyPolicy=RequireDualStack \
--set values.gateways.istio-egressgateway.ipFamilyPolicy=RequireDualStack"
fi

MTLS_OPTIONS="--set values.meshConfig.enableAutoMtls=${MTLS}"

NATIVE_SIDECARS_OPTIONS="--set values.pilot.env.ENABLE_NATIVE_SIDECARS=${ENABLE_NATIVE_SIDECARS}"
Expand Down Expand Up @@ -491,6 +505,7 @@ for s in \
"${MESH_ID_OPTION}" \
"${NETWORK_OPTION}" \
"${REDUCE_RESOURCES_OPTIONS}" \
"${DUALSTACK_OPTIONS}" \
"${CUSTOM_INSTALL_SETTINGS}"
do
MANIFEST_CONFIG_SETTINGS_TO_APPLY="${MANIFEST_CONFIG_SETTINGS_TO_APPLY} ${s}"
Expand Down
19 changes: 16 additions & 3 deletions hack/start-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ IMAGE=""
LOAD_BALANCER_RANGE="255.70-255.84"
KEYCLOAK_ISSUER_URI=""
KEYCLOAK_CERTS_DIR=""
IP_FAMILY="ipv4" # or "dual"

# for now these are fixed unless you override with env vars (no cmdline opts)
KIND_IMAGE_REGISTRY_NAME="${KIND_IMAGE_REGISTRY_NAME:-kind-registry}"
Expand Down Expand Up @@ -45,6 +46,8 @@ Options:
Default: false
-i|--image
Image of the kind cluster. Defaults to latest kind image if not specified.
-if|--ip-family
Can be "ipv4" if only IPv4 network is enabled, or "dual" if dual-stack is supported. Default: ipv4
-kcd|--keycloak-certs-dir
Directory where the keycloak certs are stored.
-kiu|--keycloak-issuer-uri
Expand All @@ -66,6 +69,7 @@ while [[ $# -gt 0 ]]; do
-ek|--enable-keycloak) ENABLE_KEYCLOAK="$2"; shift;shift; ;;
-eir|--enable-image-registry) ENABLE_IMAGE_REGISTRY="$2"; shift;shift; ;;
-i|--image) IMAGE="$2"; shift;shift; ;;
-if|--ip-family) IP_FAMILY="$2"; shift;shift; ;;
-kcd|--keycloak-certs-dir) KEYCLOAK_CERTS_DIR="$2"; shift;shift; ;;
-kiu|--keycloak-issuer-uri) KEYCLOAK_ISSUER_URI="$2"; shift;shift; ;;
-lbr|--load-balancer-range) LOAD_BALANCER_RANGE="$2"; shift;shift; ;;
Expand Down Expand Up @@ -107,7 +111,11 @@ start_image_registry_daemon() {
# see: https://kind.sigs.k8s.io/docs/user/local-registry/
if [ "${ENABLE_IMAGE_REGISTRY}" == "true" ]; then
if [ "$(${DORP} inspect -f '{{.State.Running}}' ${KIND_IMAGE_REGISTRY_NAME} 2>/dev/null || true)" != "true" ]; then
${DORP} run --sysctl=net.ipv6.conf.all.disable_ipv6=1 -d --restart=always -p "127.0.0.1:${KIND_IMAGE_REGISTRY_PORT}:5000" --name "${KIND_IMAGE_REGISTRY_NAME}" --network bridge registry:2
_disable_ipv6="0"
if [ "${IP_FAMILY}" == "ipv4" ]; then
_disable_ipv6="1"
fi
${DORP} run --sysctl=net.ipv6.conf.all.disable_ipv6=${_disable_ipv6} -d --restart=always -p "127.0.0.1:${KIND_IMAGE_REGISTRY_PORT}:5000" --name "${KIND_IMAGE_REGISTRY_NAME}" --network bridge registry:2
infomsg "An image registry daemon has started."
else
infomsg "An image registry daemon appears to already be running; this existing daemon will be used."
Expand Down Expand Up @@ -209,12 +217,13 @@ fi
start_kind() {
# Due to: https://github.com/kubernetes-sigs/kind/issues/1449#issuecomment-1612648982 we need two nodes.
infomsg "Kind cluster to be created with name [${NAME}]"
infomsg "networking.ipFamily will be set to [${IP_FAMILY}]"
KIND_NODE_IMAGE=${IMAGE:+image: ${IMAGE}}
cat <<EOF | ${KIND_EXE} create cluster --name "${NAME}" --config -
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
ipFamily: ipv4
ipFamily: ${IP_FAMILY}
$(echo_keycloak_kubeadm_config)
nodes:
- role: control-plane
Expand Down Expand Up @@ -247,8 +256,12 @@ config_metallb() {
subnet=""
fi
done
if [ -z "$subnet" ]; then
infomsg "No subnets found in the expected docker network list. Maybe this is a podman network - let's check"
subnet=$(docker network inspect kind | jq -r '.[0].subnets[] | select(.subnet | test("^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+/")) | .subnet' 2>/dev/null)
fi
else
subnet=$(podman network inspect kind --format '{{ (index (index (index .plugins 0).ipam.ranges 1) 1).subnet }}' 2>/dev/null)
subnet=$(podman network inspect kind | jq -r '.[0].subnets[] | select(.subnet | test("^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+/")) | .subnet' 2>/dev/null)
fi

if [ -z "$subnet" ]; then
Expand Down

0 comments on commit 34ff12b

Please sign in to comment.