-
Notifications
You must be signed in to change notification settings - Fork 452
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
Populate toxics at startup from a json string #211
base: main
Are you sure you want to change the base?
Conversation
Hey @worldtiki. Are you attempting to run Toxiproxy as a side car in a production Kubernetes cluster? If so, I would suggest extreme caution. Toxiproxy was not designed for production use and I have never heard of anyone running it in production environments. Thanks for opening a PR. I don't have time to review this right now but will look at it later in the week. |
Hi @jpittis. Thanks for the feedback. This would be used in a staging/test environment, not in a production one. |
Did you find an alternative solution @worldtiki? If you did, would you mind briefly mentioning what it was? |
Hi Jake! Yes and no. I managed to use Kubernetes config maps feature to pass the config file to Toxiproxy. I did however got stuck again as the initial population seems to be populating proxies but ignoring the list of toxics. I don't know if this is expected behaviour or if I'm just doing something wrong (I never worked with Go before so I'm having a bit of a struggle to debug this) |
The correct behaviour is that initial population ignores toxics. There's an open issue. #79 |
@worldtiki, Any chance to revive that? I like what you have done on your fork. |
However, I just noticed that the ability to update toxics through the api seems to be broken on your branch. |
Yeah, sorry about that @jpambrun :( I'll reopen this pr (didn't know it could be of use for others). Regarding the initial population of toxics, it would be nice if someone else could give it a go, as my knowledge of go is very basic :s |
@jpambrun @worldtiki Hope it helps! |
I would replace ability to load config via ENV variable instead. Currently I am not fully convinced to change the arguments. ENV is good, that it is easy to use in kubernetes and docker compose. It could be stored in |
Fair enough. But just to confirm. This env var would be use to specify the name/path of a config file and not to explicitly pass the configs themselves right? |
@worldtiki I tried to find other command lines that uses ENV as full config or for complex one. I failed to find a good examples (kubectl, opentelemtry-collector, grafana, nginx). Learned about best practices in https://12factor.net/ and https://clig.dev/ also suggested to have simple ENVs. If you can suggest some example command line, it would be helpful. Max that we can do assign SINGLE ENV to SINGLE Flag. Similar to TOML or what provides current frameworks Viper or https://github.com/urfave/cli/. As workaround for docker we can use entrypoint.sh that would generate config file base on ENVs. Example: https://devopsian.net/notes/docker-nginx-template-env-vars/ or use http://mustache.github.io/mustache.5.html P.S: During learning about config structure. I feel I need extract parse config out of models. I am going to change config structure to remove arrays of proxies with dictionary. So it would be easy to create new entries. Also support more other formats. |
Also thought to use flag Also i think it is not unix way. |
@dianadevasia By renaming (I think using the rename feature of GitHub would have prevented this.) |
Ability to provide a configuration at startup.
My use case is the following:
I'm running a Kuberneters cluster with several applications/containers deployed. I would like to use Toxiproxy as a sidecar to some of these applications to be able to perform failure testing.
Currently we have two existing options to populate proxies, one from a json file and by making an http request. Neither option is very friendly when using Toxiproxy on containerized environments as they either require a post start script to run the http populate request or mounting a volume with the json config file.
With this change we can provide a json string (at startup) as such:
docker run -it shopify/toxiproxy:git -configJson '[{"name": "redis","listen": "0.0.0.0:9092","upstream": "redis:6379"}]'