kube-dns 命令

(1)下载kube-dns命令

# wget https://dl.k8s.io/v1.5.2/kubernetes-server-linux-amd64.tar.gz
# tar -xf kubernetes-server-linux-amd64.tar.gz
# mv /opt/docker/src/kubernetes/server/bin/kube-dns /usr/bin/

(2)新建kube-dns配置文件

# vi /etc/kubernetes/kube-dns
KUBE_DNS_PORT="--dns-port=53"
KUBE_DNS_DOMAIN="--domain=cluster.local"
KUBE_DNS_MASTER=--kube-master-url="http://192.168.40.50:8080"
KUBE_DNS_ARGS=""         

(3 ) 新建kube-dns.service配置文件

vi /usr/lib/systemd/system/kube-dns.service 
[Unit]
Description=Kubernetes Kube-dns Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=kube-apiserver.service
Requires=kube-apiserver.service
[Service]
WorkingDirectory=/var/lib/kube-dns
EnvironmentFile=-/etc/kubernetes/kube-dns
ExecStart=/usr/bin/kube-dns \
            $KUBE_DNS_PORT \
            $KUBE_DNS_DOMAIN \
            $KUBE_DNS_MASTER \
            $KUBE_DNS_ARGS
Restart=on-failure
[Install]
WantedBy=multi-user.target

(4)master启动

# mkdir -p /var/lib/kube-dns
# systemctl enable kube-dns
# systemctl restart kube-dns

(5)master修改/etc/resolv.conf文件

search default.svc.cluster.local svc.cluster.local cluster.local
nameserver 192.168.40.50
nameserver 223.5.5.5
nameserver 202.96.128.86

(6)node结点修改kubelet文件

vi /etc/kubernetes/kubelet 
# Add your own!
KUBELET_ARGS="--cluster-dns=192.168.40.50 --cluster-domain= cluster.local "

(7)检测

图片.png

参考:http://www.pangxie.space/docker/1055

你可能感兴趣的:(kube-dns 命令)