Skip to main content

PyPI PyPI - License PyPI - Downloads docker-image-version docker-image-size docker-pulls

julb/kubernetes-configmap-sync

Description

This utility takes a source directory and creates automatically ConfigMap in the Kubernetes cluster based on the content of that directory.

This can be used when :

  • Configuration files for your application are stored in Git, or anything source directory.
  • A regular routine will launch the container to synchronize the content of the source directory into the Kubernetes cluster.

Use the script

The directory used as source for ConfigMap creation should be organized like this:

-- ROOT/
-- -- namespace1/
-- -- -- configmap-name1/
-- -- -- -- file1.txt
-- -- -- -- file2.txt

-- -- -- configmap-name2/
-- -- -- -- [....]

-- -- namespace2/
-- -- -- [....]

-- -- namespace3/
-- -- -- [....]

Using the python module

$ pip install kubernetes-configmap-sync
$ python -m kubernetes-configmap-sync <directory>

Using the container

To execute the container, you should have a ~/.kube/config with the context pointing to the cluster. The user defined in the context should have the appropriate rights in th cluster to manage configmaps.

$ docker run -ti \
    --user 65534:65534                      \
    -e "CONFIGMAP_DIR=/opt/configmap-dir"   \
    -v $(pwd)/examples:/opt/configmap-dir   \
    -e "KUBECONFIG=/.kube/config"           \
    -v ~/.kube/config:/.kube/config         \
    julb/kubernetes-configmap-sync:latest

2020-06-08 09:08:06: [INFO] Running outside a pod, using .kubeconfig.
2020-06-08 09:08:06: [INFO] Operation started.
2020-06-08 09:08:06: [INFO] = ConfigMap directory is: <examples>
2020-06-08 09:08:06: [INFO] = Proceed to ConfigMap extraction.
2020-06-08 09:08:06: [INFO] == Namespace: <default>
2020-06-08 09:08:06: [INFO] == > ConfigMap: <test-cm>
2020-06-08 09:08:06: [INFO] == >>> Adding file: <hello.txt>.
2020-06-08 09:08:06: [INFO] = ConfigMap extraction completed successfully.
2020-06-08 09:08:06: [INFO] = Proceed to ConfigMap extraction in cluster.
2020-06-08 09:08:06: [INFO] == Namespace: <default>
2020-06-08 09:08:06: [INFO] === Fetching list of ConfigMap in the cluster
2020-06-08 09:08:07: [INFO] === Synchronize ConfigMaps in the cluster
2020-06-08 09:08:07: [INFO] ==== Create ConfigMap: test-cm.
2020-06-08 09:08:07: [INFO] === Delete ConfigMaps no more present in the cluster
2020-06-08 09:08:07: [INFO] Operation completed.
$ kubectl --namespace default get cm

NAME      DATA   AGE
test-cm   0      43s
$ kubectl --namespace default get cm test-cm -ojson

{
    "apiVersion": "v1",
    "binaryData": {
        "hello.txt": "SGVsbG8gV29ybGQhCkhvdyBhcmUgeW91ID8="
    },
    "kind": "ConfigMap",
    "metadata": {
        "creationTimestamp": "2020-06-08T07:08:07Z",
        "labels": {
            "app.kubernetes.io/managed-by": "io.julb.kubernetes-configmap-sync"
        },
        "name": "test-cm",
        "namespace": "default",
        "resourceVersion": "87285195",
        "selfLink": "/api/v1/namespaces/default/configmaps/test-cm",
        "uid": "705a29dc-ac51-4ec4-af6c-4611b0d4077b"
    }
}
Environment var Description Default Value
CONFIGMAP_DIR Indicates the location of the directory containing ConfigMap sources. /opt/configmap-dir
KUBECONFIG When run out of kubernetes, it indicates the location of the kube config used to update the cluster. /.kube/config

When this container is run in Kubernetes with a mounted service account, the script will use that user account automatically. In that case, the KUBECONFIG parameter will have no effect.

Contributing

This project is totally open source and contributors are welcome.

When you submit a PR, please ensure that the python code is well formatted and linted.

$ make format
$ make lint

Metadata

Release files for kubernetes-configmap-sync 1.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kubernetes-configmap-sync 1.1.5
File Size Uploaded
kubernetes-configmap-sync-1.1.5.tar.gz 5.2 kB Details

Release files / kubernetes-configmap-sync-1.1.5.tar.gz

Download URL kubernetes-configmap-sync-1.1.5.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
457ae081904537110fcb2226628a885d8c2dc67c4d5834b807b94c0cf1b00ecd
BLAKE2b-256 checksum
How to use checksums
6b81fa286240325c4dcf876d8264e70b87d88e7d6b71133c56a291968065ebbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2

Release history Release notifications | RSS feed

This release

1.1.5 This release

1 release file

1.1.4

1 release file

1.1.3

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page