Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect coredns or kubedns service, populate in service definition yaml #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
File renamed without changes.
14 changes: 11 additions & 3 deletions hack/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@ DEFAULT_LOCALDNS_IMAGE=colopl/k8s-dns-local-dns-amd64:0.1.0

[ -z ${LOCALDNS_IMAGE} ] && LOCALDNS_IMAGE=${DEFAULT_LOCALDNS_IMAGE}

# check if using coredns or kube-dns, fall back to kube-dns if neither found
CLUSTER_DNS_BACKEND=`kubectl get services -n kube-system | egrep "^coredns |^kube-dns " | awk '{print $1}' | head -n 1`
if [[ -z $CLUSTER_DNS_BACKEND ]]; then
CLUSTER_DNS_BACKEND=kube-dns
fi

# Create the underlying uncached service
kubectl apply -f kube-dns-uncached.yaml
sed -i "s/k8s-app: kube-dns/k8s-app: ${CLUSTER_DNS_BACKEND}/g" dns-service-uncached.yaml
sed -i "s/name: kube-dns-uncached/name: ${CLUSTER_DNS_BACKEND}-uncached/g" dns-service-uncached.yaml
kubectl apply -f dns-service-uncached.yaml

# We will intercept the kube-dns service
LOCAL_DNS=`kubectl get services -n kube-system kube-dns -o=jsonpath={.spec.clusterIP}`
LOCAL_DNS=`kubectl get services -n kube-system ${CLUSTER_DNS_BACKEND} -o=jsonpath={.spec.clusterIP}`

# And we will forward misses to the uncached service we created above
UPSTREAM_DNS=`kubectl get services -n kube-system kube-dns-uncached -o=jsonpath={.spec.clusterIP}`
UPSTREAM_DNS=`kubectl get services -n kube-system ${CLUSTER_DNS_BACKEND}-uncached -o=jsonpath={.spec.clusterIP}`

# Assume the cluster DNS domain was not changed
DNS_DOMAIN=cluster.local
Expand Down