gpt4 book ai didi

spring - kubernetes事件未经授权

转载 作者:行者123 更新时间:2023-12-02 11:46:42 25 4
gpt4 key购买 nike

我试图通过传递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


我的 secret 如下:
apiVersion: v1
kind: Secret
metadata:
name: actuatortoken
type: Opaque
stringData:
token: Bearer <token>

如果我通过以下相同的实际值...按预期工作
  - name: mycontainer
image: myimage
livenessProbe:
httpGet:
path: /test/actuator/health
port: 9001
httpHeaders:
- name: Authorization
value: Bearer <token>


非常感谢您的帮助。

最佳答案

您将拥有的文字字符串$MY_SECRET作为Authorization header 将无法使用。

您不希望将 secret 的实际值放入Pod / Deployment /任何YAML中,因为您不想在其中使用纯文本凭据。

我能想到的3种选择:

a)更改您的应用,使其不需要/test/actuator/health端点的身份验证;

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

c)从HTTP探针切换到命令探针并自己编写curl / wget命令

答案来自Amit Kumar Gupta评论,被发布为社区Wiki。

关于spring - kubernetes事件未经授权,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60136084/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com