Adding nameservers to kubernetes

0 votes

I'm using Kubernetes v1.0.6 on AWS that has been deployed using kube-up.sh.
Cluster is using kube-dns.

$ kubectl get svc kube-dns --namespace=kube-system
NAME       LABELS                                                                           SELECTOR           IP(S)       PORT(S)
kube-dns   k8s-app=kube-dns,kubernetes.io/cluster-service=true,kubernetes.io/name=KubeDNS   k8s-app=kube-dns   10.0.0.10   53/UDP

Which works fine.

$ kubectl exec busybox -- nslookup kubernetes.default
Server:    10.0.0.10
Address 1: 10.0.0.10 ip-10-0-0-10.eu-west-1.compute.internal
Name:      kubernetes.default
Address 1: 10.0.0.1 ip-10-0-0-1.eu-west-1.compute.internal

This is the resolv.conf of a pod.

$ kubectl exec busybox -- cat /etc/resolv.conf
nameserver 10.0.0.10
nameserver 172.20.0.2
search default.svc.cluster.local svc.cluster.local cluster.local eu-west-1.compute.internal

Is it possible to have the containers use an additional nameserver?

I would like my kubernetes containers to be able to use for dns resolution.

Sep 3, 2018 in Kubernetes by Hannah
• 18,570 points
914 views

2 answers to this question.

0 votes

A safe way to maybe do this would be adding the nameserver in skydns' configuration.

answered Sep 3, 2018 by Nilesh
• 7,050 points
0 votes

For those usign Kubernetes kube-dns, flag -nameservers nor environment variable SKYDNS_NAMESERVERS are no longer avaiable.

Usage of /kube-dns:
  --alsologtostderr                  log to standard error as well as files
  --config-map string                config-map name. If empty, then the config-map will not used. Cannot be  used in conjunction with federations flag. config-map contains dynamically adjustable configuration.
  --config-map-namespace string      namespace for the config-map (default "kube-system")
  --dns-bind-address string          address on which to serve DNS requests. (default "0.0.0.0")
  --dns-port int                     port on which to serve DNS requests. (default 53)
  --domain string                    domain under which to create names (default "cluster.local.")
  --healthz-port int                 port on which to serve a kube-dns HTTP readiness probe. (default 8081)
  --kube-master-url string           URL to reach kubernetes master. Env variables in this flag will be expanded.
  --kubecfg-file string              Location of kubecfg file for access to kubernetes master service; --kube-master-url overrides the URL part of this; if neither this nor --kube-master-url are provided, defaults to service account tokens
  --log-backtrace-at traceLocation   when logging hits line file:N, emit a stack trace (default :0)
  --log-dir string                   If non-empty, write log files in this directory
  --log-flush-frequency duration     Maximum number of seconds between log flushes (default 5s)
  --logtostderr                      log to standard error instead of files (default true)
  --stderrthreshold severity         logs at or above this threshold go to stderr (default 2)
  -v, --v Level                      log level for V logs
  --version version[=true]           Print version information and quit
  --vmodule moduleSpec               comma-separated list of pattern=N settings for file-filtered logging

Now, either you put your name servers on the hosts resolv.conf, so DNS is inherited from the node, or you use custom resolv.conf and add it to Kubelet with the flag --resolv-conf  

answered Sep 3, 2018 by Kalgi
• 52,360 points

Related Questions In Kubernetes

0 votes
1 answer

Adding users to kubernetes

Follow these steps: create service account for user Alice kubectl ...READ MORE

answered Sep 5, 2018 in Kubernetes by Kalgi
• 52,360 points
2,085 views
+5 votes
2 answers

Redirecting host to service path in kubernetes

What you are trying to do is ...READ MORE

answered Mar 27, 2018 in Kubernetes by DragonLord999
• 8,450 points
3,175 views
0 votes
1 answer

unable to start Kubernetes due to so many open files in system

You can try the following steps: You can ...READ MORE

answered May 1, 2018 in Kubernetes by shubham
• 7,340 points
1,820 views
0 votes
1 answer

How to use gravitational teleport in a container/kubernetes environment?

You can use teleport to augment kubernetes ...READ MORE

answered Jun 28, 2018 in Kubernetes by ajs3033
• 7,300 points
2,229 views
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
14,614 views
+4 votes
1 answer

Installing Web UI (Dashboard):kubernetes-dashboard on main Ubuntu 16.04.6 LTS (Xenial Xerus) server

Follow these steps: $ kubeadm reset $ kubeadm init ...READ MORE

answered Apr 12, 2019 in Kubernetes by Kalgi
• 52,360 points

reshown Apr 12, 2019 by Kalgi 6,106 views
0 votes
2 answers

Deny access to some specific paths while using kubernetes ingress

Try to create two Ingresses first by default ...READ MORE

answered Sep 21, 2018 in Kubernetes by Nilesh
• 7,050 points
11,531 views
0 votes
2 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP