Skip to content

Develop locally

Jonas Umland edited this page Nov 28, 2020 · 9 revisions

Develop locally

There are some easy ways to work locally. We assume that you have a local kubernetes (like minikube) up and running and the newest version of the application is deployed. It is recommended to use some kubernetes helper like the VSCode kubernetes extension. Garden will deploy all services to a namespace called mpci_default. So while monitoring the cluster, you will type kubectl ... -n mpci-default a lot. To make your life easier you can add run kubectl config set-context --current --namespace=mpci-default.

Only developing the frontend

If you only want to do frontend development, just execute kubectl port-forward -n BACKENDPOD 5000:5000. With this it will be like you have the backend running locally. Navigate to services/frontend-image/src and execute yarn if you need to update dependencies. To run the frontend in development mode locally, execute yarn start. Have fun developing locally! If you want to run tests or lint, execute yarn test or yarn lint.

Develop backend (and frontend)

  1. Run kubectl port-forward -n ENV YOUR_POSTGRES_POD 5432:5432
  2. Set the POSTGRES_USER and POSTGRES_PASSWORD env variables to right values(using export etc)
  3. cd services/python-images
  4. pip install -r requirements.txt
  5. python server.py

You now have your backend running locally. To start the frontend as well, follow the steps above.

Scheduler

There is no easy way to run the scheduler locally, since it needs to execute in cluster commands. You can swap the deployment from your minikube cluster using Telepresence and by setting the env variable IN_CLUSTER to false.

Execution Environment Images

The local execution environment images are not deployed by Garden, because they are not required directly by any deployment. Instead by default they are always pulled from DockerHub. Here, I will use the R environment images as an example but the same also applied for the python and cuda images. First we need to enable the scheduled Job to use local images instead of always pulling. In executor-job.yaml we need to change spec.template.spec.containers.imagePullPolicy to IfNotPresent.
Now to point your terminal to use the docker daemon inside minikube run this (minikube must be started):

eval $(minikube docker-env)

Now any ‘docker’ command you run in this current terminal will run against the docker inside minikube cluster. Now you can ‘build’ against the docker inside minikube. which is instantly accessible to kubernetes cluster.

Make sure to run the following command from inside services/executionenvironments/r.
docker build . -f r-executor.Dockerfile -t milanpro/mpci_execution_r:latest. (If needed, change path to Dockerfile)

Different ways of adding a local Docker image to Minikube are shown here.

Right now we are not aware of any way to do this with Garden - in case there is one, please change accordingly.