Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error at line 13, tested on MacOS. #2

Open
Bogdan0w opened this issue May 23, 2021 · 2 comments
Open

Error at line 13, tested on MacOS. #2

Bogdan0w opened this issue May 23, 2021 · 2 comments

Comments

@Bogdan0w
Copy link

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.
1

@hholst80
Copy link
Member

hholst80 commented May 26, 2021

Good catch. There is actually a set of environment variables that must be set.

  1. RELOADER_PATH must be set to a directory where reloader will write config files.
  2. 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

@hholst80
Copy link
Member

hholst80 commented May 26, 2021

I think it would be more correct to:

  1. make 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...
  2. Gracefully handle the no-op case when no assets are monitored for changes, and quit. That is, remove the xor assert from config.py and handle it in __main__.py.

I would be happy to receive a PR that addresses one or both of these suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants