11. Sync secret between name space¶
11.1 Without tools¶
Export existing secret in yaml format
kubectl get secret <secret-name> -n <namespace> -o yaml
For example, you can see the below output, put it in a file secret.yaml
apiVersion: v1
data:
password: dGVzdFBAc3N3b3Jk
username: dGVzdC11c2Vy
kind: Secret
metadata:
creationTimestamp: "2022-10-11T21:21:02Z"
name: test-secret-1
namespace: testns1
resourceVersion: "307939"
uid: 6a8d9a6d-9648-4a39-a362-150e682c9a42
type: Opaque
The only attribute you need to change is namespace
Change namespace: testns1 to namespace: testns2
Then apply the new secert
kubectl apply -f secret.yaml
11.2 With tools¶
There are three possilbe tools that can sync configMap/secret between namespaces
- config-syncer (aka. kubed) : A tuto of kubed
- reflector
- kubernetes-replicator
No time to test them.