mrc*_*mrc 1 nginx azure kubernetes kubernetes-helm azure-aks
在 Azure AKS 上运行 helm 图表打包容器时,我尝试自动注释 pod(编辑:入口控制器 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>
Run Code Online (Sandbox Code Playgroud)
没问题,但是当我的 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>"
Run Code Online (Sandbox Code Playgroud)
但它只是落在 ingress.yaml 的元数据注释中
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "myservice.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Run Code Online (Sandbox Code Playgroud)
这会产生服务的注释。但是,我需要在 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"
Run Code Online (Sandbox Code Playgroud)
当我设置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>"
Run Code Online (Sandbox Code Playgroud)
由于某种原因,变量的键controller.podAnnotations不是controller.pod.annotations
| 归档时间: |
|
| 查看次数: |
6859 次 |
| 最近记录: |