【发布时间】:2022-01-17 16:10:47
【问题描述】:
我正在使用本地 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=.\kubernetes\kind-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.
我想原因是 Ingress 默认使用 80 端口:
kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
example-ingress <none> * localhost 80 5m46s
【问题讨论】:
-
can I change that port to something another (30080)?你这样做的时候发生了什么? -
@rkosegi 感谢您的回复!集群创建成功,Ingress pod 启动成功,但我无法使用
curl localhost/foo或curl http://localhost:30080/foo- 收到错误 HTTP 404 或curl: Underlying connection closed: The connection was closed unexpectedly. -
我认为如果您使用该信息更新您的问题,您将有更好的机会得到某人的回答
-
@rkosegi 添加了信息。看起来 Ingress 无论如何都使用端口 80
-
Ingress 将仅使用 80 or 443 ports。你用的是哪个版本的 Kubernetes?
标签: kubernetes yaml windows-10 kind