我在ubuntu 20.4的minikube上运行nginx pod和Loadbalancer服务。但是,我无法从浏览器打开nginx默认主页。我无法从输出端点的Yaml文件中找到任何问题。我还需要做些什么来从浏览器命中我的Nginx pod吗?
Yaml文件:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx
type: LoadBalancer
ports:
- protocol: TCP
port: 8081
nodePort: 30001
targetPort: 8080
kubectl description svc nginx-service output:
Name: nginx-service
Namespace: default
Labels: <none>
Annotations: <none>
Selector: app=nginx
Type: LoadBalancer
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.105.99.220
IPs: 10.105.99.220
Port: <unset> 8081/TCP
TargetPort: 8080/TCP
NodePort: <unset> 30001/TCP
Endpoints: 172.17.0.3:8080
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
kubectl description svc nginx-service
|-----------|---------------|-------------|-----------------------------|| namespace | name |目标端口| url ||-----------|---------------|-------------|-----------------------------|| default | nginx-service | 8081 | http://192.168.99.101:30001 ||-----------|---------------|-------------|-----------------------------|
旋度输出
curl http://192.168.99.101:30001
curl: (7) Failed to connect to 192.168.99.101 port 30001: Connection refused
您正在使用非默认端口(8080)来监听nginx容器。您应该将其更改为nginx默认侦听的端口80
。或者你可以改变(为什么? !)的端口nginx听这里描述。