美文网首页
kubernetes集群搭建十一:测试

kubernetes集群搭建十一:测试

作者: 开始懂了90 | 来源:发表于2018-12-18 16:58 被阅读0次

部署应用

cat > test-nginx.yaml << EOF
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx-server    # 这个 Deployment 管理着那些拥有这个标签的 Pod 
  template:
    metadata:
      labels:
        app: nginx-server  # 为所有 Pod 都打上这个标签
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80
EOF

执行

kubectl apply -f test-nginx.yaml

查看

[root@k8s-master-51 ~]# kubectl get po -o wide
NAME                                READY     STATUS    RESTARTS   AGE       IP             NODE            NOMINATED NODE
nginx-deployment-697fcbbbd8-gm6xg   1/1       Running   0          4m        10.253.40.1    k8s-master-57   <none>
nginx-deployment-697fcbbbd8-hkmkj   1/1       Running   0          4m        10.253.63.68   k8s-master-51   <none>
nginx-deployment-697fcbbbd8-qbtpc   1/1       Running   0          10s       10.253.63.70   k8s-master-51   <none>

验证

[root@k8s-master-51 ~]# curl -I 10.253.63.68
HTTP/1.1 200 OK
Server: nginx/1.7.9
Date: Thu, 13 Dec 2018 10:13:49 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 23 Dec 2014 16:25:09 GMT
Connection: keep-alive
ETag: "54999765-264"
Accept-Ranges: bytes

[root@k8s-master-51 ~]# curl -I 10.253.40.1
HTTP/1.1 200 OK
Server: nginx/1.7.9
Date: Thu, 13 Dec 2018 10:14:01 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 23 Dec 2014 16:25:09 GMT
Connection: keep-alive
ETag: "54999765-264"
Accept-Ranges: bytes

[root@k8s-master-51 ~]# curl -I 10.253.63.70
HTTP/1.1 200 OK
Server: nginx/1.7.9
Date: Thu, 13 Dec 2018 10:14:06 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 23 Dec 2014 16:25:09 GMT
Connection: keep-alive
ETag: "54999765-264"
Accept-Ranges: bytes

错误记录

## IP 不在同一个网段
[root@k8s-master-51 ~]# kubectl get po -o wide
NAME                                READY     STATUS    RESTARTS   AGE       IP             NODE            NOMINATED NODE
nginx-deployment-697fcbbbd8-brvql   1/1       Running   0          1s        10.253.63.67   k8s-master-51   <none>
nginx-deployment-697fcbbbd8-mwnrg   1/1       Running   0          1s        172.17.0.3     k8s-master-52   <none>

# 其中一台kubelet.service 没有添加--network-plugin=cni

相关文章

网友评论

      本文标题:kubernetes集群搭建十一:测试

      本文链接:https://www.haomeiwen.com/subject/xxvlkqtx.html