Kubernetes/使用文档/跨Namespace同步Secret和ConfigMap.md
offends 7a2f41e7d6
All checks were successful
continuous-integration/drone Build is passing
synchronization
2024-08-07 18:54:39 +08:00

915 B

本文作者:丁辉

跨Namespace同步Secret和ConfigMap

示例:同步 test 命名空间下的 demo-secretdefault 命名空间下

JQ实现

  1. 准备依赖 jq

    • Centos

      yum install jq -y
      
    • Ubuntu

      apt install jq -y
      
  2. 执行命令

    kubectl get secret demo-secret -n test -o json \
     | jq 'del(.metadata["namespace","creationTimestamp","resourceVersion","selfLink","uid"])' \
     | kubectl apply -n default -f -
    

SED实现

kubectl get secret demo-secret -n test -o json \
 | jq 'del(.metadata["namespace","creationTimestamp","resourceVersion","selfLink","uid"])' \
 | kubectl apply -n default -f -

Helm部署Config-Syncer实现自动同步

请查看此文档:Helm部署Config-Syncer