简体   繁体   English

在K8S中,创建新机密时如何使用现有机密中的数据?

[英]In K8S, how to use data from existed secret when creating new secret?

We got an existed secret in K8S(suppose it is "secret_1") and we want to write a yaml to create a new secret "secret_2", using some values from secret_1. 我们在K8S中获得了一个秘密(假设它是“ secret_1”),我们想使用secret_1中的一些值编写一个Yaml来创建一个新的秘密“ secret_2”。

That is, in this yaml we'd like to 也就是说,在这个Yaml中,我们想

  1. Read values from other secret 从其他机密中读取值
  2. Store values to new secret 将值存储到新秘密

Is it possible to do this? 是否有可能做到这一点? It will be great help if a sample can be provided. 如果可以提供样品,将对您有很大的帮助。

Thanks in advance. 提前致谢。

You cannot do this directly in YAML. 您不能直接在YAML中执行此操作。 You would need to write a script of some kind to do the steps you described, though you can use kubectl get secret -o yaml (or -o json ) for a lot of the heavy lifting, possibly with jq for the reformatting. 尽管可以使用kubectl get secret -o yaml (或-o json )进行繁重的工作,但可能需要使用jq进行重新格式化,但是您需要编写某种脚本来执行所描述的步骤。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 K8S 测试 pod 模板中的删除GracePeriodSeconds - How to test deletionGracePeriodSeconds in pod templates with K8S 如何在C ++中从现有的模板函数定义一个新函数 - How to define a new function from an existed template function in C++ 从SharePoint导入的列表模板创建新列表时不显示 - SharePoint imported list template are not shown when creating new list from it 从命令行创建项目时,如何在android中使用代码模板? - How can I use code template in android when creating project from command line? Docker:用 docker-compose 中的秘密替换文件内容 - Docker: replace file contents with secret in docker-compose 什么是标准::map<k,v> ::map; 以及在实现/使用 stl 容器和函数时如何知道使用什么命名空间?</k,v> - What is std::map<K,V>::map; and how do you know what namespace to use when implementing/using stl containers and functions? 如何使用ControlTemplate中的应用程序资源? - How to use application's resource from ControlTemplate? 我应该如何构造std :: array <T, k> 从一个具有sizeof(U)= k * sizeof(T)的U中? - How should I construct an std::array<T, k> from a U with sizeof(U) = k * sizeof(T)? 在C ++中创建自定义地图类时,如何在模板中定义和使用比较器 - When creating a custom map class in c++ how to define and use a comparator in the template 在 Visual Studio 中创建新项目时没有可用的模板 - No templates available when creating a new project in Visual Studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM