commit fc72cc1af883dd2892a05ce38d50c7cd64959261 Author: Gupta, Sangeet (sg774j) Date: Tue Oct 6 15:40:00 2020 +0000 Changing the kube version to 1.18.9 Adjust configure_resolveconf to avoid passing kube-dns ip to coredns, that is suspected to create a loop with coredns 1.6.7 comming with kubeadm 1.18.9 Depends-On: https://review.opendev.org/756375 Change-Id: I509da892ca4609d50a80ade2656dd436b0a3dfc3 diff --git a/minikube-aio/Dockerfile b/minikube-aio/Dockerfile index ba47654..52b3ef1 100644 --- a/minikube-aio/Dockerfile +++ b/minikube-aio/Dockerfile @@ -26,7 +26,7 @@ Acquire::AllowInsecureRepositories \"${ALLOW_UNAUTHENTICATED}\";\n\ Acquire::AllowDowngradeToInsecureRepositories \"${ALLOW_UNAUTHENTICATED}\";" \ >> /etc/apt/apt.conf.d/allow-unathenticated -ARG KUBE_VERSION="v1.16.2" +ARG KUBE_VERSION="v1.18.9" ARG MINIKUBE_VERSION="v1.3.1" ARG CALICO_VERSION="v3.9" ARG HELM_VERSION="v2.16.9" diff --git a/minikube-aio/install.sh b/minikube-aio/install.sh index 5ca1c16..caccb1d 100755 --- a/minikube-aio/install.sh +++ b/minikube-aio/install.sh @@ -37,33 +37,30 @@ function extract { } function configure_resolvconf { - # Setup resolv.conf to use the k8s api server, which is required for the - # kubelet to resolve cluster services. - sudo mv /etc/resolv.conf /etc/resolv.conf.backup - - # Create symbolic link to the resolv.conf file managed by systemd-resolved, as - # the kubelet.resolv-conf extra-config flag is automatically executed by the - # minikube start command, regardless of being passed in here - sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf - - sudo bash -c "echo 'nameserver 10.96.0.10' >> /etc/resolv.conf" - - # NOTE(drewwalters96): Use the Google DNS servers to prevent local addresses in - # the resolv.conf file unless using a proxy, then use the existing DNS servers, - # as custom DNS nameservers are commonly required when using a proxy server. + # here with systemd-resolved disabled, we'll have 2 separate resolv.conf + # 1 - /run/systemd/resolve/resolv.conf automatically passed by minikube + # to coredns via kubelet.resolv-conf extra param + # 2 - /etc/resolv.conf - to be used for resolution on host + + kube_dns_ip="10.96.0.10" + # keep all nameservers from both resolv.conf excluding local addresses + old_ns=$(grep -P --no-filename "^nameserver\s+(?!127\.0\.0\.|${kube_dns_ip})" \ + /etc/resolv.conf /run/systemd/resolve/resolv.conf | sort | uniq) + + # Add kube-dns ip to /etc/resolv.conf for local usage + sudo bash -c "echo 'nameserver ${kube_dns_ip}' > /etc/resolv.conf" if [ -z "${HTTP_PROXY}" ]; then - sudo bash -c "echo 'nameserver 8.8.8.8' >> /etc/resolv.conf" - sudo bash -c "echo 'nameserver 8.8.4.4' >> /etc/resolv.conf" + sudo bash -c "printf 'nameserver 8.8.8.8\nnameserver 8.8.4.4\n' > /run/systemd/resolve/resolv.conf" + sudo bash -c "printf 'nameserver 8.8.8.8\nnameserver 8.8.4.4\n' >> /etc/resolv.conf" else - sed -ne "s/nameserver //p" /etc/resolv.conf.backup | while read -r ns; do - sudo bash -c "echo 'nameserver ${ns}' >> /etc/resolv.conf" - done + sudo bash -c "echo \"${old_ns}\" > /run/systemd/resolve/resolv.conf" + sudo bash -c "echo \"${old_ns}\" >> /etc/resolv.conf" fi - sudo bash -c "echo 'search svc.cluster.local cluster.local' >> /etc/resolv.conf" - sudo bash -c "echo 'options ndots:5 timeout:1 attempts:1' >> /etc/resolv.conf" - - sudo rm /etc/resolv.conf.backup + for file in /etc/resolv.conf /run/systemd/resolve/resolv.conf; do + sudo bash -c "echo 'search svc.cluster.local cluster.local' >> ${file}" + sudo bash -c "echo 'options ndots:5 timeout:1 attempts:1' >> ${file}" + done } # NOTE: Clean Up hosts file