gpt4 book ai didi

azure - 如何在 Kubernetes (AKS) 中使用 Helm 注释 Ingress Controller 的 Pod?

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

在 Azure AKS 上运行 helm 图表打包容器时,我尝试自动注释 pod(编辑:入口 Controller pod),以在 Scalyr 中设置自定义日志解析器。我可以自动注释服务,但无法自动注释 Pod。使用 kubectl 手动执行此操作:

kubectl annotate pod nginx-ingress-ingress-nginx-controller-yyy-xxx --overwrite log.config.scalyr.com/attributes.parser=<my_scalyr_parser_name>

很好,但是当我的 Pod 终止时,我将丢失注释,并且 Scalyr 可能会丢失一些日志。或者 ingress nginx pod IDDQD(不朽)?所以我正在尝试以某种方式实现自动化。

我尝试将其添加到values.yaml

ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: "true"
log.config.scalyr.com/attributes.parser: "<my_scalyr_parser_name>"

但它只是落在 ingress.yaml 中的元数据注释中

kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "myservice.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}

这会产生服务的注释。但是,我需要在 Pod 上进行注释,以便 Scalyr 使用我的自定义解析器,而不是在服务中。

另一种方法是在安装 nginx-ingress 时硬装:

helm install nginx-ingress ingress-nginx/ingress-nginx --set controller.replicaCount=3 --set-string controller.pod.annotations.'log\.config\.scalyr\.com/attributes\.parser'="<my_scalyr_parser_name>"
--set-string controller.service.annotations.'service\.beta\.kubernetes\.io/azure-load-balancer-internal'="true"

当我设置controller.service.annotations时,我得到了服务上的注释,但是controller.pod.annotations被忽略了(我在nginx文档中找到了controller.pod.annotations)。

那么我还能做什么呢?

最佳答案

您应该能够使用 values.yaml 来完成此操作,其方式与您尝试 ingress 的方式类似:

controller:
podAnnotations:
log.config.scalyr.com/attributes.parser: "<my_scalyr_parser_name>"

由于某种原因,变量的键是 controller.podAnnotations 而不是 controller.pod.annotations

关于azure - 如何在 Kubernetes (AKS) 中使用 Helm 注释 Ingress Controller 的 Pod?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64375602/

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