Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions hack/allocate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,17 @@ dns() {
echo "${green}✅ DNS${reset}"
}

arr2yaml() {
echo -n '['
local e
local s=""
for e in "$@"; do
printf '%s"%s"' "$s" "$e";
s=", "
done
echo -n ']'
}

loadbalancer() {
echo "${blue}Installing Load Balancer (Metallb)${reset}"
$KUBECTL apply -f "https://raw.githubusercontent.com/metallb/metallb/v0.13.7/config/manifests/metallb-native.yaml"
Expand All @@ -138,7 +149,22 @@ loadbalancer() {
--timeout=300s

local kind_addr
local kind_addr6
local addr_array

kind_addr="$($CONTAINER_ENGINE container inspect func-control-plane | jq '.[0].NetworkSettings.Networks.kind.IPAddress' -r)"
kind_addr6="$($CONTAINER_ENGINE container inspect func-control-plane | jq '.[0].NetworkSettings.Networks.kind.GlobalIPv6Address' -r)"

addr_array=()

if [[ -n "$kind_addr" ]]; then
addr_array+=("$kind_addr/32");
fi

if [[ -n "$kind_addr6" ]]; then
addr_array+=("$kind_addr6/128");
fi


echo "Setting up address pool."
$KUBECTL apply -f - <<EOF
Expand All @@ -148,8 +174,7 @@ metadata:
name: example
namespace: metallb-system
spec:
addresses:
- ${kind_addr}-${kind_addr}
addresses: $(arr2yaml "${addr_array[@]}")
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
Expand Down
22 changes: 21 additions & 1 deletion hack/patch-hosts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,34 @@ function patch_hosts() {
echo "${blue}Configuring Magic DNS${reset}"

local cluster_node_addr
local cluster_node_addr6

cluster_node_addr="$(docker container inspect func-control-plane | jq ".[0].NetworkSettings.Networks.kind.IPAddress" -r)"
cluster_node_addr6="$(docker container inspect func-control-plane | jq ".[0].NetworkSettings.Networks.kind.GlobalIPv6Address" -r)"

local a_recs=""
local aaaa_recs=""

if [[ -n $cluster_node_addr ]]; then
a_recs="\
localtest.me. IN A ${cluster_node_addr}\n\
*.localtest.me. IN A ${cluster_node_addr}\n";
fi

if [[ -n $cluster_node_addr6 ]]; then
aaaa_recs="\
localtest.me. IN AAAA ${cluster_node_addr6}\n\
*.localtest.me. IN AAAA ${cluster_node_addr6}\n";
fi

$KUBECTL patch cm/coredns -n kube-system --patch-file /dev/stdin <<EOF
{
"data": {
"Corefile": ".:53 {\n errors\n health {\n lameduck 5s\n }\n ready\n kubernetes cluster.local in-addr.arpa ip6.arpa {\n pods insecure\n fallthrough in-addr.arpa ip6.arpa\n ttl 30\n }\n file /etc/coredns/example.db localtest.me\n prometheus :9153\n forward . /etc/resolv.conf {\n max_concurrent 1000\n }\n cache 30\n loop\n reload\n loadbalance\n}\n",
"example.db": "; localtest.me test file\nlocaltest.me. IN SOA sns.dns.icann.org. noc.dns.icann.org. 2015082541 7200 3600 1209600 3600\nlocaltest.me. IN A ${cluster_node_addr}\n*.localtest.me. IN A ${cluster_node_addr}\n"
"example.db": "; localtest.me test file\n\
localtest.me. IN SOA sns.dns.icann.org. noc.dns.icann.org. 2015082541 7200 3600 1209600 3600\n\
$a_recs\
$aaaa_recs"
}
}
EOF
Expand Down
Loading