Open Bogdan0w opened 3 years ago
Good catch. There is actually a set of environment variables that must be set.
RELOADER_PATH
must be set to a directory where reloader will write config files.RELOADER_CONFIGMAP
exclusive or RELOADER_SECRET
must be set to a resource name. In order to test this properly you also need a Kubernetes endpoint to attach to.
Assuming you have that you can start a proxy with kubectl proxy
and you will have a K8s endpoint listening at http://localhost:8001
. Either minicube or k3s will work fine. For MacOS I think it is not yet possible to run k3s so your option is minicube, or host a K8s instance on another machine which runs Linux.
You can insert a dummy config by the command:
echo "# this is a test config" > config
kubectl create configmap test --from-file=config
When those pre-conditions are fulfilled you can start reloader:
RELOADER_PATH=/tmp RELOADER_CONFIGMAP=test python3 -m reloader
Every time you update the configmap test reloader will rewrite /tmp/config
with the contents of that asset. You can change a configmap simply by running
EDITOR=nano kubectl edit configmap test
I think it would be more correct to:
RELOADER_PATH
optional. If it is missing reloader should simply not save the asset. Requires a minor change to config.py
. The logic is already there in __main__.py
, if CONFIGMAP and PATH
, so if PATH is None
the update
method is not called, same for the other branch if SECRET and PATH
...config.py
and handle it in __main__.py
. I would be happy to receive a PR that addresses one or both of these suggestions.
Tried to run python file on MacOS with Python 3.8.2. I have installed all required libraries. Attached a screenshot of error. Can happened that I did something wrong.