我正在尝试使用服务和Nginx入口在Kubernetes集群上公开我的部署。我目前有以下配置。
apiVersion: apps/v1
kind: Deployment
metadata:
name: mira-api-deployment
spec:
replicas: 1
selector:
matchLabels:
app: mira-api
template:
metadata:
labels:
app: mira-api
spec:
containers:
- name: backend
image: registry.gitlab.com/izit/mira-backend
ports:
- containerPort: 8080
name: http
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: mira-api-service
spec:
ports:
- port: 8080
protocol: TCP
targetPort: 8080
selector:
app: mira-api
type: NodePort
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: mira-api-ingress
spec:
tls:
- hosts:
- kubernetes.mira-appservice.be
secretName: mirasecret
rules:
- host: kubernetes.mira-appservice.be
http:
paths:
- backend:
serviceName: mira-api-service
servicePort: 8080
此配置使我的部署可以使用正确的证书等通过HTTPS公开提供。
唯一的问题是,发出请求时我收到HTTP 502错误消息。
当我检查入口的日志时,看到以下错误消息:
我的服务配置是否正确?还是配置中缺少其他内容?