Keep shared config in sync across namespaces.
Several teams' namespaces need the same ConfigMap. Copying it by hand drifts. This page makes one source object the truth and lets Replikate maintain every copy.
replikate.ubixsys.com/sync: "team=web" # namespaces labelled team=web replikate.ubixsys.com/sync: "" # every namespace
The annotation value is a namespace label selector. Replikate keeps a managed copy of the source in each matching namespace: a change to the source updates every copy, deleting the source or removing the annotation deletes the copies, and a newly labelled namespace is populated automatically.
Replikate never overwrites an object it does not manage. If a namespace already holds an unmanaged object of the same name, it is left alone and a Conflict event is emitted.
1. Install.
$ helm upgrade --install replikate charts/replikate \
--namespace replikate --create-namespace \
--set image.tag=v1.4.0 2. Create the source.
apiVersion: v1
kind: ConfigMap
metadata:
name: shared-config
namespace: default
annotations:
replikate.ubixsys.com/sync: "team=web"
data:
LOG_LEVEL: "info" $ kubectl apply -f shared-config.yaml 3. Opt a namespace in by labelling it.
$ kubectl label namespace some-namespace team=web $ kubectl get configmap shared-config -n some-namespace
4. Change the source; the copy follows.
$ kubectl patch configmap shared-config -n default \ --type merge -p '{"data":{"LOG_LEVEL":"debug"}}' $ kubectl get configmap shared-config -n some-namespace -o jsonpath='{.data.LOG_LEVEL}' debug
5. Stop replicating. Removing the annotation deletes every managed copy.
$ kubectl annotate configmap shared-config -n default replikate.ubixsys.com/sync- Replikate also replicates Secrets, and can copy a source into other clusters, and into several namespaces on each (green:web,green:live), with the target-clusters annotation; see the Replikate page for the hub-and-spoke setup.
The manifests above, with a script that checks each step, are in ubixsys-manual-examples under examples/replikate/.
Written against Replikate v1.4.0.