018.Kubernetes二进制部署插件coredns
一修改配置文件1.1下载解压1 [root@k8smaster01 ~]# cd /opt/k8s/work/kubernetes/2 [root@k8smaster01 kubernetes]# tar -xzvf kubernetes-src.tar.gz提示:k8smaster01节点已解压完毕,可直接修改配置。1.2修改配置1 [root@k8smaster01 ~]# cd /opt/k
·
一 修改配置文件
1.1 下载解压
1 [root@k8smaster01 ~]# cd /opt/k8s/work/kubernetes/ 2 [root@k8smaster01 kubernetes]# tar -xzvf kubernetes-src.tar.gz
提示:k8smaster01节点已解压完毕,可直接修改配置。
1.2 修改配置
1 [root@k8smaster01 ~]# cd /opt/k8s/work/kubernetes/cluster/addons/dns/coredns 2 [root@k8smaster01 coredns]# cp coredns.yaml.base coredns.yaml 3 [root@k8smaster01 coredns]# source /opt/k8s/bin/environment.sh 4 [root@k8smaster01 coredns]# sed -i -e "s/__PILLAR__DNS__DOMAIN__/${CLUSTER_DNS_DOMAIN}/" -e "s/__PILLAR__DNS__SERVER__/${CLUSTER_DNS_SVC_IP}/" coredns.yaml 5 [root@k8smaster01 coredns]# vi coredns.yaml 6 …… 7 image: registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.3.1 8 …… 9 #修改image的源。
二 创建 coredns
2.1 创建coredns并检查
1 [root@k8smaster01 coredns]# kubectl create -f coredns.yaml
2.2 检查 coredns 功能
1 [root@k8smaster01 coredns]# kubectl get all -n kube-system
三 确认验证
3.1 新建Deployment
1 [root@k8smaster01 ~]# cd /opt/k8s/work 2 [root@k8smaster01 work]# cat > my-nginx.yaml <<EOF 3 apiVersion: extensions/v1beta1 4 kind: Deployment 5 metadata: 6 name: my-nginx 7 spec: 8 replicas: 2 9 template: 10 metadata: 11 labels: 12 run: my-nginx 13 spec: 14 containers: 15 - name: my-nginx 16 image: nginx:1.7.9 17 ports: 18 - containerPort: 80 19 EOF
3.2 export该Deployment
1 [root@k8smaster01 work]# kubectl expose deploy my-nginx
3.3 查看该service
1 [root@k8smaster01 work]# kubectl get services --all-namespaces | grep my-nginx 2 default my-nginx ClusterIP 10.254.157.163 <none> 80/TCP 9s 3
3.4 创建另一个pod
1 [root@k8smaster01 ~]# cd /opt/k8s/work 2 [root@k8smaster01 work]# cat > dnsutils-ds.yml <<EOF 3 apiVersion: v1 4 kind: Service 5 metadata: 6 name: dnsutils-ds 7 labels: 8 app: dnsutils-ds 9 spec: 10 type: NodePort 11 selector: 12 app: dnsutils-ds 13 ports: 14 - name: http 15 port: 80 16 targetPort: 80 17 --- 18 apiVersion: extensions/v1beta1 19 kind: DaemonSet 20 metadata: 21 name: dnsutils-ds 22 labels: 23 addonmanager.kubernetes.io/mode: Reconcile 24 spec: 25 template: 26 metadata: 27 labels: 28 app: dnsutils-ds 29 spec: 30 containers: 31 - name: my-dnsutils 32 image: tutum/dnsutils:latest 33 command: 34 - sleep 35 - "3600" 36 ports: 37 - containerPort: 80 38 EOF 39 [root@k8smaster01 work]# kubectl create -f dnsutils-ds.yml 40 [root@k8smaster01 work]# kubectl get pods -lapp=dnsutils-ds
3.5 检查解析
1 [root@k8smaster01 ~]# kubectl create clusterrolebinding kube-apiserver:kubelet-apis --clusterrole=system:kubelet-api-admin --user kubernetes 2 [root@k8smaster01 ~]# kubectl -it exec dnsutils-ds-4f2nt bash 3 root@dnsutils-ds-4f2nt:/# cat /etc/resolv.conf 4 nameserver 10.254.0.2 5 search default.svc.cluster.local svc.cluster.local cluster.local 6 options ndots:5 7 8 [root@k8smaster01 work]# kubectl exec dnsutils-ds-4f2nt nslookup kubernetes 9 [root@k8smaster01 work]# kubectl exec dnsutils-ds-4f2nt nslookup www.baidu.com 10 [root@k8smaster01 work]# kubectl exec dnsutils-ds-4f2nt nslookup my-nginx 11 [root@k8smaster01 work]# kubectl exec dnsutils-ds-4f2nt nslookup kube-dns.kube-system.svc 12 [root@k8smaster01 work]# kubectl exec dnsutils-ds-4f2nt nslookup kube-dns.kube-system.svc.cluster.local 13 [root@k8smaster01 work]# kubectl exec dnsutils-ds-4f2nt nslookup kube-dns.kube-system.svc.cluster.local.
更多推荐
已为社区贡献2条内容
所有评论(0)