0

I make EKS cluster like this https://learn.hashicorp.com/terraform/aws/eks-intro I use Amazon Linux 7 ( default ami-0ee5ca4231511cafc) After deploying PODs inside file /etc/resolv.conf like on node. On node:

options timeout:2 attempts:5
; generated by /usr/sbin/dhclient-script
search mysite.com
nameserver 10.200.64.2

In POD:

nameserver 10.200.64.2
search mysite.com
options timeout:2 attempts:5

Kubelet parameters:

/usr/bin/kubelet --cloud-provider aws --config /etc/kubernetes/kubelet/kubelet-config.json --allow-privileged=true --kubeconfig /var/lib/kubelet/kubeconfig --container-runtime docker --network-plugin cni --node-ip=10.200.69.73 --pod-infra-container-image=602401**.dkr.ecr.eu-central-1.amazonaws.com/eks/pause-amd64:3.1 --node-labels=env=prod --cluster_dns=172.20.0.10 --cluster-domain=cluster.local

I would like to make resolv.conf inside POD

nameserver 172.20.0.10
search cp-394211.svc.cluster.local svc.cluster.local cluster.local 
options ndots:5

Could you please help with these problem

1 Answers1

0

This link to official Kubernetes documentation should answer your question.

Your pod definition may look like this:

apiVersion: v1
kind: Pod
metadata:
  namespace: default
  name: dns-example
spec:
  containers:
    - name: test
      image: your-image
  dnsPolicy: "None"
  dnsConfig:
    nameservers:
      - 172.20.0.10
    searches:
      - cp-394211.svc.cluster.local
      - svc.cluster.local
      - cluster.local
    options:
      - name: ndots
        value: "5"

You can also apply similar configuration to your pod template specification in deployment definition. All pods in your deployment will have same dns configuration in /etc/resolv.conf. It may look like this:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80
      dnsPolicy: "None"
      dnsConfig:
        nameservers:
          - 172.20.0.10
        searches:
          - cp-394211.svc.cluster.local
          - svc.cluster.local
          - cluster.local
        options:
          - name: ndots
            value: "5"
mario
  • 525
  • 3
  • 8