【发布时间】:2021-11-24 12:27:37
【问题描述】:
我有一个应用程序,它将在 127.0.0.1:8080 启动一个服务器,并使用 Dockerfile 创建一个用于在 GKE 上托管它的图像。我在 kubernetes 集群上的 port 8080 上部署了这个应用程序。然后我将服务公开为LoadBalancer,用于同一端口 8080,但不允许从外部访问它。所以我为外部访问创建了一个入口,但仍然无法正常工作。
当我点击 ingress 提供的 IP 时,我得到这个错误:
Error: Server Error
The server encountered a temporary error and could not complete your request.
Please try again in 30 seconds.
我想问一下我在实施中是否遗漏了什么或做错了什么。
我的 YAML 文件:
---
apiVersion: "apps/v1"
kind: "Deployment"
metadata:
name: "app"
namespace: "default"
labels:
app: "app"
spec:
replicas: 3
selector:
matchLabels:
app: "app"
template:
metadata:
labels:
app: "app"
spec:
containers:
- name: "app-sha256-1"
image: "gcr.io/project-1234/github.com/user/app@sha256:b17b8159668d44fec3d"
---
apiVersion: "autoscaling/v2beta1"
kind: "HorizontalPodAutoscaler"
metadata:
name: "app-hpa-y3ay"
namespace: "default"
labels:
app: "app"
spec:
scaleTargetRef:
kind: "Deployment"
name: "app"
apiVersion: "apps/v1"
minReplicas: 1
maxReplicas: 5
metrics:
- type: "Resource"
resource:
name: "cpu"
targetAverageUtilization: 80
---
apiVersion: "v1"
kind: "Service"
metadata:
name: "app-service"
namespace: "default"
labels:
app: "app"
spec:
ports:
- protocol: "TCP"
port: 8080
selector:
app: "app"
type: "LoadBalancer"
loadBalancerIP: ""
---
apiVersion: "extensions/v1beta1"
kind: "Ingress"
metadata:
name: "ingress"
namespace: "default"
spec:
backend:
serviceName: "app-service"
servicePort: 8080
谢谢!期待建议。
【问题讨论】:
标签: kubernetes google-kubernetes-engine kubernetes-ingress kubernetes-service