gpt4 book ai didi

ubuntu - kubernetes nginx 服务未从浏览器打开

转载 作者:行者123 更新时间:2023-12-04 18:59:03 25 4
gpt4 key购买 nike

我在 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 描述 svc nginx-service 输出:
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 描述 svc nginx-service
|-----------|----------------|-------------|------- ----------------------|
|命名空间 |姓名 |目标港口 |网址 |
|-----------|----------------|-------------|------- ----------------------|
|默认 | nginx 服务 | 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 容器。您应该将其更改为端口 80 nginx 默认监听的地方。或者,您可以更改(为什么?!)nginx 监听的端口,如 here 所述。 .

关于ubuntu - kubernetes nginx 服务未从浏览器打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69407095/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com