Renders and continually checks `kubectl get` results.
386
kubectl-watch is a docker image that allows a user to continuously check the
results of a kubectl get command, and pipe it through a template when the
results change.
The original purpose of the image was to help drive an automatic k8s edge
router that updated its configuration whenever services became available with
specific labels.
To use kubectl-watch, you are basically configuring a kubectl get command
and then mount volumes for the templates and output.
Here's a docker-compose example:
label-watcher:
image: ceroic/kubectl-watch
volumes:
- ~/.kube:/root/.kube:ro
- ./templates:/var/kubectl-watch/templates
- ./output:/var/kubectl-watch/output
environment:
TYPE: svc
SELECTOR: app=my-app
TEMPLATE: my-fancy-template.txt
OUTPUT_FILE: my-fancy-output.txt
NOTE: This example assumes you are testing locally and mounts authentication directly as a volume. Ideally in a production setting this container would be running with access to a service account that authorizes kubectl to the k8s API.
kubectl-watch requires the following environment variables to work.
| Variable | Description |
|---|---|
| TYPE | The k8s service type to pass to the kubectl get call. |
| SELECTOR | The kubectl get label selector passed to the -l parameter |
| TEMPLATE | The filename of the template to render. Needs to be available in the templates directory |
| OUTPUT_FILE | The name of the file to output to the output directory. |
| Variable | Description |
|---|---|
| INTERVAL | The amount of time between each check. Defaults to 5 seconds. |
kubectl-watch assumes you will be mounting two volumes to the container at
run time.
| Volume | Internal Path | Description |
|---|---|---|
| Templates | /var/kubectl-watch/templates | Templates available to render. |
| Output | /var/kubectl-watch/output | Where rendered templates are output to. |
kubectl-watch renders all templates using the -o go-template-file and
--template= flags. All templates use Go template syntax. More information
can be found here:
Content type
Image
Digest
Size
347.8 MB
Last updated
over 10 years ago
docker pull ceroic/kubectl-watch