Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.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
Spring 库伯内特的活泼是未经授权的_Spring_Spring Boot_Kubernetes - Fatal编程技术网

Spring 库伯内特的活泼是未经授权的

Spring 库伯内特的活泼是未经授权的,spring,spring-boot,kubernetes,Spring,Spring Boot,Kubernetes,我试图通过将httpheader的值传递为secret来定义livenessProbe。但我得到的是未经授权的401 - name: mycontainer image: myimage env: - name: MY_SECRET valueFrom: secretKeyRef: name: actuatortoken key: token livenessProbe:

我试图通过将httpheader的值传递为secret来定义livenessProbe。但我得到的是未经授权的401

  - name: mycontainer
    image: myimage
    env:
      - name: MY_SECRET
        valueFrom:
          secretKeyRef:
            name: actuatortoken
            key: token
    livenessProbe:
        httpGet:
          path: /test/actuator/health
          port: 9001
          httpHeaders:
          - name: Authorization
            value: $MY_SECRET

我的秘密如下:

apiVersion: v1
kind: Secret
metadata:
  name: actuatortoken
type: Opaque
stringData:
  token: Bearer <token>
apiVersion:v1 种类:秘密 元数据: 姓名:Tortoken 类型:不透明 stringData: 代币:持票人 如果我通过与实际值相同的如下。。。它按预期工作

  - name: mycontainer
    image: myimage
    livenessProbe:
        httpGet:
          path: /test/actuator/health
          port: 9001
          httpHeaders:
          - name: Authorization
            value: Bearer <token>

-名称:mycontainer
图片:myimage
livenessProbe:
httpGet:
路径:/test/执行器/健康
港口:9001
HttpHeader:
-名称:授权书
价值:持票人

非常感谢您提供的任何帮助。

您所拥有的将把文本字符串
$MY_SECRET
作为授权标头,但该标头不起作用

您不希望将秘密的实际值放入Pod/Deployment/anywhich YAML中,因为您不希望在其中包含明文凭据

我可以想到3个选项:

a) 将您的应用程序更改为不要求对
/test/exactor/health
端点进行身份验证

b) 当请求的主机为
127.0.0.1
时,将应用程序更改为不需要身份验证,并更新探测器配置以将其用作主机

c) 从HTTP探测切换到命令探测,然后自己编写curl/wget命令


答案将作为社区wiki发布,因为它来自评论。

如果您在容器内执行并执行echo$MY\u SECRET,它会显示什么?您所拥有的内容将把文本字符串
$MY\u SECRET
作为授权标头,但不会起作用。您不希望将秘密的实际值放入Pod/Deployment/anywhich YAML中,因为您不希望在其中包含明文凭据。我可以想到3个选项:(a)将你的应用程序更改为不需要对
/test/exactor/health
端点进行身份验证;(b) 当请求的主机为
127.0.0.1
时,将应用程序更改为不需要身份验证,并更新探测器配置以将其用作主机;(c) 从HTTP探测切换到命令探测,然后自己编写curl/wget命令我同意@AmitKumarGupta的说法。请AmitKumarGupta写一个答案。这是一个常见的问题,你不需要为你的准备端点进行身份验证。如果您不想将执行器端点暴露在容器之外,只需将其配置为服务于不同的端点,它将仅可供运行状况探测器访问