Kubernetes Readiness探针发送401响应

时间:2019-09-04 05:50:44

标签: spring-boot kubernetes

尝试使用以下配置启用kubernetes滚动更新时,新创建的广告连播会显示HTTP probe failed with statuscode:401

配置:

spec:
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 1

containers:
          imagePullPolicy: Always
          readinessProbe:
            httpGet:
              path: /actuator/health
              port: 8065
            initialDelaySeconds: 20
            periodSeconds: 5
            successThreshold: 1

新创建的广告连播上的错误:

Warning  Unhealthy         0s (x2 over 5s)        kubelet, aks-agentpool-26902276-0  Readiness probe failed: HTTP probe failed with statuscode: 401

从日志中可以看到,新的pod和两个pod都在运行。

接收准备呼叫的HTTP 401的可能原因是什么?据我了解,这是Kubernetes内部的调用,不涉及身份验证。 Pod是Spring Boot应用程序

As Explained here,无需授权对spring / health端点的请求,并且在本地运行应用程序时可以正常工作。 (我可以从此端点获取http 200响应)

  

默认情况下,仅健康信息显示给未经授权的访问   通过HTTP

1 个答案:

答案 0 :(得分:0)

就我而言,问题不是添加spring-boot-starter-actuator依赖项

   <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>