Skip to content

Commit

Permalink
Squash with "KIND improvements"
Browse files Browse the repository at this point in the history
Go back and use Antonio's method of detecting API Address.

Signed-off-by: Billy McFall <22157057+Billy99@users.noreply.github.com>
  • Loading branch information
Billy99 committed Jul 24, 2020
1 parent 43853b6 commit 39bee80
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 44 deletions.
53 changes: 10 additions & 43 deletions contrib/kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,37 +160,6 @@ 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
fi

check_ipv6() {
# Collect additional IPv6 data on test environment
ERROR_FOUND=false
Expand Down Expand Up @@ -236,25 +205,20 @@ 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"
echo "IPv4 Only Support: --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"
echo "IPv6 Only Support: --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
echo "Dual Stack Support: API_IP=$API_IP --net-cidr=$NET_CIDR --svc-cidr=$SVC_CIDR"
echo "Dual Stack Support: --net-cidr=$NET_CIDR --svc-cidr=$SVC_CIDR"
else
echo "Invalid setup. KIND_IPV4_SUPPORT and/or KIND_IPV6_SUPPORT must be true."
exit 1
Expand All @@ -263,15 +227,14 @@ fi
# Output of the j2 command
KIND_CONFIG_LCL=./kind.yaml

ovn_apiServerAddress=${API_IP} \
ovn_ip_family=${IP_FAMILY} \
ovn_ip_family=${IP_FAMILY} \
ovn_ha=${KIND_HA} \
ovn_num_master=${KIND_NUM_MASTER} \
ovn_num_worker=${KIND_NUM_WORKER} \
j2 ${KIND_CONFIG} -o ${KIND_CONFIG_LCL}

# Create KIND cluster. For additional debug, add '--verbosity <int>': 0 None .. 3 Debug
kind create cluster --name ${KIND_CLUSTER_NAME} --kubeconfig ${HOME}/admin.conf --image kindest/node:${K8S_VERSION} --config=${KIND_CONFIG_LCL}
kind create cluster --name ${KIND_CLUSTER_NAME} --verbosity 5 --kubeconfig ${HOME}/admin.conf --image kindest/node:${K8S_VERSION} --config=${KIND_CONFIG_LCL}
export KUBECONFIG=${HOME}/admin.conf
cat ${KUBECONFIG}

Expand Down Expand Up @@ -319,6 +282,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 @@ -327,7 +294,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: '0.0.0.0'
apiServerPort: 11337
{%- if ovn_ip_family %}
ipFamily: {{ ovn_ip_family }}
Expand Down

0 comments on commit 39bee80

Please sign in to comment.