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 a local fol
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 a local fol
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 an HTTP 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.
This is our simple way to provide files from configmaps or secrets to a service and keep them updated during runtime.
Run the container created by this repo together with your application in a 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 an HTTP request to specified URL.
Images are available at:
All are identical multi-arch images built for amd64, arm64, arm/v7, ppc64le and riscv64.
s390xWith v2.x we dropped support for the ppc64le and s390x architectures. Support for ppc64le has since been restored, while s390x remains unsupported.
If you still have a need for s390x, please get in touch.
A possible solution would be to setup a dedicated build job using a native runner instead of qemu.
binaryData for both Secret and ConfigMap kindsConfigMap/Secret must end with ".url" (see)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)One can override the default directory that files are copied into using a configmap annotation defined by the environment variable FOLDER_ANNOTATION (if not present it will default to k8s-sidecar-target-directory). The sidecar will attempt to create directories defined by configmaps if they are not present. Example configmap annotation:
metadata:
annotations:
k8s-sidecar-target-directory: "/path/to/target/directory"If the filename ends with .url suffix, the content will be processed as a URL which the target file contents will be downloaded from.
| name | description | required | default | type |
|---|---|---|---|---|
--req-username-file |
Path to file containing username to use for basic authentication for requests to REQ_URL and for *.url triggered requests. This overrides REQ_USERNAME. Takes precedence over REQ_USERNAME_FILE env var. |
false | - | string |
--req-password-file |
Path to file containing password to use for basic authentication for requests to REQ_URL and for *.url triggered requests. This overrides REQ_PASSWORD. Takes precedence over REQ_PASSWORD_FILE env var. |
false | - | string |
containers:
- name: k8s-sidecar
image: ghcr.io/kiwigrid/k8s-sidecar:latest
args:
- --req-username-file=/path/to/username
- --req-password-file=/path/to/password| name | description | required | default | type |
|---|---|---|---|---|
LABEL |
Label that should be used for filtering | true | - | string |
LABEL_VALUE |
The value for the label you want to filter your resources on. Don't set a value to filter by any value | false | - | string |
FOLDER |
Folder where the files should be placed | true | - | string |
FOLDER_ANNOTATION |
The annotation the sidecar will look for in configmaps to override the destination folder for files. The annotation value can be either an absolute or a relative path. Relative paths will be relative to FOLDER. |
false | k8s-sidecar-target-directory |
string |
FOLDER_PER_NAMESPACE |
Set to true to place files in a subfolder of FOLDER named after the resource's namespace. If FOLDER_ANNOTATION is also set and provides a relative path, that relative path is placed under the namespace subfolder as well. |
false | false |
boolean |
NAMESPACE |
Comma separated list of namespaces. If specified, the sidecar will search for config-maps inside these namespaces. It's also possible to specify ALL to search in all namespaces. |
false | namespace in which the sidecar is running | string |
RESOURCE |
Resource type, which is monitored by the sidecar. Options: configmap, secret, both |
false | configmap |
string |
RESOURCE_NAME |
Comma separated list of resource names, which are monitored by the sidecar. Items can be prefixed by the namespace and the resource type. E.g. secret/resource-name or namespace/secret/resource-name. Setting this will result method set to WATCH being treated as SLEEP |
false | - | string |
METHOD |
If METHOD is set to LIST, the sidecar will just list config-maps/secrets and exit. With SLEEP it will list all config-maps/secrets, then sleep for SLEEP_TIME seconds. Anything else will continuously watch for changes (see Kubernetes Doc). |
false | - | string |
SLEEP_TIME |
How many seconds to wait before updating config-maps/secrets when using SLEEP method. |
false | 60 |
integer |
REQ_URL |
URL to which send a request after a configmap/secret got reloaded | false | - | URI |
REQ_METHOD |
Request method GET or POST for requests tp REQ_URL |
false | GET |
string |
REQ_PAYLOAD |
If you use REQ_METHOD=POST you can also provide json payload |
false | - | json |
REQ_RETRY_TOTAL |
Total number of retries to allow for any http request (*.url triggered requests, requests to REQ_URI and k8s api requests) |
false | 5 |
integer |
REQ_RETRY_CONNECT |
How many connection-related errors to retry on for any http request (*.url triggered requests, requests to REQ_URI and k8s api requests) |
false | 10 |
integer |
REQ_RETRY_READ |
How many times to retry on read errors for any http request (.url triggered requests, requests to REQ_URI and k8s api requests) |
false | 5 |
integer |
REQ_RETRY_BACKOFF_FACTOR |
A backoff factor to apply between attempts after the second try for any http request (.url triggered req |
No open issues yet, or sync has not completed.