【发布时间】:2021-07-14 06:12:03
【问题描述】:
为什么每次我尝试连接到 MicroK8s 上的 nodeport 暴露服务时,连接都会被拒绝?
下面是部署、服务和入口:
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx-container
image: 'nginx'
ports:
- containerPort: 80
---
kind: Service
apiVersion: v1
metadata:
name: nginx
labels:
app: nginx
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 80
selector:
app: nginx
type: NodePort
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx.info
labels:
app: 'nginx'
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- host: 'nginx.plz'
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: 'nginx'
port:
number: 80
我的/etc/hosts 文件中也包含以下行:
127.0.0.1 nginx.plz
但是,当我尝试访问该站点时,我继续收到以下错误:
curl -v -H "host: nginx.plz" 10.152.183.60
* Trying 10.152.183.60...
* TCP_NODELAY set
* Connection failed
* connect to 10.152.183.60 port 80 failed: Operation timed out
* Failed to connect to 10.152.183.60 port 80: Operation timed out
* Closing connection 0
curl: (7) Failed to connect to 10.152.183.60 port 80: Operation timed out
有人熟悉在 microk8s 上设置这个吗?我确实看到了一些其他问题,例如这个:https://serverfault.com/questions/1032572/microk8s-deploy-application-not-working 但它没有解决方案
编辑:我也启用了 microk8s 入口。
【问题讨论】:
标签: nginx kubernetes kubernetes-ingress kubernetes-service microk8s