2018-08-31 孙小北

二进制部署k8s集群方案之验证集群功能

养浩然之气,做博学之人

一、检查节点状态

kubectl get nodes
#NAME         STATUS    ROLES     AGE       VERSION
#kube-node1   Ready     <none>    3h        v1.10.4
#kube-node2   Ready     <none>    3h        v1.10.4
#kube-node3   Ready     <none>    3h        v1.10.4

##都为 Ready 时正常。

二、创建测试文件

cat > nginx-ds.yml <<EOF
apiVersion: v1
kind: Service
metadata:
  name: nginx-ds
  labels:
      app: nginx-ds
spec:
  type: NodePort
  selector:
      app: nginx-ds 
  ports:
    - name: http
      port: 80 
      targetPort: 80
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: nginx-ds
  labels:
      addonmanager.kubernetes.io/mode: Reconcile
spec:
  template:
      metadata: 
           labels: 
                  app: nginx-ds
      spec:
            containers:
            - name: my-nginx
              image: nginx:1.7.9
              ports:
              - containerPort: 80
EOF

三、执行定义文件

kubectl create -f nginx-ds.yml
#service "nginx-ds" created
#daemonset.extensions "nginx-ds" created

四、检查各 Node 上的 Pod IP 连通性

kubectl get pods  -o wide|grep nginx-ds
#nginx-ds-p9p5x   1/1       Running    6          15h       192.30.32.2   docker110
#nginx-ds-rsrvl   1/1       Running    5          15h       192.30.97.2   docker112
#nginx-ds-rvbdl   1/1       Running    12         15h       192.30.18.2   docker111

若有没有起来的可执行:

#kubectl describe pods nginx-ds-rsrvl 
#kubectl describe pods nginx-ds-rvbdl

可见,nginx-ds 的 Pod IP 分别是192.30.32.2、192.30.97.2、192.30.18.2,在所有 Node 上分别 ping 这三个 IP,看是否连通:

source /opt/k8s/bin/environment.sh
for node_ip in ${NODE_IPS[@]}
  do
      echo ">>> ${node_ip}"
      ssh ${node_ip} "ping -c 1 192.30.18.2"
      ssh ${node_ip} "ping -c 1 192.30.97.2"
      ssh ${node_ip} "ping -c 1 192.30.32.2"
done

五、检查服务 IP 和端口可达性

kubectl get svc |grep nginx-ds
#nginx-ds     NodePort    10.0.178.178   <none>        80:8536/TCP   9h

#可见:

#Service Cluster IP: 10.0.178.178

#服务端口:80

#NodePort 端口:8536

六、检查服务的 NodePort 可达性

source /opt/k8s/bin/environment.shfor node_ip in ${NODE_IPS[@]}
  do
    echo ">>> ${node_ip}"
    ssh ${node_ip} "curl ${node_ip}:8900"
  done

#预期输出 nginx 欢迎页面内容。

#% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

#                                 Dload  Upload   Total   Spent    Left  Speed

#  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0<!DOCTYPE html>

#<html>

#<head>

#<title>Welcome to nginx!</title>

#<style>

#    body {

#        width: 35em;

#        margin: 0 auto;

#        font-family: Tahoma, Verdana, Arial, sans-serif;

#    }

#</style>

#</head>

#<body>

#<h1>Welcome to nginx!</h1>

#<p>If you see this page, the nginx web server is successfully installed and

#working. Further configuration is required.</p>

#

#<p>For online documentation and support please refer to

#<a href="http://nginx.org/">nginx.org</a>.<br/>

#Commercial support is available at

#<a href="http://nginx.com/">nginx.com</a>.</p>

#

#<p><em>Thank you for using nginx.</em></p>

#</body>

#</html>


二进制部署k8s和Docker集群方案详细步骤【置顶】

参考:

https://www.kubernetes.org.cn/3063.html

https://www.kubernetes.org.cn/3096.html

https://github.com/opsnull/follow-me-install-kubernetes-cluster

http://www.imooc.com/article/23355

https://www.docker.com/


编辑:孙小北

本文地址: https://www.xiaowangyun.com/wyblog/detail/?id=238

版权归属: www.xiaowangyun.com   转载时请以链接形式注明出处

0 条评论

快来评论

物以类聚

最新评论

2017-10-06

一辈子不长,只有珍惜了,才不至于后悔。

2017-10-06

懂得感恩,才能走得更远。

标签云

归档

取消

感谢您的支持,您的每一次打赏都是一次鼓励!

扫码支持
每一次支持,都是不懈的动力

打开支付宝扫一扫,即可进行扫码打赏哦