kubernetes配置coredns-configmap

  sre

#注意hosts域内每行后面都有空格
apiVersion: v1
kind: ConfigMap
metadata:
  name: coredns
  namespace: kube-system
data:
  Corefile: |
    .:53 {
        errors
        health
        hosts {
           192.168.2.144 mysql.host
           192.168.2.144 redis.host
           192.168.2.144 nfs.host
           fallthrough
       }
       kubernetes cluster.local in-addr.arpa ip6.arpa {
           pods insecure
           upstream
           fallthrough in-addr.arpa ip6.arpa
        }
        prometheus :9153
        proxy . /etc/resolv.conf
        cache 30
        loop
        reload
        loadbalance
    }
#!/bin/bash
echo "delete k8s-coredns.yaml...."
kubectl delete -f k8s-coredns.yaml
echo "apply k8s-coredns.yaml...."
kubectl apply -f k8s-coredns.yaml

echo "scale replicas 0 start....."
kubectl -n kube-system scale deployment coredns --replicas=0
echo "scale replicas 0 end....."
sleep 5s
echo "scale replicas 2 start....."
kubectl -n kube-system scale deployment coredns --replicas=2
echo "scale replicas 2 end....."

LEAVE A COMMENT

Captcha Code