掌舵人:如何用名称中的句点替换值 [英] Helm: How to Override Value with Periods in Name

查看:92
本文介绍了掌舵人:如何用名称中的句点替换值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写Jenkins设置脚本,以便我可以通过头盔以编程方式创建和拆除Jenkins集群.我遇到了一个烦人的障碍,无法在名称中设置带点的键.我的helm values.yaml文件如下所示:

I am trying to script setup of Jenkins so that I can create and tear down Jenkins clusters programmatically with helm. I've hit an annoying snag where I cannot set a key with dots in the name. My helm values.yaml file looks like this:

---
rbac:
  install: true

Master:
  HostName: jenkins.mycompany.com
  ServiceType: ClusterIP
  ImageTag: lts
  InstallPlugins:
    - kubernetes
    - workflow-aggregator
    - workflow-job
    - credentials-binding
    - git
    - blueocean
    - github
    - github-oauth

  ScriptApproval:
    - "method groovy.json.JsonSlurperClassic parseText java.lang.String"
    - "new groovy.json.JsonSlurperClassic"
    - "staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods leftShift java.util.Map java.util.Map"
    - "staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods split java.lang.String"
    - "method java.util.Collection toArray"
    - "staticMethod org.kohsuke.groovy.sandbox.impl.Checker checkedCall java.lang.Object boolean boolean java.lang.String java.lang.Object[]"
    - "staticMethod org.kohsuke.groovy.sandbox.impl.Checker checkedGetProperty java.lang.Object boolean boolean java.lang.Object"

  Ingress:
    Annotations:
      kubernetes.io/ingress.class: nginx
      kubernetes.io/tls-acme: "true"
    TLS:
      - secretName: jenkins-mycompany-com
        hosts:
          - jenkins.mycompany.com

  Memory: "2Gi"
  # This breaks the init container
  # RunAsUser: 1000
  # FSGroup: 1000

Agent:
  Enabled: false
  ImageTag: latest

在安装cert-managerexternal-dnsnginx-ingress之后(现在通过bash脚本),我像这样安装它:

After installing cert-manager, external-dns, nginx-ingress (for now via a bash script) I install it like so:

helm install --values helm/jenkins.yml stable/jenkins

我根本无法阅读letencrypt文档,因此在整个测试过程中,我都使用了生产配额.我希望能够在Ingress:certmanager.k8s.io/cluster-issuer: letsencrypt-staging中添加注释,以便我可以继续测试(并将其设置为默认值,以后在准备生产时将其覆盖).

I failed to read the letsencrypt docs at all, so throughout the course of testing I used my production quota. I want to be able to add an annotation to the Ingress: certmanager.k8s.io/cluster-issuer: letsencrypt-staging so that I can continue testing (and set this as the default in the future, overriding when I'm ready for production).

麻烦是...我不知道如何通过--set标志传递它,因为键名中有句点.我尝试过:

The trouble is... I can't figure out how to pass this via the --set flag, since there are periods in the key name. I've tried:

helm install --values helm/jenkins.yml stable/jenkins --set Master.Ingress.Annotations.certmanager.k8s.io/cluster-issuer=letsencrypt-staging

helm install --values helm/jenkins.yml stable/jenkins --set Master.Ingress.Annotations.certmanager\.k8s\.io/cluster-issuer=letsencrypt-staging

我当然可以通过添加一个用作标志的值来解决此问题,但是它不太明确.有什么办法可以直接设置它?

I can of course solve this by adding a value that I use as a flag, but it's less explicit. Is there any way to set it directly?

推荐答案

您需要将密钥用引号引起来,然后转义点号

You need to enclose the key with quotations and then escape the dots

helm install --values helm/jenkins.yml stable/jenkins --set Master.Ingress.Annotations."certmanager\.k8s\.io/cluster-issuer"=letsencrypt-staging

这篇关于掌舵人:如何用名称中的句点替换值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆