二进制安装kubernetes v1.11.2 (第十五章 验证集群功能)

继续前一章部署。

15.1 验证集群功能

查看 master 状态

kubectl get componentstatuses

检查节点状态

[k8s@k8s-m1 template]$ kubectl get nodes
NAME      STATUS     ROLES     AGE       VERSION
k8s-m1    Ready      <none>    3h        v1.11.2
k8s-m2    Ready      <none>    3h        v1.11.2
k8s-n1    Ready      <none>    4h        v1.11.2
k8s-n2    Ready      <none>    4h        v1.11.2

创建测试文件

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

执行定义文件

[k8s@k8s-m1 yaml]$ kubectl apply -f nginx-ds.yml 
service/nginx-ds created
daemonset.extensions/nginx-ds created

检查执行结果

[root@k8s-m2 yaml]# kubectl get pods -o wide
NAME             READY     STATUS    RESTARTS   AGE       IP            NODE      NOMINATED NODE
nginx-ds-ggslj   0/1       Pending   0          1s        <none>        k8s-m1    <none>
nginx-ds-tkptc   1/1       Running   0          9m        172.30.27.2   k8s-m2    <none>
nginx-ds-w27qd   1/1       Running   0          9m        172.30.68.2   k8s-n1    <none>
nginx-ds-xvx29   1/1       Running   0          9m        172.30.15.2   k8s-n2    <none>

k8s-m1 节点一直处于 pending 状态,原因待确定

检查 pod ip 的连通性

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

检查服务IP和端口的可达性

[root@k8s-m2 yaml]# kubectl get svc
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)       AGE
kubernetes   ClusterIP   10.254.0.1       <none>        443/TCP       13d
nginx-ds     NodePort    10.254.182.192   <none>        80:8933/TCP   10m
  • Service Cluster IP 10.254.182.192
  • 服务端口  80
  • NodePort 端口  8933 

在所有 Node 上 curl Service IP:cluster ip 只能在pods内部访问

预期输出 nginx 欢迎页面

 

posted on 2018-11-07 17:18  冰冰爱学习  阅读(208)  评论(0编辑  收藏  举报

导航