【问题标题】:In k8s, how to automatically add a root certificate of a self-signed certificate between pods?在k8s中,如何在pod之间自动添加自签名证书的根证书?
【发布时间】:2022-08-18 17:44:48
【问题描述】:

我创建了一个自签名证书,我的HTTP服务pod挂载了这个自签名证书,希望其他pod在访问这个http服务的时候可以信任这个证书,现在我只能在client的pod中挂载根证书然后使用pod 内的 update-ca-certificates 以添加证书信任。 k8s 中有没有办法自动将此根证书添加到所有新创建的 Pod 中,而无需我手动挂载根证书然后添加信任。因为不知道后面的pods是怎么创建的,以后也不能要求创建pods 挂载我根证书的人

    标签: kubernetes ssl


    【解决方案1】:

    最好使用 helm,因为它是为模板设计的,如果你想要解决方法,那么它应该可以工作

    apiVersion: batch/v1
    kind: Job
    metadata:
      annotations:
        version: 0.0.1
      name: job_name # this also need to be overridden otherwise it will throw an error as cmd is immutable
      labels:
        app: batch
        io.service: batch
    spec:
      template:
        spec:
          containers:
          - name: batch-1
            image: alpine
            command: ["/bin/sh"]
            args: ["-c", "echo the value of argument1= ARG_1  and argument2= ARG_2"]
          restartPolicy: Never
    

    在这里我们将覆盖args 和工作name

    sed -e "s/ARG_1/my-arg1/g" -e "s/ARG_2/my-arg2/g" -e "s/job_name/myawsomejob-name/"  demo.yaml  | kubectl apply -f -
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-08-23
      • 2020-12-22
      • 1970-01-01
      • 2014-09-02
      • 2021-04-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多