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

Fix configmap volume #282

Conversation

StephanePaulus
Copy link

@StephanePaulus StephanePaulus commented Mar 18, 2021

POC for #280

I tested the code locally (no automated test yet) and it does work, however the code is a bit strange. The code has almost nothing to do with Kubernetes anymore. The only thing that relates to kubernetes is the way Kubernetes changes data in mounted volumes.
The game.properties file is actually a symbolic link, so you cannot have watch events on this. Every time the files are changed, Kubernetes creates a directory like: ..2021_03_18_17_30_18.531648931 and creates some temp folders and deletes the old ones.

These are the events fired every time a change happens in chronological order:

File at path ..2021_03_18_17_30_18.531648931 changed. Firing change event: ENTRY_CREATE
File at path ..2021_03_18_17_30_18.531648931 changed. Firing change event: ENTRY_MODIFY
File at path ..data_tmp changed. Firing change event: ENTRY_CREATE
File at path ..data_tmp changed. Firing change event: ENTRY_DELETE
File at path ..data changed. Firing change event: ENTRY_CREATE
File at path ..2021_03_18_17_17_29.703573822 changed. Firing change event: ENTRY_DELETE

In the code I just listen to the 1 MODIFY event, remove all propertysources and add them all back again after.

Maybe this code should be in a different repo as another bootstrap/client-config/hot-reload file repo. Instead of using Consul, Kubernetes,... you just use files to drive you configuration and have the possibility to change them on the fly.

bootstrap.yaml to make this work

micronaut:
  application:
    name: micronaut-service
  config-client:
    enabled: true

kubernetes:
  client:
    enabled: false
    watch: true
    config-maps:
      enabled: true
      paths:
        - /etc/example-service/configmap
    secrets:
      enabled: true
      paths:
        - /etc/example-service/secrets

Looking forward to ideas.

@rdesgroppes
Copy link
Contributor

The game.properties file is actually a symbolic link, so you cannot have watch events on this. Every time the files are changed, Kubernetes creates a directory like: ..2021_03_18_17_30_18.531648931 and creates some temp folders and deletes the old ones.

Yes, that's how it works. Worth a read: https://william-yeh.net/post/2019/06/inotify-in-containers/#caution-about-symbolic-links

@StephanePaulus
Copy link
Author

@rdesgroppes are you interested in this pull request/feature? I did manage to get something working. I am still using the normal file watcher, but this time to only look for CREATE of the folder "..data"

I can update this POC with my new code, but I have problems writing tests for this in the micronaut code repo.

@stale
Copy link

stale bot commented Jul 20, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@rdesgroppes
Copy link
Contributor

@StephanePaulus Unfortunately, I can't devote time to it this year.

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

Successfully merging this pull request may close these issues.

3 participants