Este contenido no está disponible en el idioma seleccionado.
Chapter 5. DNS Operator in OpenShift Container Platform
The DNS Operator deploys and manages CoreDNS to provide a name resolution service to pods, enabling DNS-based Kubernetes Service discovery in OpenShift Container Platform.
5.1. DNS Operator Copiar enlaceEnlace copiado en el portapapeles!
The DNS Operator implements the
dns
operator.openshift.io
Procedure
The DNS Operator is deployed during installation with a
Deployment
Use the
command to view the deployment status:oc get$ oc get -n openshift-dns-operator deployment/dns-operatorExample output
NAME READY UP-TO-DATE AVAILABLE AGE dns-operator 1/1 1 1 23hUse the
command to view the state of the DNS Operator:oc get$ oc get clusteroperator/dnsExample output
NAME VERSION AVAILABLE PROGRESSING DEGRADED SINCE dns 4.1.0-0.11 True False False 92m,AVAILABLEandPROGRESSINGprovide information about the status of the operator.DEGRADEDisAVAILABLEwhen at least 1 pod from the CoreDNS daemon set reports anTruestatus condition.Available
5.2. Controlling DNS pod placement Copiar enlaceEnlace copiado en el portapapeles!
The DNS Operator has two daemon sets: one for CoreDNS and one for managing the
/etc/hosts
/etc/hosts
As a cluster administrator, you can use a custom node selector to configure the daemon set for CoreDNS to run or not run on certain nodes.
Prerequisites
-
You installed the CLI.
oc -
You are logged in to the cluster with a user with privileges.
cluster-admin
Procedure
To prevent communication between certain nodes, configure the
API field:spec.nodePlacement.nodeSelectorModify the DNS Operator object named
:default$ oc edit dns.operator/defaultSpecify a node selector that includes only control plane nodes in the
API field:spec.nodePlacement.nodeSelectorspec: nodePlacement: nodeSelector: node-role.kubernetes.io/worker: ""
To allow the daemon set for CoreDNS to run on nodes, configure a taint and toleration:
Modify the DNS Operator object named
:default$ oc edit dns.operator/defaultSpecify a taint key and a toleration for the taint:
spec: nodePlacement: tolerations: - effect: NoExecute key: "dns-only" operators: Equal value: abc tolerationSeconds: 36001 - 1
- If the taint is
dns-only, it can be tolerated indefinitely. You can omittolerationSeconds.
5.3. View the default DNS Copiar enlaceEnlace copiado en el portapapeles!
Every new OpenShift Container Platform installation has a
dns.operator
default
Procedure
Use the
command to view the defaultoc describe:dns$ oc describe dns.operator/defaultExample output
Name: default Namespace: Labels: <none> Annotations: <none> API Version: operator.openshift.io/v1 Kind: DNS ... Status: Cluster Domain: cluster.local1 Cluster IP: 172.30.0.102 ...To find the service CIDR of your cluster, use the
command:oc get$ oc get networks.config/cluster -o jsonpath='{$.status.serviceNetwork}'
Example output
[172.30.0.0/16]
5.4. Using DNS forwarding Copiar enlaceEnlace copiado en el portapapeles!
You can use DNS forwarding to override the forwarding configuration identified in
/etc/resolv.conf
Procedure
Modify the DNS Operator object named
:default$ oc edit dns.operator/defaultThis allows the Operator to create and update the ConfigMap named
with additional server configuration blocks based ondns-default. If none of the servers has a zone that matches the query, then name resolution falls back to the name servers that are specified inServer./etc/resolv.confSample DNS
apiVersion: operator.openshift.io/v1 kind: DNS metadata: name: default spec: servers: - name: foo-server1 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:5454NoteIf
is undefined or invalid, the ConfigMap only contains the default server.serversView the ConfigMap:
$ oc get configmap/dns-default -n openshift-dns -o yamlSample 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:54541 } .: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
forwardPlugintriggers a rolling update of the CoreDNS daemon set.
5.5. DNS Operator status Copiar enlaceEnlace copiado en el portapapeles!
You can inspect the status and view the details of the DNS Operator using the
oc describe
Procedure
View the status of the DNS Operator:
$ oc describe clusteroperators/dns
5.6. DNS Operator logs Copiar enlaceEnlace copiado en el portapapeles!
You can view DNS Operator logs by using the
oc logs
Procedure
View the logs of the DNS Operator:
$ oc logs -n openshift-dns-operator deployment/dns-operator -c dns-operator