https://github.com/squat/configmap-to-disk
configmap-to-disk synchronizes a ConfigMap from the Kubernetes API to disk
https://github.com/squat/configmap-to-disk
Last synced: over 1 year ago
JSON representation
configmap-to-disk synchronizes a ConfigMap from the Kubernetes API to disk
- Host: GitHub
- URL: https://github.com/squat/configmap-to-disk
- Owner: squat
- License: apache-2.0
- Created: 2020-07-18T18:34:13.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-05-25T16:58:24.000Z (about 3 years ago)
- Last Synced: 2024-06-21T18:53:04.871Z (about 2 years ago)
- Language: Go
- Size: 3.65 MB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# configmap-to-disk
`configmap-to-disk` is a sidecar that synchronizes a value from a ConfigMap in the Kubernetes API to a path on disk.
This allows for instant reloading of files when they are updated in the API rather than having to wait for the Kubelet to update a volume mount.
[](https://travis-ci.org/squat/configmap-to-disk)
[](https://goreportcard.com/report/github.com/squat/configmap-to-disk)
## Example Usage
Add the following container specification to a Pod in order to have the `configmap-to-disk` sidecar write the value of the key `bar` from ConfigMap `foo` to the path `/path/to/foo/bar`:
```yaml
- args:
- --path=/path/to/foo/bar
- --name=foo
- --key=bar
- --namespace=$(NAMESPACE)
env:
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: squat/configmap-to-disk
name: configmap-to-disk
volumeMounts:
- mountPath: /path/to/foo
name: foo
```
## RBAC
`configmap-to-disk` requires permission to watch and list ConfigMaps in the target ConfigMap's namespace.
The following example RBAC resources could be used to provision the necessary permissions:
```yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: configmap-to-disk
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: list-watch-configmaps
rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: configmap-to-disk
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: list-watch-configmaps
subjects:
- kind: ServiceAccount
name: configmap-to-disk
```
## Usage
[embedmd]:# (tmp/help.txt)
```txt
Watch ConfigMaps in the API and write them to disk
Usage:
configmap-to-disk [flags]
Flags:
-h, --help help for configmap-to-disk
--key string The ConfigMap key to read.
--kubeconfig string Path to kubeconfig. (default $KUBECONFIG)
--listen string The address at which to listen for health and metrics. (default ":8080")
--log-level string Log level to use. Possible values: all, debug, info, warn, error, none (default "info")
--name string The ConfigMap name.
--namespace string The namespace to watch.
--one-time Syncs the ConfigMap to disk a single time and exits.
--path string Where to write the file.
```