<p>I'm trying to setup a dnsmasq pod via kubernetes. Yaml file is like below:</p>
<pre><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: dnsmasq1
  labels:
    name: dnsmasq1
spec:
  serviceName: &quot;dnsmasq1&quot;
  replicas: 1
  selector:
    matchLabels:
      name: dnsmasq1
  volumeClaimTemplates:
  - metadata:
      name: dnsmasqconf-pv1
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 1Gi
      storageClassName: ceph-rbd-sc
  template:
    metadata:
      labels:
        name: dnsmasq1
    spec:
      hostNetwork: false
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchLabels:
                name: dnsmasq1
            topologyKey: &quot;kubernetes.io/hostname&quot;
      hostname: dnsmasq1
      containers:
      - name: dnsmasq1
        image: jpillora/dnsmasq
        ports:
        - containerPort: 8080
          hostPort: 8082
        imagePullPolicy: IfNotPresent
        env:
        - name: HTTP_USER
          value: &quot;****&quot;
        - name: HTTP_PASS
          value: &quot;****&quot;
        volumeMounts:
        - mountPath: /mnt/config
          name: dnsmasqconf-pv1
        resources:
          requests:
            memory: 250Mi
          limits:
            memory: 250Mi
      nodeSelector:
        etiket: worker
      dnsPolicy: &quot;None&quot;
      dnsConfig:
        nameservers:
          - 8.8.8.8
      volumes:
      - name: dnsmasqconf-pv1
        persistentVolumeClaim:
          claimName: dnsmasqconf-pv1
</code></pre>
<p>This works fine and I can reach to pod using the node's IP address. I decided to test the pod as a dns server on a test machine but the entries are not resolved. I think this is because I'm not using the Pod's IP as dns server but the node's. How can I set this pod to be used a dns server externally? I don't have a cloud provider so I don't think I can use loadbalancer IP here.</p>

Nyquillus
<p>I don't think you can use dnsmasq as external dns server as dnsmasq is a lightweight DNS forwarder, designed to provide DNSservices to a small-scale network. It can serve the names of local machines which are not in the global DNS. dnsmasq makes it simple to specify the nameserver to use for a given domain and it is ideal to manage communication in a kubernetes cluster.</p>
<p>In /etc/NetworkManager/NetworkManager.conf, add or uncomment the following line in the [main] section:</p>
<p>dns=dnsmasq</p>
<p>Create /etc/NetworkManager/dnsmasq.d/kube.conf with this line:</p>
<p>server=/cluster.local/10.90.0.10</p>
<p>This tells dnsmasq that queries for anything in the cluster.local domain should be forwarded to the DNS server at 10.90.0.10. This happens to be the default IP address of the kube-dns service in the kube-system namespace. If your cluster’s DNS service has a different IP address, you’ll need to specify it instead.</p>
<p>Now, after you run systemctl restart NetworkManager, your /etc/resolv.conf should look something like this:</p>
<p>#Generated by NetworkManager</p>
<p>search localdomain</p>
<p>nameserver 127.0.0.1</p>
<p>The important line is nameserver 127.0.0.1. This means DNS requests are sent to localhost, which is handled by dnsmasq.</p>
