一、将mysql的svc名字解析成VIP地址

二、定义yaml文件,官方下载

[root@k8s-master dns]# ls
skydns-svc.yaml  skydns.yaml

三、上传需要的镜像

[root@k8s-node-2 ~]# docker image ls
gcr.io/google_containers/kubedns-amd64                             1.9                 26cf1ed9b144        3 years ago         47 MB
gcr.io/google_containers/dnsmasq-metrics-amd64                     1.0                 5271aabced07        3 years ago  
gcr.io/google_containers/kube-dnsmasq-amd64                        1.4                 3ec65756a89b        3 years ago         5.13 MB
gcr.io/google_containers/exechealthz-amd64                         1.2                 93a43bfb39bf        3 years ago         8.37 MB

四、启动dns服务

[root@k8s-master dns]# kubectl create -f skydns.yaml 
deployment "kube-dns" created
[root@k8s-master dns]# kubectl create -f skydns-svc.yaml 
service "kube-dns" created

五、查看dns的pod资源

[root@k8s-master dns]# kubectl get all -n kube-system 
NAME              DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deploy/kube-dns   1         1         1            1           39s

NAME           CLUSTER-IP       EXTERNAL-IP   PORT(S)         AGE
svc/kube-dns   10.254.230.254   <none>        53/UDP,53/TCP   27s

NAME                   DESIRED   CURRENT   READY     AGE
rs/kube-dns-32943122   1         1         1         39s

NAME                         READY     STATUS    RESTARTS   AGE
po/kube-dns-32943122-v11kh   4/4       Running   0          39s

六、节点增加dns的vip地址

[root@k8s-node-1 ~]# cat /etc/kubernetes/kubelet 
###
# kubernetes kubelet (minion) config

# The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces)
KUBELET_ADDRESS="--address=0.0.0.0"

# The port for the info server to serve on
KUBELET_PORT="--port=10250"

# You may leave this blank to use the actual hostname
KUBELET_HOSTNAME="--hostname-override=10.0.0.12"

# location of the api-server
KUBELET_API_SERVER="--api-servers=http://10.0.0.11:8080"

# pod infrastructure container
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=10.0.0.11:5000/pod-infrastructure:latest"

# Add your own!
KUBELET_ARGS="--cluster_dns=10.254.230.254 --cluster_domain=cluster.local"   #添加的vip地址,固定的

七、重启节点kubelet服务

[root@k8s-node-1 ~]# systemctl restart kubelet.service
Categories: docker&k8s

0 Comments

发表评论

Avatar placeholder

邮箱地址不会被公开。 必填项已用*标注