From 81b17c5157519d24a8d1fb88bef5b41229de1828 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 2 Jun 2020 16:52:53 +0200 Subject: [PATCH] ci: pass target filename of /etc/resolv.conf in case it is a symlink In some Linux distributions the /etc/resolv.conf file is a symlink. This file gets included in the Kubernetes containers and will be used for resolving hostnames. By including the symlink, it is possible that that target file is not available in the container(s). This will cause problems when resolving hostnames, and Kubernetes will not get deployed. The default minikube VM provides /run/systemd/resolve/resolv.conf, with /etc/resolv.conf being a symlink. Therefor, it is needed to pass the `--extra-config=kubelet.resolv-conf=..` parameter to `kubeadm`. In case minikube is started with `--vm-driver=none` and /run/systemd/resolve/resolv.conf does not exist, the local /etc/resolv.conf will be used for inclusion in the Kubelet container. If this is a symlink, the final destination should get passed with `--extra-config=kubelet.resolv-conf=..` so that a working hostname resolution configuration is available in the container. Updates: #1121 Signed-off-by: Niels de Vos --- scripts/minikube.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/minikube.sh b/scripts/minikube.sh index d645d22ca..37664ed1f 100755 --- a/scripts/minikube.sh +++ b/scripts/minikube.sh @@ -78,8 +78,19 @@ fi K8S_FEATURE_GATES=${K8S_FEATURE_GATES:-"BlockVolume=true,CSIBlockVolume=true,VolumeSnapshotDataSource=true,ExpandCSIVolumes=true"} #extra-config for kube https://minikube.sigs.k8s.io/docs/reference/configuration/kubernetes/ -EXTRA_CONFIG=${EXTRA_CONFIG:-"--extra-config=apiserver.enable-admission-plugins=PodSecurityPolicy \ - --extra-config=kubelet.resolv-conf=/run/systemd/resolve/resolv.conf"} +EXTRA_CONFIG=${EXTRA_CONFIG:-"--extra-config=apiserver.enable-admission-plugins=PodSecurityPolicy"} + +# kubelet.resolv-conf needs to point to a file, not a symlink +# the default minikube VM has /etc/resolv.conf -> /run/systemd/resolve/resolv.conf +RESOLV_CONF='/run/systemd/resolve/resolv.conf' +if [[ "${VM_DRIVER}" == "none" ]] && [[ ! -e "${RESOLV_CONF}" ]]; then + # in case /run/systemd/resolve/resolv.conf does not exist, use the + # standard /etc/resolv.conf (with symlink resolved) + RESOLV_CONF="$(readlink -f /etc/resolv.conf)" +fi +# TODO: this might overload --extra-config=kubelet.resolv-conf in case the +# caller did set EXTRA_CONFIG in the environment +EXTRA_CONFIG="${EXTRA_CONFIG} --extra-config=kubelet.resolv-conf=${RESOLV_CONF}" #extra Rook configuration ROOK_BLOCK_POOL_NAME=${ROOK_BLOCK_POOL_NAME:-"newrbdpool"}