首页 > 解决方案 > openshift 请求经常失败

问题描述

我已经在 openshift (tomcat) 中部署了我的 web 服务,每次我请求我的服务时,有时它会工作,有时它会不起作用。它以前工作得很好,吊舱数量为 1 没有失败日志

错误是

应用程序不可用 应用程序当前不在此端点处服务请求。它可能尚未启动或仍在启动。

您看到此页面的可能原因:主机不存在。确保主机名输入正确并且存在匹配该主机名的路由。

主机存在,但没有匹配的路径。检查 URL 路径是否输入正确,以及是否使用所需路径创建了路由。

路由和路径匹配,但所有 pod 都已关闭。确保此路由公开的资源(pod、服务、部署配置等)至少有一个 pod 正在运行。

O/P of oc describe routes
Name:           mysample
Namespace:      enzen
Created:        12 days ago
Labels:         app=mysample
Annotations:        openshift.io/host.generated=true
Requested Host: mysample-enzen.193b.starter-ca-central-1.openshiftapps.com
exposed on router router (host elb.193b.starter-ca-central-1.openshiftapps.com) 12 days ago
Path:           <none>
TLS Termination:    <none>
Insecure Policy:    <none>
Endpoint Port:      8080-tcp
Service:    mysample
Weight:     100 (100%)
Endpoints:  10.128.18.210:8080

O/P of oc describe services
Name:              mysample
Namespace:         enzen
Labels:            app=mysample
Annotations:       openshift.io/generated-by=OpenShiftNewApp
Selector:          app=mysample,deploymentconfig=mysample
Type:              ClusterIP
IP:                172.30.145.245
Port:              8080-tcp  8080/TCP
TargetPort:        8080/TCP
Endpoints:         10.128.18.210:8080
Session Affinity:  None
Events:            <none>

标签: openshift

解决方案


最初的想法是路由试图将负载分散到多个服务https://docs.openshift.com/container-platform/3.9/architecture/networking/routes.html#alternateBackends,其中一项服务已关闭或不可用. 通常在这种情况下,我会重新创建服务和路由以验证它是否按预期配置。也许您可以共享路由、服务和 pod 的配置?

oc describe routes
oc describe services
oc describe pods

#### 编辑 18 年 10 月 22 日 ####

为了其他读者的利益,添加来自 google doc 的输出并编辑构建 pod(因为它们不相关)。没有立即作为应用程序/配置问题跳出;

oc describe routes
Name:           mysample
Namespace:      enzen
Created:        12 days ago
Labels:         app=mysample
Annotations:        openshift.io/host.generated=true
Requested Host:     mysample-enzen.193b.starter-ca-central-1.openshiftapps.com
              exposed on router router (host elb.193b.starter-ca-central-1.openshiftapps.com) 12 days ago
Path:           <none>
TLS Termination:    <none>
Insecure Policy:    <none>
Endpoint Port:      8080-tcp

Service:    mysample
Weight:     100 (100%)
Endpoints:  10.128.18.210:8080


 oc describe services
Name:              mysample
Namespace:         enzen
Labels:            app=mysample
Annotations:       openshift.io/generated-by=OpenShiftNewApp
Selector:          app=mysample,deploymentconfig=mysample
Type:              ClusterIP
IP:                172.30.145.245
Port:              8080-tcp  8080/TCP
TargetPort:        8080/TCP
Endpoints:         10.128.18.210:8080
Session Affinity:  None
Events:            <none>




oc describe pods
Name:               mysample-15-z85zt
Namespace:          enzen
Priority:           0
PriorityClassName:  <none>
Node:               ip-172-31-29-189.ca-central-1.compute.internal/172.31.29.189
Start Time:         Sun, 21 Oct 2018 20:55:36 +0530
Labels:             app=mysample
                    deployment=mysample-15
                    deploymentconfig=mysample
Annotations:        kubernetes.io/limit-ranger=LimitRanger plugin set: cpu, memory request for container mysample; cpu, memory limit for container mysample
                    openshift.io/deployment-config.latest-version=15
                    openshift.io/deployment-config.name=mysample
                    openshift.io/deployment.name=mysample-15
                    openshift.io/generated-by=OpenShiftNewApp
                    openshift.io/scc=restricted
Status:             Running
IP:                 10.128.18.210
Controlled By:      ReplicationController/mysample-15
Containers:
  mysample:
    Container ID:   cri-o://0cd20854571232b310ce22a282c8d5832908533d28d5d720537bbf3618b86c44
    Image:          docker-registry.default.svc:5000/enzen/mysample@sha256:adadeb7decf82b29699861171c58d7ae5f87ca6eeb1c10e5a1d525e4a0888ebc
    Image ID:       docker-registry.default.svc:5000/enzen/mysample@sha256:adadeb7decf82b29699861171c58d7ae5f87ca6eeb1c10e5a1d525e4a0888ebc
    Port:           8080/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Sun, 21 Oct 2018 20:55:40 +0530
    Ready:          True
    Restart Count:  0
    Limits:
      cpu:     1
      memory:  512Mi
    Requests:
      cpu:        20m
      memory:     256Mi
    Environment:  <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-8xjb8 (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  default-token-8xjb8:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-8xjb8
    Optional:    false
QoS Class:       Burstable
Node-Selectors:  type=compute
Tolerations:     node.kubernetes.io/memory-pressure:NoSchedule
Events:          <none>

推荐阅读