我是 K8 的新手。我已经部署了一个 nginx 服务,如下所示
kubectl describe svc nginx-nfs-service
Name: nginx-nfs-service
Namespace: default
Labels: <none>
Annotations: <none>
Selector: app=nginx
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.105.179.135
IPs: 10.105.179.135
Port: <unset> 80/TCP
TargetPort: 80/TCP
Endpoints: 172.16.222.234:80
Session Affinity: None
Events: <none>
这是运行该服务的 pod
kubectl describe pod nginx-nfs-deployment-5dd946cdd6-7hh4k
Name: nginx-nfs-deployment-5dd946cdd6-7hh4k
Namespace: default
Priority: 0
Service Account: default
Node: c1-node1/192.168.0.11
Start Time: Mon, 12 Aug 2024 07:45:11 +0200
Labels: app=nginx
pod-template-hash=5dd946cdd6
Annotations: cni.projectcalico.org/containerID: 7a0f4c8666f1d5f30050560bb5c7ef4bc5c738cbbcdb81055283b0906862f5df
cni.projectcalico.org/podIP: 172.16.222.234/32
cni.projectcalico.org/podIPs: 172.16.222.234/32
Status: Running
IP: 172.16.222.234
Controlled By: ReplicaSet/nginx-nfs-deployment-5dd946cdd6
Containers:
nginx:
Container ID: containerd://cc35872a49e107a113439459f362f1cd0ac9bc6f3b7e328f255a48fe295bbfa8
Image: nginx
Image ID: docker.io/library/nginx@sha256:6af79ae5de407283dcea8b00d5c37ace95441fd58a8b1d2aa1ed93f5511bb18c
Port: 80/TCP
Host Port: 0/TCP
State: Running
Started: Mon, 12 Aug 2024 07:45:15 +0200
Ready: True
Restart Count: 0
Environment: <none> ....
在控制平面节点上,我尝试做
curl https://10.105.179.135
但是超时了。我需要帮助来解决这个问题。我可以从控制平面 ping 托管该服务的节点。
至少我看到nginx pod使用端口80,但你想使用https(端口443)。除非您进行设置,否则不会自动重定向。
因此,如果您需要使用 https 和端口 443,您可以设置使用 TLS 证书的入口规则。