2.8 测试集群

创建一个 deploymentservice 进行测试

kubectl create deployment nginx --image=nginx:1.20.1-alpine
kubectl expose deployment/nginx --name=nginx --port=80 --type=NodePort
kubectl get po

输出如下

NAME                     READY   STATUS    RESTARTS   AGE
nginx-779c9459b8-dp4tq   0/1     Pending   0          22s

查看描述

kubectl describe po nginx-779c9459b8-dp4tq
  Warning  FailedScheduling  46s   default-scheduler  0/3 nodes are available: 3 node(s) had taint {node-role.kubernetes.io/master: }, that the pod didn't tolerate.

因为这里的实验环境 3 台 master 节点,同时充当 worker 节点使用,生产环境建议保留,使用单独的 worker 节点来调度。

需要把 master 标签和污点去掉,默认 master 无法调度

去除 master 标签

kubectl label node k8s-m1 node-role.kubernetes.io/master-
kubectl label node k8s-m2 node-role.kubernetes.io/master-
kubectl label node k8s-m3 node-role.kubernetes.io/master-

去除污点

kubectl taint node k8s-m1 node-role.kubernetes.io/master:NoSchedule-
kubectl taint node k8s-m2 node-role.kubernetes.io/master:NoSchedule-
kubectl taint node k8s-m3 node-role.kubernetes.io/master:NoSchedule-

再次检查,已经正常调度到 master 节点了

kubectl get po
NAME                     READY   STATUS              RESTARTS   AGE
nginx-779c9459b8-dp4tq   0/1     ContainerCreating   0          2m4s

查看 podservice

kubectl get svc -l app=nginx

输出如下

NAME    TYPE       CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
nginx   NodePort   10.100.168.172   <none>        80:30009/TCP   2m5s

访问测试

curl 10.100.168.172

输出如下

<!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>

查看 ipvs 规则

ipvsadm -L -n

输出如下

IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  172.17.0.1:30009 rr
  -> 10.244.42.129:80             Masq    1      0          0
TCP  192.168.122.10:30009 rr
  -> 10.244.42.129:80             Masq    1      0          0
TCP  10.96.0.1:443 rr
  -> 192.168.122.10:6443          Masq    1      1          0
  -> 192.168.122.20:6443          Masq    1      1          0
  -> 192.168.122.30:6443          Masq    1      2          0
TCP  10.96.0.10:53 rr
  -> 10.244.11.1:53               Masq    1      0          0
  -> 10.244.11.2:53               Masq    1      0          0
TCP  10.96.0.10:9153 rr
  -> 10.244.11.1:9153             Masq    1      0          0
  -> 10.244.11.2:9153             Masq    1      0          0
TCP  10.100.168.172:80 rr
  -> 10.244.42.129:80             Masq    1      0          1
TCP  10.244.42.128:30009 rr
  -> 10.244.42.129:80             Masq    1      0          0
UDP  10.96.0.10:53 rr
  -> 10.244.11.1:53               Masq    1      0          0
  -> 10.244.11.2:53               Masq    1      0          0

看到上面的,说明已经正常使用 ipvs 模式了。

Copyright © huangzhongde.cn 2021 all right reserved,powered by Gitbook该文件修订时间: 2022-01-28 00:02:24

results matching ""

    No results matching ""