Add verification of the existing configuration of the custom entries support for kube-dns
@@ -604,10 +604,17 @@ function parse_options {
return 0
}
+function is_kube_dns_configured_for_custom_entries {
+ kubectl get deployment kube-dns -n kube-system -o yaml | grep -q "hostsdir=/etc/hosts.d"
+ return $?
+}
+
function prepare_kube_dns {
local static_names="$1"
+ if [ ! is_kube_dns_configured_for_custom_entries ]; then
# 1. Mount hosts config map into dnsmasq
+ print_info "Configuring kube-dns for custom entries support"
kubectl patch deployment kube-dns \
--namespace kube-system \
--type='json' \
@@ -647,6 +654,11 @@ function prepare_kube_dns {
# Just in case...
sleep 10
+ print_ok "kube-dns is configured for custom entries support"
+ else
+ print_info "kube-dns seems to be already configured for custom entries support"
+ fi
+
# 2. Add ${static_names} to the kube-dns
local custom_name_registration_results=0
IFS="," read -ra static_names_arr <<< "$static_names"
@@ -756,6 +768,10 @@ EOF
fi
fi
+ # Check if kube-dns is configured (e.g. if kube was deployed prior to this functionality added)
+ if [ ! is_kube_dns_configured_for_custom_entries ]; then
+ prepare_kube_dns
+ fi
# Trigger dns update (rollout)
kubectl patch deployment kube-dns \
-n kube-system \
