【问题标题】:GCP - Kubernetes Ingress Backend service unhealthyGCP - Kubernetes Ingress 后端服务不健康
【发布时间】:2019-06-28 19:11:34
【问题描述】:

我已经在 pod 上部署了 SAS Viya 编程。SASStudio 在端口 80 上运行。我正在尝试使用 nodeport 和 Ingress 通过下面的 yaml 文件公开 SAS Studio。但是在 GCP 控制台中,显示的后端服务不健康,如果我尝试访问 Ip,它会点击默认后端或找不到页面。我可以使用集群 IP 和节点 IP 以及端口号来访问服务。

如果我使用 LoadBalancer 服务而不是 Ingress,我可以使用 Loadbalancer Ip 访问该服务。

使用 Ingress 时,后端服务显示为不健康。

我已经将 curl 命令与 node Ip 和 nodeport Ip 一起使用。下面是结果。

   [root@k8jumphost doc]# curl -ILS "10.142.0.19:30100"
    HTTP/1.1 302 Found
    Date: Fri, 01 Feb 2019 07:53:31 GMT
    Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips
    Location: http://10.142.0.19:30100/SASStudio
    Content-Type: text/html; charset=iso-8859-1

    HTTP/1.1 302
    Date: Fri, 01 Feb 2019 07:53:32 GMT
    Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips
    Location: /SASStudio/
    Transfer-Encoding: chunked

    HTTP/1.1 200
    Date: Fri, 01 Feb 2019 07:53:34 GMT
    Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips
    Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:;
    X-Content-Type-Options: nosniff
    X-XSS-Protection: 1; mode=block
    Content-Type: text/html;charset=UTF-8
    Content-Language: en-US
    Content-Length: 7836

    [root@k8jumphost doc]# cat sas-analytics-ingress.yaml
    ---
    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
      name: sas-programming-ingress
      labels:
        app: sas-programming
    spec:
      rules:
      - host: sas-programming
        http:
          paths:
          - path: /
            backend:
              serviceName: sas-programming-svc-nodeport
              servicePort: 80


        [root@k8jumphost doc]# cat sas-analytics-nodeport.yaml
    ---

    apiVersion: v1
    kind: Service
    metadata:
      name: sas-programming-svc-nodeport
      labels:
        app: sas-programming
    spec:
      selector:
        app: sas-programming
      ports:
      - name: http
        nodePort: 30100
        port: 80
        targetPort: 80
      - name: cas
        nodePort: 30200
        port: 5570
        targetPort: 5570
      type: NodePort

[root@k8jumphost doc]# cat sas-analytics.yaml
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: sas-programming-deployment
  labels:
    app: sas-programming
spec:
  replicas: 1
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: sas-programming
    spec:
      securityContext:
        fsGroup: 1001
      hostname: sas-programming
      containers:
      - name: sas-programming
        image: <location of the image>
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 5570
        - containerPort: 80
        env:
        - name: CASENV_CAS_VIRTUAL_HOST
          value: "sas-programming"
        - name: CASENV_CAS_VIRTUAL_PORT
          value: "30300"

我怀疑 / 上的重定向导致了这个错误。谁能帮帮我,应该在部署文件中添加什么来克服这个错误。

【问题讨论】:

    标签: google-kubernetes-engine kubernetes-ingress


    【解决方案1】:

    我认为您在 GCP 中的后端不健康这一事实表明您的容器上可能没有健康端点。看看https://kubernetes.io/docs/concepts/services-networking/ingress/#loadbalancing。您需要在部署 yaml 中使用 readinessProbelivenessProbe

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-20
      • 2023-01-24
      • 1970-01-01
      • 2017-01-10
      • 2022-08-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多