Skip to content

Commit

Permalink
Add IPv6 support for network attachements
Browse files Browse the repository at this point in the history
When NETWORK_ISOLATION_IPV6 (default: false) is true, configure the NAD for IPv6.
Likewize NETWORK_ISOLATION_IPV4 (default: true) controls if IPv4 is configured.

Enabling both IPv6 and IPv4 should work for dual stack.

Signed-off-by: Harald Jensås <[email protected]>
  • Loading branch information
hjensas committed Jan 16, 2024
1 parent f64f03e commit 120814f
Showing 1 changed file with 88 additions and 37 deletions.
125 changes: 88 additions & 37 deletions scripts/gen-netatt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@ if [ -z "${VLAN_STEP}" ]; then
echo "Please set VLAN_STEP"; exit 1
fi

if [ -z "$IPV4_ENABLED" ] && [ -z "$IPV6_ENABLED" ]; then
echo "Please enable either IPv4 or IPv6 by setting IPV4_ENABLED or IPV6_ENABLED"; exit 1
fi

if [ -n "$IPV4_ENABLED" ] && [ -n "$IPV6_ENABLED" ]; then
echo "Dual stack not supported, cannot enable both IPv4 and IPv6"; exit 1
fi


echo DEPLOY_DIR ${DEPLOY_DIR}
echo INTERFACE ${INTERFACE}
echo VLAN_START ${VLAN_START}
Expand Down Expand Up @@ -78,21 +69,36 @@ spec:
"master": "${BRIDGE_NAME}",
"ipam": {
"type": "whereabouts",
"ipRanges": [
EOF_CAT
if [ -n "$IPV4_ENABLED" ]; then
cat >> ${DEPLOY_DIR}/ctlplane.yaml <<EOF_CAT
"range": "${CTLPLANE_IP_ADDRESS_PREFIX}.0/24",
"range_start": "${CTLPLANE_IP_ADDRESS_PREFIX}.30",
"range_end": "${CTLPLANE_IP_ADDRESS_PREFIX}.70"
{
"range": "${CTLPLANE_IP_ADDRESS_PREFIX}.0/24",
"range_start": "${CTLPLANE_IP_ADDRESS_PREFIX}.30",
"range_end": "${CTLPLANE_IP_ADDRESS_PREFIX}.70"
EOF_CAT
elif [ -n "$IPV6_ENABLED" ]; then
fi
if [ -n "$IPV4_ENABLED" ] && [ -n "$IPV6_ENABLED" ]; then
cat >> ${DEPLOY_DIR}/ctlplane.yaml <<EOF_CAT
},
EOF_CAT
elif [ -n "$IPV4_ENABLED" ] && [ -z "$IPV6_ENABLED" ]; then
cat >> ${DEPLOY_DIR}/ctlplane.yaml <<EOF_CAT
"range": "${CTLPLANE_IPV6_ADDRESS_PREFIX}0/64",
"range_start": "${CTLPLANE_IPV6_ADDRESS_PREFIX}30",
"range_end": "${CTLPLANE_IPV6_ADDRESS_PREFIX}70"
}
EOF_CAT
fi
if [ -n "$IPV6_ENABLED" ]; then
cat >> ${DEPLOY_DIR}/ctlplane.yaml <<EOF_CAT
{
"range": "${CTLPLANE_IPV6_ADDRESS_PREFIX}0/64",
"range_start": "${CTLPLANE_IPV6_ADDRESS_PREFIX}30",
"range_end": "${CTLPLANE_IPV6_ADDRESS_PREFIX}70"
}
EOF_CAT
fi
cat >> ${DEPLOY_DIR}/ctlplane.yaml <<EOF_CAT
]
}
}
EOF_CAT
Expand All @@ -114,21 +120,36 @@ spec:
"master": "${INTERFACE}.${VLAN_START}",
"ipam": {
"type": "whereabouts",
"ipRanges": [
EOF_CAT
if [ -n "$IPV4_ENABLED" ]; then
cat >> ${DEPLOY_DIR}/internalapi.yaml <<EOF_CAT
"range": "172.17.0.0/24",
"range_start": "172.17.0.30",
"range_end": "172.17.0.70"
{
"range": "172.17.0.0/24",
"range_start": "172.17.0.30",
"range_end": "172.17.0.70"
EOF_CAT
fi
if [ -n "$IPV4_ENABLED" ] && [ -n "$IPV6_ENABLED" ]; then
cat >> ${DEPLOY_DIR}/internalapi.yaml <<EOF_CAT
},
EOF_CAT
elif [ -n "$IPV4_ENABLED" ] && [ -z "$IPV6_ENABLED" ]; then
cat >> ${DEPLOY_DIR}/internalapi.yaml <<EOF_CAT
}
EOF_CAT
elif [ -n "$IPV6_ENABLED" ]; then
fi
if [ -n "$IPV6_ENABLED" ]; then
cat >> ${DEPLOY_DIR}/internalapi.yaml <<EOF_CAT
"range": "fd00:bbbb::/64",
"range_start": "fd00:bbbb::30",
"range_end": "fd00:bbbb::70"
{
"range": "fd00:bbbb::/64",
"range_start": "fd00:bbbb::30",
"range_end": "fd00:bbbb::70"
}
EOF_CAT
fi
cat >> ${DEPLOY_DIR}/internalapi.yaml <<EOF_CAT
]
}
}
EOF_CAT
Expand All @@ -150,21 +171,36 @@ spec:
"master": "${INTERFACE}.$((${VLAN_START}+${VLAN_STEP}))",
"ipam": {
"type": "whereabouts",
"ipRanges": [
EOF_CAT
if [ -n "$IPV4_ENABLED" ]; then
cat >> ${DEPLOY_DIR}/storage.yaml <<EOF_CAT
"range": "172.18.0.0/24",
"range_start": "172.18.0.30",
"range_end": "172.18.0.70"
{
"range": "172.18.0.0/24",
"range_start": "172.18.0.30",
"range_end": "172.18.0.70"
EOF_CAT
fi
if [ -n "$IPV4_ENABLED" ] && [ -n "$IPV6_ENABLED" ]; then
cat >> ${DEPLOY_DIR}/storage.yaml <<EOF_CAT
},
EOF_CAT
elif [ -n "$IPV6_ENABLED" ]; then
elif [ -n "$IPV4_ENABLED" ] && [ -z "$IPV6_ENABLED" ]; then
cat >> ${DEPLOY_DIR}/storage.yaml <<EOF_CAT
"range": "fd00:cccc::/64",
"range_start": "fd00:cccc::30",
"range_end": "fd00:cccc::70"
}
EOF_CAT
fi
if [ -n "$IPV6_ENABLED" ]; then
cat >> ${DEPLOY_DIR}/storage.yaml <<EOF_CAT
{
"range": "fd00:cccc::/64",
"range_start": "fd00:cccc::30",
"range_end": "fd00:cccc::70"
}
EOF_CAT
fi
cat >> ${DEPLOY_DIR}/storage.yaml <<EOF_CAT
]
}
}
EOF_CAT
Expand All @@ -186,21 +222,36 @@ spec:
"master": "${INTERFACE}.$((${VLAN_START}+$((${VLAN_STEP}*2))))",
"ipam": {
"type": "whereabouts",
"ipRanges": [
EOF_CAT
if [ -n "$IPV4_ENABLED" ]; then
cat >> ${DEPLOY_DIR}/tenant.yaml <<EOF_CAT
"range": "172.19.0.0/24",
"range_start": "172.19.0.30",
"range_end": "172.19.0.70"
{
"range": "172.19.0.0/24",
"range_start": "172.19.0.30",
"range_end": "172.19.0.70"
EOF_CAT
fi
if [ -n "$IPV4_ENABLED" ] && [ -n "$IPV6_ENABLED" ]; then
cat >> ${DEPLOY_DIR}/tenant.yaml <<EOF_CAT
},
EOF_CAT
elif [ -n "$IPV6_ENABLED" ]; then
elif [ -n "$IPV4_ENABLED" ] && [ -z "$IPV6_ENABLED" ]; then
cat >> ${DEPLOY_DIR}/tenant.yaml <<EOF_CAT
"range": "fd00:dddd::/64",
"range_start": "fd00:dddd::30",
"range_end": "fd00:dddd::70"
}
EOF_CAT
fi
if [ -n "$IPV6_ENABLED" ]; then
cat >> ${DEPLOY_DIR}/tenant.yaml <<EOF_CAT
{
"range": "fd00:dddd::/64",
"range_start": "fd00:dddd::30",
"range_end": "fd00:dddd::70"
}
EOF_CAT
fi
cat >> ${DEPLOY_DIR}/tenant.yaml <<EOF_CAT
]
}
}
EOF_CAT
Expand Down

0 comments on commit 120814f

Please sign in to comment.