Making resolv.conf to be more flexible

Currently the script is hard coded for local.cluster as a domain name,
which is ok for the gate but limit the usage of this script for other
deployment scenarios. This PS uses the same domain name as kube-dns is
using in its command line.

Change-Id: I77294a03f61a326ba91bd2d5612986942408a71b
This commit is contained in:
Serguei Bezverkhi 2017-04-12 07:58:38 -04:00
parent 47aad34117
commit 22e6c38d90
1 changed files with 4 additions and 1 deletions

View File

@ -5,8 +5,11 @@ NAMESPACE=$1
function finish {
DNS_IP=`kubectl get svc --namespace=kube-system -l k8s-app=kube-dns -o \
jsonpath='{.items[*].spec.clusterIP}'`
DOMAIN_NAME=$(kubectl get pod --namespace=kube-system -l k8s-app=kube-dns -o \
jsonpath={..args} | grep "\-\-domain=" | awk -F '=' '{print $2}' | awk '{print $1}')
DOMAIN_NAME=${DOMAIN_NAME%%.}
cat > /tmp/$$ <<EOF
search $NAMESPACE.svc.cluster.local svc.cluster.local cluster.local
search $NAMESPACE.svc.$DOMAIN_NAME svc.$DOMAIN_NAME $DOMAIN_NAME
nameserver $DNS_IP
options ndots:5
EOF