我在我的RedHat EC2实例上安装了Minikube v1.3.1进行一些测试。
由于nginx-ingress-controller默认使用的端口已经被占用,我尝试在部署中更改它们但没有成功。请问有人能指导如何操作吗?
如何确定端口已经被占用?
当我使用命令kubectl -n kube-system get deployment | grep nginx
列出系统pod时,我得到:
nginx-ingress-controller 0/1 1 0 9d
这意味着我的容器未启动。当我使用命令kubectl -n kube-system describe pod nginx-ingress-controller-xxxxx
描述它时,我得到:
Type Reason Age From
Message ---- ------ ----
---- ------- Warning FailedCreatePodSandBox 42m (x163507 over 2d1h) kubelet, minikube (combined from similar events): Failed create pod sandbox: rpc error: code = Unknown desc = failed to start sandbox container for pod "nginx-ingress-controller-xxxx": Error response from daemon: driver failed programming external connectivity on endpoint k8s_POD_nginx-ingress-controller-xxxx_kube-system_...: Error starting userland proxy: listen tcp 0.0.0.0:443: bind: address already in use
然后我检查了使用这些端口的进程并将它们杀掉。这样可以释放它们,使ingress-controller pod成功部署。
我尝试更改nginx-ingress-controller端口的操作是什么?
kubectl -n kube-system get deployment | grep nginx
> NAME READY UP-TO-DATE AVAILABLE AGE
> nginx-ingress-controller 0/1 1 0 9d
kubectl -n kube-system edit deployment nginx-ingress-controller
我的部署内容中相关部分如下:
部署的关键步骤如下:
name: nginx-ingress-controller
ports:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
- containerPort: 81
hostPort: 81
protocol: TCP
- containerPort: 444
hostPort: 444
protocol: TCP
- containerPort: 18080
hostPort: 18080
protocol: TCP
我先移除了端口为443和80的子部分,但是当我推出更改后,它们又被添加回来了。
现在我的服务通过Ingress无法访问。