0

Dnsjava is an implementation of DNS in Java. We have built some of our application logic around it.. Just wanted to check if Kubernetes would support DNS interfaces at application level

Yukti Kaura
  • 55
  • 1
  • 11

3 Answers3

1

Not entirely sure what you mean, but Kubernetes doesn't care what you run on it. Your workloads are your problem :)

coderanger
  • 52,400
  • 4
  • 52
  • 75
0

You can configure your DNS Pod and customize the DNS resolution process in Kubernetes.

DNS is a built-in Kubernetes service launched automatically using the addon manager cluster add-on.

CoreDNS is the most popular DNS Server, replacing kube-dns.

The CoreDNS Deployment is exposed as a Kubernetes Service with a static IP. Both the CoreDNS and kube-dns Service are named kube-dns in the metadata.name field. This is done so that there is greater interoperability with workloads that relied on the legacy kube-dns Service name to resolve addresses internal to the cluster. It abstracts away the implementation detail of which DNS provider is running behind that common endpoint. The kubelet passes DNS to each container with the --cluster-dns= flag.

DNS names also need domains. You configure the local domain in the kubelet with the flag --cluster-domain=<default-local-domain>.

The DNS server enable port lookups, forward lookups and reverse IP address lookups (PTR records).

If a Pod’s dnsPolicy is set to “default”, it inherits the name resolution configuration from the node that the Pod runs on. The Pod’s DNS resolution should behave the same as the node. But see Known issues.

If you don’t want this, or if you want a different DNS config for pods, you can use the kubelet’s --resolv-conf flag. Set this flag to “” to prevent Pods from inheriting DNS. Set it to a valid file path to specify a file other than /etc/resolv.conf for DNS inheritance.

For each pod there is possibility to set DNS policies. Kubernetes supports below DNS polices:

  • Default: this value is set for the pods which get the name resolution configuration from the node that specific pod is run on.
  • ClusterFirst: this value is set for any DNS query that does not match the configured cluster domain suffix, example: www.kubernetes.io
  • ClusterFirstWithHostNet: this value is set if pods are running with hostNetwork
  • None: this value let pods to skip DNS settings within the Kubernetes environment. All DNS settings are supposed to be provided using the dnsConfig field in the Pod Spec.

Take notice that “Default” value is not as the same time the default DNS policy. If dnsPolicy is not specified, then default value for DNS policy is “ClusterFirst”.

Here is example of pod configuration file with specific DNS policy:

apiVersion: v1
kind: Pod
metadata:
  name: dns-example
spec:
  containers:
  - name: dns-test
    image: eg_postgresql:latest
    command:
      - sleep
      - "4000"
    imagePullPolicy: IfNotPresent
    name: eg_postgresql
  restartPolicy: Always
  hostNetwork: true
  dnsPolicy: ClusterFirstWithHostNet

Read more here: dns-kubernetes, dns-services-pod.

Malgorzata
  • 6,409
  • 1
  • 10
  • 27
0

Yes - your application running on Kubernetes can interface with/call the Kubernetes DNS that's running in the same cluster...if that is what the question is about. :-)

If you have proper access, you can customize the DNS in Kubernetes.

Check out the "Pod's DNS Policy" and "Pod's DNS Config" sections in the docs for how configuring the dnsPolicy and dnsConfig fields in a Deployment/Pod configuration allow more control of the DNS settings for a Deployment/Pod.

gears
  • 690
  • 3
  • 6