种类群集无法在 Windows 10 上绑定端口 80



我正在使用本地 Kubernetes 集群。我尝试使用Ingress并按照官方文档中的下一条说明进行操作: https://kind.sigs.k8s.io/docs/user/ingress/#create-cluster

我的集群配置:

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 80

但看起来我不能在 Windows 上使用端口 80:

kind create cluster --config=.kuberneteskind-cluster.yaml
Creating cluster "kind" ...
• Ensuring node image (kindest/node:v1.21.1)     ...
✓ Ensuring node image (kindest/node:v1.21.1)   
• Preparing nodes      ...
✗ Preparing nodes   
ERROR: failed to create cluster: docker run error: command "docker run --hostname kind-control-plane --name kind-control-plane --label io.x-k8s.kind.role=control-plane --privileged --security-opt seccomp=unconfined --security-opt apparmor=unconfined --tmpfs /tmp --tmpfs /run --volume /var --volume /lib/modules:/lib/modules:ro --detach --tty --label io.x-k8s.kind.cluster=kind --net kind --restart=on-failure:1 --init=false --publish=0.0.0.0:80:80/TCP --publish=127.0.0.1:55805:6443/TCP -e KUBECONFIG=/etc/kubernetes/admin.conf kindest/node:v1.21.1@sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6" failed with error: exit status 125
Command Output: db8cabb573332b7f0466a0461c4b2e687350400f71bb2b04b98b337900180310
docker: Error response from daemon: Ports are not available: listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.

所以主要问题是:我可以将该端口更改为另一个端口 (30080) 吗?之后如何访问服务?

<小时 />

编辑1: 尝试使用30080端口并应用文档链接中的命令:群集启动,入口(使用nginx)启动,但我无法访问服务:

curl localhost/foo
curl : Not Found
HTTP Error 404. The requested resource is not found.
curl http://localhost:30080/foo
curl: Underlying connection closed: The connection was closed unexpectedly.

我想原因是入口默认使用端口 80:

kubectl get ingress
NAME              CLASS    HOSTS   ADDRESS     PORTS   AGE
example-ingress   <none>   *       localhost   80      5m46s

在互联网上的某个地方,我找到了解决方案(不幸的是,我没有保存原始链接)。针对我的情况,解决方案的最小实现如下:

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 80
hostPort: 8080
protocol: TCP
listenAddress: 127.0.0.1
- containerPort: 443
hostPort: 9000
protocol: TCP
listenAddress: 127.0.0.1

这使我能够使用以下方法访问我的服务:localhost:8080127.0.0.1:8080. 假设443端口用于https,但我目前没有使用它,因此无法检查其可操作性。