There's a similar question here, but I think I want different thing. For those who familiar with docker-compose, there's a brilliant command which runs command in container just once, this insanely helps for launching migrations before each deploy:
docker-compose -f docker-compose.prod.yml run web npm run migrate
Also because this is a one line command it's comfortable for automation purpose: like using Makefile or ansible/chef/saltstack.
The only thing I've found is kubectl run
which is more similar to docker run
. But docker-compose run
allows us to use config file, where docker-run does not:
kubectl run rp2migrate --command -- npm run migrate
This would probably work, but I need to list 20 environment variables, and really don't want to do this in command line.. instead I'd like to pass a flag which would specify yaml config like this:
kubectl run rp2migrate -f k8s/rp2/rp2-deployment.yaml --command -- npm run migrate