-
Notifications
You must be signed in to change notification settings - Fork 0
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
Save data to database #12
Conversation
Since you clearly like the cli parser library (which I don't), you should replace all the os.GetEnv() calls by this library. Currently there is a weird mix. Unfortunately because Github doesn't let me comment on collapsed lines in the DIFF (I can view them but not add a comment, thanks Github) I cannot directly point out the affected lines... |
Since you're not prefixing the environment variables (which I like, because I think prefixing environment variables is pointless and annoying), you should remove this code from the main.go file. `// env combines envPrefix with given suffix delimited by underscore. // envVars combines envPrefix with each given suffix delimited by underscore. |
Another thing I don't like is the fact that the kubernetes config is coming from a file (kubernetes.go line 26). I see no reason why the yaml shouldn't be put into an environment variable. Using environment variables for some things and files for other things just makes things unnecessarily complex and clumsy to use (e.g. if I need to switch between multiple environments). I also don't like the approach of having a single yaml document for configuring multiple clusters. This means that when setting this up (e.g. creating secrets) there must be some code that understands yaml and can merge all the different configurations. This is just unnecessarily complicated. I would much prefer one (or multiple, as it was before) environment variables per configured cluster to make things easy to work with. (you can still have yaml inside this one environment variable if you feel that this is easier than having e.g. 2 environment variables per cluster as my original implementation had) |
Here's another idea: work directly with
|
I had a wrong reason to parse them but after playing around a bit more with the cli library I got it right and now the parsing is is done by this library.
The only reason I decided to go with the file is because how big the text may get. I don't feel it's the right away to put a potential huge text file into an env variable.
I really wanted to avoid 2 env variables per cluster and the next (less bad) thing for me was to put that data neatly into a file. From my part I don't see having difficulties to create a secret out of this file (maybe I'm missing something?), such approach is being widely used like prometheus or alert manager. In any case I can understand your concern and I'm open for better suggestions. Also the parsing of yaml file is pretty straight forward in go and doesn't make the code much more difficult then it is with parsing an n number of env variables. @ccremer Regarding your suggestion for the cluster configs, it seems sensible but we should discuss this in a short call so that we are all aligned before I commit to change the code. |
During our BF we decided to remove multiple cluster support and instead run one job per cluster to populate the database. With this change it was natural to just use the same pattern aka environment variables like we did for other systems (exoscale and database). |
3cfdcc7
to
f0585e0
Compare
Just to recap the latest discussion: We opted to go for 2 environment variables (token + url). But each execution of the binary is targeted towards 1 cluster. So if you need to switch environment (another cluster), you need to reset the env vars. |
96c0a4e
to
498ca74
Compare
Summary
Local Testing:
K8S_SERVER_URL
andK8S_TOKEN
environment variables for k8s cluster.EXOSCALE_API_KEY
andEXOSCALE_API_SECRET
ACR_DB_URL
exoscale-metrics-collector objectstorage --log-level 1 --cluster-config clusters.yaml
Checklist
bug
,enhancement
,documentation
,change
,breaking
,dependency
as they show up in the changelog