Fork from kiwigrid/k8s-sidecar https://github.com/kiwigrid/k8s-sidecar
This is a docker container intended to run inside a kubernetes cluster to collect config maps with a specified label and store the included files in an local folder. It can also send a html request to a specified URL after a configmap change. The main target is to be run as a sidecar container to supply an application with information from the cluster. The contained python script is working with the Kubernetes API 1.10


Currently there is no simple way to hand files in configmaps to a service and keep them updated during runtime.
Run the container created by this repo together you application in an single pod with a shared volume. Specify which label should be monitored and where the files should be stored. By adding additional env variables the container can send a html request to specified URL.
Example for a simple deployment can be found in example.yaml. Depending on the cluster setup you have to grant yourself admin rights first: kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user $(gcloud config get-value account)
LABEL
FOLDER
NAMESPACE
ALL to search in all namespaces.REQ_URL
REQ_METHOD
REQ_PAYLOAD
TIMEOUT
PARTFILES
COMMENT
COMMAND_AFTER_CC
PARTFILES=True)CHECK_CONFIG_COMMAND
OK_EXIT_CODES
CHECK_CONFIG_COMMANDPARTFILES=True)DATA_NAME_{somename} example: DATA_NAME_ROUTE
DATA_FILE_{somename} example: DATA_FILE_ROUTE
DATA_NAME_{somename} is set )DATA_INDENT_{somename} example: DATA_INDENT_ROUTE
# python ./files_to_cm.py -h
usage: ./files_to_cm.py [-h] --name NAME --dir DIR
[--file_pattern FILE_PATTERN] [--namespace NAMESPACE]
optional arguments:
-h, --help show this help message and exit
--name NAME Name of Secret/Configmap
--dir DIR Source directory path
--file_pattern FILE_PATTERN
File pattern for match files (default: '.*')
--namespace NAMESPACE
Name of Namespace
example:
Script take all yaml files from directory /tmp/k8s_sidecar-cm-to-file/ and create secret with name alertmanager-main in namespace default
python ./files_to_cm.py --name=alertmanager-main --dir /tmp/k8s_sidecar-cm-to-file/ --file_pattern '.*.yaml' --namespace 'default'
For this step you need have set up ClusterRole
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "watch", "list","create","update"]
Content type
Image
Digest
Size
26.1 MB
Last updated
over 7 years ago
docker pull sysincz/k8s-sidecar-cm-to-file