---
# System prepended metadata

title: OpenShift 修改node / pod dns option

---

# OpenShift 修改node / pod dns option


## Pod level 


```
apiVersion: v1
kind: Pod
metadata:
  annotations:
    sidecar.istio.io/inject: "true"
  name: ubuntu-2
  labels:
    app: ubuntu
spec:
  dnsConfig:
    searches:
      - ns1.svc.cluster-domain.example
      - my.dns.search.suffix
    options:
      - name: timeout
        value: "1"
      - name: attempts
        value: "2"
  containers:
  - image: quay.io/bedrock/ubuntu:xenial-20210804
    securityContext:
      allowPrivilegeEscalation: true
      seccompProfile:
        type: RuntimeDefault
      #capabilities:
      #  drop:
      #  - ALL
    command:
      - "sleep"
      - "604800"
    imagePullPolicy: IfNotPresent
    name: ubuntu
  restartPolicy: Always
```

## Node Level


利用nmstate operator

OCP 4.14後可設定option

```
apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
  name: 99-okd-resolvconf
spec:
  nodeSelector:
    node-role.kubernetes.io/master: ""
  desiredState:
    dns-resolver:
      config:
        server:
        # 一定要補上原本resolv.conf內的server
        - 8.8.8.8 
        options:
        - rotate
        - ndot:9
        - timeout:1
        - attempts:2
```