google-cloud-platform - Kubernetes Ingress Controller GPC GKE 无法访问站点
问题描述
Kubernetes Ingress Controller 无法访问该站点
嗨,这是我第一次尝试使用 kubernetes 部署应用程序。我面临的问题是我希望能够将子域与我的 svc 链接,但是当我尝试导航到我得到的链接时
无法访问此站点
我将解释我为这些所做的步骤,可能是我出了点问题或遗漏了
我安装
ingress-controller
在谷歌云平台在 GCP -> 网络服务 -> 云 DNS
一个。我用谷歌 dns 指向 testcompany.com
湾。我从上一步“ingress-nginx-controller”创建了一条指向公共 IP 的 A 记录
我的服务清单
apiVersion: v1 kind: Service metadata: namespace: staging name: testcompany-svc labels: app: testcompany-svc spec: type: NodePort ports: - name: test-http port: 80 protocol: TCP targetPort: 3001 selector: app: testcompany
我的入口清单
apiVersion: networking.k8s.io/v1beta1 - host: api.testcompany.com http: paths: - backend: serviceName: testcompany-svc servicePort: test-http
一切都是绿色的,它似乎正在工作,但是当我尝试访问该网址时,我得到了This site can’t be reached
更新 1
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
namespace: staging
name: ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: front.stagingtestcompany.com
http:
paths:
- backend:
serviceName: testcompanyfront-svc
servicePort: testcompanyfront-http
- host: api.stagingtestcompanysrl.com
http:
paths:
- backend:
serviceName: testcompanynodeapi-svc
servicePort: testcompanyapi-http
解决方案
您应该按以下顺序检查:
- 您的 Service、Pod、Ingress 在同一个命名空间中:
kubectl get all -n staging
- 您的 Pod 正在侦听端口 3001:如果可以,请在本地运行它,或者使用
kubectl port-forward pods/[pod-name] -n staging 3001:3001
并在本地尝试使用http://localhost:3001/...
- 您的服务正确到达您的 Pod:使用
kubectl port-forward service/testcompany-svc -n staging 3001:3001
并在本地尝试http://localhost:3001/...
- 在您发布之前检查任何其他 Ingress 规范规则
- 检查您的 VPC 网络中的防火墙规则,它们应该允许来自 Google LB 的流量
推荐阅读
- php - 为什么我会看到一条消息,指出 IAF 令牌对于 EBay 无效?
- reactjs - Formik handleReset 用于具有一个值的特定 Select
- json - 解码具有单个未键控 bool swift 的 json 文件
- php - Laravel - 从请求中更新大量数据的最佳方法?
- r - ggplot2:geom_bin2d 图中的空白列
- ios - 如何将多行保存到 Firebase,具有自己的自动 ID 的单行?
- flutter - 将水平和垂直滚动条附加到同一个小部件
- algorithm - 逻辑编程 - 查找给定单词的同义词
- python - 将文件一分为二,但保留行
- filter - 用于过滤的 ATR 不适用于斐波那契