This is a cache of https://docs.okd.io/4.6/networking/dns-operator.html. It is a snapshot of the page at 2024-11-18T02:47:18.933+0000.
Understanding the <strong>dns</strong> Operator | Networking | OKD 4.6
×

The dns Operator deploys and manages Coredns to provide a name resolution service to pods, enabling dns-based Kubernetes Service discovery in OpenShift.

dns Operator

The dns Operator implements the dns API from the operator.openshift.io API group. The Operator deploys Coredns using a daemon set, creates a service for the daemon set, and configures the kubelet to instruct pods to use the Coredns service IP address for name resolution.

Procedure

The dns Operator is deployed during installation with a Deployment object.

  1. Use the oc get command to view the deployment status:

    $ oc get -n openshift-dns-operator deployment/dns-operator
    Example output
    NAME           READY     UP-TO-DATE   AVAILABLE   AGE
    dns-operator   1/1       1            1           23h
  2. Use the oc get command to view the state of the dns Operator:

    $ oc get clusteroperator/dns
    Example output
    NAME      VERSION     AVAILABLE   PROGRESSING   DEGRADED   SINCE
    dns       4.1.0-0.11  True        False         False      92m

    AVAILABLE, PROGRESSING and DEGRADED provide information about the status of the Operator. AVAILABLE is True when at least 1 pod from the Coredns daemon set reports an Available status condition.

View the default dns

Every new OKD installation has a dns.operator named default.

Procedure
  1. Use the oc describe command to view the default dns:

    $ oc describe dns.operator/default
    Example output
    Name:         default
    Namespace:
    Labels:       <none>
    Annotations:  <none>
    API Version:  operator.openshift.io/v1
    Kind:         dns
    ...
    Status:
      Cluster Domain:  cluster.local (1)
      Cluster IP:      172.30.0.10 (2)
    ...
    1 The Cluster Domain field is the base dns domain used to construct fully qualified pod and service domain names.
    2 The Cluster IP is the address pods query for name resolution. The IP is defined as the 10th address in the service CIDR range.
  2. To find the service CIDR of your cluster, use the oc get command:

    $ oc get networks.config/cluster -o jsonpath='{$.status.serviceNetwork}'
Example output
[172.30.0.0/16]

Using dns forwarding

You can use dns forwarding to override the forwarding configuration identified in /etc/resolv.conf on a per-zone basis by specifying which name server should be used for a given zone. If the forwarded zone is the Ingress domain managed by OKD, then the upstream name server must be authorized for the domain.

Procedure
  1. Modify the dns Operator object named default:

    $ oc edit dns.operator/default

    This allows the Operator to create and update the ConfigMap named dns-default with additional server configuration blocks based on Server. If none of the servers has a zone that matches the query, then name resolution falls back to the name servers that are specified in /etc/resolv.conf.

    Sample dns
    apiVersion: operator.openshift.io/v1
    kind: dns
    metadata:
      name: default
    spec:
      servers:
      - name: foo-server (1)
        zones: (2)
          - example.com
        forwardPlugin:
          upstreams: (3)
            - 1.1.1.1
            - 2.2.2.2:5353
      - name: bar-server
        zones:
          - bar.com
          - example.com
        forwardPlugin:
          upstreams:
            - 3.3.3.3
            - 4.4.4.4:5454
    1 name must comply with the rfc6335 service name syntax.
    2 zones must conform to the definition of a subdomain in rfc1123. The cluster domain, cluster.local, is an invalid subdomain for zones.
    3 A maximum of 15 upstreams is allowed per forwardPlugin.

    If servers is undefined or invalid, the ConfigMap only contains the default server.

  2. View the ConfigMap:

    $ oc get configmap/dns-default -n openshift-dns -o yaml
    Sample dns ConfigMap based on previous sample dns
    apiVersion: v1
    data:
      Corefile: |
        example.com:5353 {
            forward . 1.1.1.1 2.2.2.2:5353
        }
        bar.com:5353 example.com:5353 {
            forward . 3.3.3.3 4.4.4.4:5454 (1)
        }
        .:5353 {
            errors
            health
            kubernetes cluster.local in-addr.arpa ip6.arpa {
                pods insecure
                upstream
                fallthrough in-addr.arpa ip6.arpa
            }
            prometheus :9153
            forward . /etc/resolv.conf {
                policy sequential
            }
            cache 30
            reload
        }
    kind: ConfigMap
    metadata:
      labels:
        dns.operator.openshift.io/owning-dns: default
      name: dns-default
      namespace: openshift-dns
    1 Changes to the forwardPlugin triggers a rolling update of the Coredns daemon set.
Additional resources

dns Operator status

You can inspect the status and view the details of the dns Operator using the oc describe command.

Procedure

View the status of the dns Operator:

$ oc describe clusteroperators/dns

dns Operator logs

You can view dns Operator logs by using the oc logs command.

Procedure

View the logs of the dns Operator:

$ oc logs -n openshift-dns-operator deployment/dns-operator -c dns-operator