0

我得到了一个基于 CentOS8 的 K8s 集群,具有以下节点:

节点1:129.XX193(主节点1)节点2
:129.XX195(主节点2)节点3
:129.XX194(工作节点)

我使用 Kubespray (v2.15.1) 安装了 Kubernetes,主要是默认设置,它安装得很好 - 这里是 pod:

$ kubectl get pods -n kube-system
calico-kube-controllers-75f8564897-f9j48   1/1     Running   0          141m
calico-node-cx4js                          1/1     Running   0          141m
calico-node-gtcxm                          1/1     Running   0          141m
calico-node-pw9kt                          1/1     Running   0          141m
coredns-7677f9bb54-qx5w8                   1/1     Running   0          140m
coredns-7677f9bb54-ttjkm                   1/1     Running   0          140m
dns-autoscaler-6b849f6697-85v55            1/1     Running   0          140m
kube-apiserver-node1                       1/1     Running   0          144m
kube-apiserver-node2                       1/1     Running   0          143m
kube-controller-manager-node1              1/1     Running   0          144m
kube-controller-manager-node2              1/1     Running   0          143m
kube-proxy-7mjdk                           1/1     Running   0          142m
kube-proxy-dr2x2                           1/1     Running   0          142m
kube-proxy-qrpx9                           1/1     Running   0          142m
kube-scheduler-node1                       1/1     Running   0          144m
kube-scheduler-node2                       1/1     Running   0          143m
nginx-proxy-node3                          1/1     Running   0          142m
nodelocaldns-hxjmt                         1/1     Running   0          140m
nodelocaldns-jctwx                         1/1     Running   0          140m
nodelocaldns-khdsl                         1/1     Running   0          140m

现在我想使用示例 nginx 部署检查网络插件:

$ kubectl create deployment nginx --image=nginx
deployment.apps/nginx created
$ kubectl expose deployment/nginx --type="NodePort" --port=8080 --target-port=80 --overrides '{ "spec":{"ports":[{"port":8080,"targetPort":80,"protocol":"TCP","nodePort":31704}]}}'
service/nginx exposed

Pod 和服务看起来都很好:

$ kubectl get svc -n kube-system
NAME      TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)                  AGE
coredns   ClusterIP   10.X.X.3     <none>        53/UDP,53/TCP,9153/TCP   142m
nginx     NodePort    10.X.X.22   <none>        8080:31704/TCP           29m

据我了解,我现在应该能够从所有 3 个节点访问该服务,但是 3 个节点中只有 2 个在工作:

Node1 和 Node3(主机名和 IP)按预期显示所有内容:

$ curl node1:31704
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
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>

但是,当我使用 node2 时,它卡住了:

$ curl -v node2:31704
* Rebuilt URL to: node2:31704/
*   Trying 129.X.X.195...
* TCP_NODELAY set

使用内部 ClusterIP 也可以正常工作 ( curl 10.X.X.22:8080)

知道我做错了什么或需要任何进一步的信息吗?谢谢!

4

0 回答 0