Skip to content

Commit

Permalink
Squash with "KIND improvements"
Browse files Browse the repository at this point in the history
Use original method of detecting API Address, but use Antonio's API_URL to pass
to daemonset.sh.

Signed-off-by: Billy McFall <22157057+Billy99@users.noreply.github.com>
  • Loading branch information
Billy99 committed Jul 25, 2020
1 parent 76124ec commit 867ccd6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 35 deletions.
54 changes: 20 additions & 34 deletions contrib/kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,34 +161,21 @@ print_params
set -euxo pipefail

# Detect IP to use as API server
API_IPV4=""
if [ "$KIND_IPV4_SUPPORT" == true ]; then
# ip -4 addr -> Run ip command for IPv4
# grep -oP '(?<=inet\s)\d+(\.\d+){3}' -> Use only the lines with the
# IPv4 Addresses and strip off the trailing subnet mask, /xx
# grep -v "127.0.0.1" -> Remove local host
# head -n 1 -> Of the remaining, use first entry
API_IPV4=$(ip -4 addr | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | grep -v "127.0.0.1" | head -n 1)
if [ -z "$API_IPV4" ]; then
echo "Error detecting machine IPv4 to use as API server"
exit 1
fi
fi

API_IPV6=""
if [ "$KIND_IPV6_SUPPORT" == true ]; then
# ip -6 addr -> Run ip command for IPv6
# grep "inet6" -> Use only the lines with the IPv6 Address
# sed 's@/.*@@g' -> Strip off the trailing subnet mask, /xx
# grep -v "^::1$" -> Remove local host
# sed '/^fe80:/ d' -> Remove Link-Local Addresses
# head -n 1 -> Of the remaining, use first entry
API_IPV6=$(ip -6 addr | grep "inet6" | awk -F' ' '{print $2}' | \
sed 's@/.*@@g' | grep -v "^::1$" | sed '/^fe80:/ d' | head -n 1)
if [ -z "$API_IPV6" ]; then
echo "Error detecting machine IPv6 to use as API server"
exit 1
fi
#
# You can't use an IPv6 address for the external API, docker does not support
# IPv6 port mapping. Always use the IPv4 host address for the API Server field.
# This will keep compatibility and people will be able to connect with kubectl
# from outside
#
# ip -4 addr -> Run ip command for IPv4
# grep -oP '(?<=inet\s)\d+(\.\d+){3}' -> Use only the lines with the
# IPv4 Addresses and strip off the trailing subnet mask, /xx
# grep -v "127.0.0.1" -> Remove local host
# head -n 1 -> Of the remaining, use first entry
API_IP=$(ip -4 addr | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | grep -v "127.0.0.1" | head -n 1)
if [ -z "$API_IP" ]; then
echo "Error detecting machine IPv4 to use as API server. Default to 0.0.0.0."
API_IP=0.0.0.0
fi

check_ipv6() {
Expand Down Expand Up @@ -230,21 +217,16 @@ if [ "$KIND_IPV6_SUPPORT" == true ]; then
fi

if [ "$KIND_IPV4_SUPPORT" == true ] && [ "$KIND_IPV6_SUPPORT" == false ]; then
API_IP=${API_IPV4}
IP_FAMILY=""
NET_CIDR=$NET_CIDR_IPV4
SVC_CIDR=$SVC_CIDR_IPV4
echo "IPv4 Only Support: API_IP=$API_IP --net-cidr=$NET_CIDR --svc-cidr=$SVC_CIDR"
elif [ "$KIND_IPV4_SUPPORT" == false ] && [ "$KIND_IPV6_SUPPORT" == true ]; then
API_IP=${API_IPV6}
IP_FAMILY="ipv6"
NET_CIDR=$NET_CIDR_IPV6
SVC_CIDR=$SVC_CIDR_IPV6
echo "IPv6 Only Support: API_IP=$API_IP --net-cidr=$NET_CIDR --svc-cidr=$SVC_CIDR"
elif [ "$KIND_IPV4_SUPPORT" == true ] && [ "$KIND_IPV6_SUPPORT" == true ]; then
#TODO DUALSTACK: Multiple IP Addresses for APIServer not currently supported.
#API_IP=${API_IPV4},${API_IPV6}
API_IP=${API_IPV4}
IP_FAMILY="DualStack"
NET_CIDR=$NET_CIDR_IPV4,$NET_CIDR_IPV6
SVC_CIDR=$SVC_CIDR_IPV4,$SVC_CIDR_IPV6
Expand Down Expand Up @@ -313,6 +295,10 @@ docker build -t ovn-daemonset-f:dev -f Dockerfile.fedora .
# and since OVN has to provide the connectivity to service
# it can not be bootstrapped

# This is the address of the node with the control-plane
# If HA, multiple control-plane nodes, KIND deploys
API_URL=$(kind get kubeconfig --internal --name ${KIND_CLUSTER_NAME} | grep server | awk '{ print $2 }')

# Create ovn-kube manifests
./daemonset.sh \
--image=docker.io/library/ovn-daemonset-f:dev \
Expand All @@ -321,7 +307,7 @@ docker build -t ovn-daemonset-f:dev -f Dockerfile.fedora .
--gateway-mode=${OVN_GATEWAY_MODE} \
--hybrid-enabled=${OVN_HYBRID_OVERLAY_ENABLE} \
--multicast-enabled=${OVN_MULTICAST_ENABLE} \
--k8s-apiserver=https://[${API_IP}]:11337 \
--k8s-apiserver=${API_URL} \
--ovn-master-count=${KIND_NUM_MASTER} \
--kind \
--master-loglevel=5
Expand Down
2 changes: 1 addition & 1 deletion contrib/kind.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: kind.x-k8s.io/v1alpha4
networking:
# the default CNI will not be installed
disableDefaultCNI: true
apiServerAddress: {{ ovn_apiServerAddress | default('11.12.13.1') }}
apiServerAddress: {{ ovn_apiServerAddress | default('0.0.0.0') }}
apiServerPort: 11337
{%- if ovn_ip_family %}
ipFamily: {{ ovn_ip_family }}
Expand Down

0 comments on commit 867ccd6

Please sign in to comment.