hikerspath
4/17/2019 - 4:20 PM

Kubernetes: Running Test Containers

So you have a kubernetes cluster and an RDS database, but you also have a laptop that would be SUPER helpful if you could figure out how to get into the RDS instance that has IP restrictions enabled to prevent access from anywhere while you are on your laptop's terminal? NO PROBLEM!

First lets undertand how the command is constructed

$ kubectl run -it --rm --restart=Never --image=mysql:5.6 mysql-client — \
  mysql -h mwmobile.db.main.staging.mobile.meltwater.io -P 3306 -u root -p$PASSWORD
$ kubectl run -it --rm --restart=Never --image=meltwaterfoundation/drone-git bash — \
  bash
#    ^     ^   ^^   ^           ^             ^                               ^
#    |     |   ||   |           |             |                            Pod Name
#    |     |   ||   |           |             +--------------------------- Image
#    |     |   ||   |           +----------------------------------------- No Deployment
#    |     |   ||   +----------------------------------------------------- Remove Image
#    |     |   |+--------------------------------------------------------- TTY Session
#    |     |   +---------------------------------------------------------- Interactive
#    |     +-------------------------------------------------------------- EG: docker run
#    +-------------------------------------------------------------------- v1.10.12+

Now that you know how it is constructed, congratulations, because you can do the same thing with virtually any docker container that is available on dockerhub, quay, private rpeos, etc. Enjoy!

kubectl run -it --rm --restart=Never --image=mysql:5.6 mysql-client — \
  mysql -h $DB_HOST -P 3306 -u $DB_USER -p$DB_PASSWORD
kubectl run -it --rm --restart=Never --image=meltwaterfoundation/drone-git bash — \
  bash