Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kubernetes Ingress endpoint在GKE上显示一个响应为200的空白页_Kubernetes_Google Cloud Platform_Yaml_Google Kubernetes Engine_Nginx Ingress - Fatal编程技术网

Kubernetes Ingress endpoint在GKE上显示一个响应为200的空白页

Kubernetes Ingress endpoint在GKE上显示一个响应为200的空白页,kubernetes,google-cloud-platform,yaml,google-kubernetes-engine,nginx-ingress,Kubernetes,Google Cloud Platform,Yaml,Google Kubernetes Engine,Nginx Ingress,我对谷歌云完全陌生,对kubernetes也几乎陌生,所以我整个周末都在努力在GKE中部署我的应用程序。 我的应用程序由react前端、nodejs后端、postgresql数据库(通过cloudsql代理连接到后端)和redis组成 我为前端和后端提供入口,一切似乎都在运行,我的吊舱正在运行。ingress nginx公开了我的应用程序的端点,但当我打开它时,我看到的不是我的应用程序,而是一个带有200响应的空白页面。当我记录我的POD时,我可以看到我的react应用程序正在运行 入口: ap

我对谷歌云完全陌生,对kubernetes也几乎陌生,所以我整个周末都在努力在GKE中部署我的应用程序。 我的应用程序由react前端、nodejs后端、postgresql数据库(通过cloudsql代理连接到后端)和redis组成

我为前端和后端提供入口,一切似乎都在运行,我的吊舱正在运行。ingress nginx公开了我的应用程序的端点,但当我打开它时,我看到的不是我的应用程序,而是一个带有200响应的空白页面。当我记录我的POD时,我可以看到我的react应用程序正在运行

入口:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: superflix-ingress-service
  namespace: default
  annotations:
    kubernetes.io/ingress.class: nginx
    kubernetes.io/ingress.global-static-ip-name: "web-static-ip"
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
  - http:
      paths:
      - path: /*
        backend:
          serviceName: superflix-ui-node-service
          servicePort: 3000
      - path: /graphql/*
        backend:
          serviceName: superflix-backend-node-service
          servicePort: 4000
这是我的后端:

kind: Service
apiVersion: v1
metadata:
  name: superflix-backend-node-service
spec:
  type: NodePort
  selector:
    app: app
  ports:
  - port: 4000
    targetPort: 4000
    # protocol: TCP
    name: http
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: superflix-backend-deployment
  namespace: default
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: app
    spec:
      containers:
        - name: superflix-backend
          image: gcr.io/superflix-project/superflix-server:v6
          ports:
            - containerPort: 4000
          # The following environment variables will contain the database host,
          # user and password to connect to the PostgreSQL instance.
          env:
            - name: REDIS_HOST
              value: superflix-redis.default.svc.cluster.local
            - name: IN_PRODUCTION
              value: "true"
            - name: POSTGRES_DB_HOST
              value: "127.0.0.1"
            - name: POSTGRES_DB_PORT
              value: "5432"
            - name: REDIS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: redis-env-secrets
                  key: REDIS_PASS
            # [START cloudsql_secrets]
            - name: POSTGRES_DB_USER
              valueFrom:
                secretKeyRef:
                  name: cloudsql-db-credentials
                  key: username
            - name: POSTGRES_DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: cloudsql-db-credentials
                  key: password
            # [END cloudsql_secrets]
        # [START proxy_container]
        - name: cloudsql-proxy
          image: gcr.io/cloudsql-docker/gce-proxy:1.11
          command: ["/cloud_sql_proxy",
                    "-instances=superflix-project:europe-west3:superflix-db=tcp:5432",
                    "-credential_file=/secrets/cloudsql/credentials.json"]
          # [START cloudsql_security_context]
          securityContext:
            runAsUser: 2  # non-root user
            allowPrivilegeEscalation: false
          # [END cloudsql_security_context]
          volumeMounts:
            - name: cloudsql-instance-credentials
              mountPath: /secrets/cloudsql
              readOnly: true
        # [END proxy_container]
      # [START volumes]
      volumes:
        - name: cloudsql-instance-credentials
          secret:
            secretName: cloudsql-instance-credentials
      # [END volumes]
这是我的前端:

kind: Service
apiVersion: v1
metadata:
  name: superflix-ui-node-service
spec:
  type: NodePort
  selector:
    app: app
  ports:
    - port: 3000
      targetPort: 3000
      # protocol: TCP
      name: http
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: superflix-ui-deployment
  namespace: default
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: app
    spec:
      containers:
        - name: superflix-ui
          image: gcr.io/superflix-project/superflix-ui:v4
          ports:
            - containerPort: 3000
          env:
            - name: IN_PRODUCTION
              value: 'true'
            - name: BACKEND_HOST
              value: superflix-backend-node-service
编辑:

当我查看我的nginx ingress控制器的stackdriver日志时,我收到了警告:

服务“default/superflix ui”没有任何活动终结点。 服务“默认/superflix后端”没有任何活动终结点


我发现了问题所在。我将入口服务路径从/*更改为/,现在它工作正常。

入口控制器在哪里?它甚至在gcp控制台中创建了lb吗?@night gold我可以在gcloud的KE中的工作负载中看到“nginx入口控制器”。当我运行“kubectl get pods-n ingress nginx”时,我也能看到它正在运行。什么是“磅”?LoadBalancer?是的,如果一切正常,您应该在控制台中看到它,它应该为您提供一些可能出错的提示。您还可以查看stackdriver中的日志,以确定某些内容的去向wrong@night-金色谢谢我查过了,确实有警告。它说我的服务没有端点。我用相关信息更新了我的问题。我也有同样的问题,但使用了/路径。在阅读了这个问题和答案之后,我随机尝试了/*来代替,这为我解决了这个问题。所以我得到了完全相反的答案。