Skip to content

Instantly share code, notes, and snippets.

@gabrielctn
Last active May 20, 2018 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabrielctn/7f5e586fe0a900a879591dabe1fc26ca to your computer and use it in GitHub Desktop.
Save gabrielctn/7f5e586fe0a900a879591dabe1fc26ca to your computer and use it in GitHub Desktop.
PhenoMeNal Galaxy on Minikube

Intro

How to use and install my own local Phenomenal Galaxy infrastructure ?

For the development of a tool in PhenoMeNal, for curiosity or for fun, this gist explains step by step how to get a local up and running PhenoMeNal e-infrastructure on Kubernetes minikube.

HowTo

Check out repo

git clone https://github.com/phnmnl/container-galaxy-k8s-runtime.git
cd container-galaxy-k8s-runtime

Start minikube

minikube start

Configure helm

helm init
helm repo add galaxy-helm-repo https://pcm32.github.io/galaxy-helm-charts

Reconfigure docker to use minikube docker deamon and install your own galaxy image

eval $(minikube docker-env)

Local Galaxy Version

Get a terminal
Stand on the directory where the galaxy dockerfile is
Make sure that you're in the correct branch and commit
Then do eval> $(minikube docker-env) to use the docker daemon of minikube
Build your container

docker build -t galaxy-test .

Create an admin role to enable launching jobs

kubectl create clusterrolebinding add-on-cluster-admin --clusterrole=cluster-admin --serviceaccount=default:default

Install and run custom helm

helm install --set galaxy_image="galaxy-test", galaxy_image_registry="", development_folder="/hosthome/path/to/container-galaxy-k8s-run", pv_minikube="yes", galaxy_admin_email="gcretin@ipb-halle.de", galaxy_admin_password="admin1", galaxy_api_key="qwertyuio" galaxy-helm-repo/galaxy

"galaxy-image" can be customized.
"development_folder" needs a path to your local galaxy repo. On linux systems "home" directory is replaced by "hosthome" in the virtual environment, so paths should take it into account.
"galaxy_admin_password" requires at least 6 characters.

Check the running pod

kubectl get pods
kubectl logs -f <galaxy-k8s-NUMBER from previous command>

When everything is set up and running, the log should give:

...
serving on 0.0.0.0:8080 view at http://127.0.0.1:8080

You can then open the Galaxy instance in your browser with:

open http://$(minikube ip):30700

Convenient miscellaneous commands / short scripts

Clean up (actually wipe out) minikube, helm and everything, and restart everything nicely from scratch (execute each command one by one)

minikube stop
minikube delete
rm -r $HOME/.helm
rm -r $HOME/.minikube
minikube start
minikube ssh
sudo rm -rf /data/galaxy-data
exit
helm init
helm repo add galaxy-helm-repo https://pcm32.github.io/galaxy-helm-charts
eval $(minikube docker-env)
docker build -t galaxy-test .
kubectl create clusterrolebinding add-on-cluster-admin --clusterrole=cluster-admin --serviceaccount=default:default
helm install --set galaxy_image="galaxy-test", galaxy_image_registry="", development_folder="/hosthome/path/to/container-galaxy-k8s-run", pv_minikube="yes", galaxy_admin_email="gcretin@ipb-halle.de", galaxy_admin_password="admin1", galaxy_api_key="qwertyuio" galaxy-helm-repo/galaxy

If you want to restart your Galaxy runtime container, do somethings like

helm list
helm delete <funny-name>
kubectl delete secrets/galaxy-admin-secret
kubectl delete configmaps/galaxy-admin-user
kubectl delete configmaps/db-connection #if necessary
kubectl delete secrets/galaxy-postgres-secret #if necessary
docker build -t galaxy-test .
helm install --set galaxy_image="galaxy-test", galaxy_image_registry="", development_folder="/hosthome/path/to/container-galaxy-k8s-run", pv_minikube="yes", galaxy_admin_email="gcretin@ipb-halle.de", galaxy_admin_password="admin1", galaxy_api_key="qwertyuio" galaxy-helm-repo/galaxy

Restart galaxy interface directly from inside the container

con=$(kubectl get pods | grep Running | cut -d" " -f1)
kubectl delete pods $con
sleep 4
con=$(kubectl get pods | grep Running | cut -d" " -f1)
kubectl exec -i -t $con -- /galaxy/run.sh --restart

Delete all non running or container creating pods
kubectl get pods | grep -v -E "ContainerCreating|Running|NAME" | awk '{print $1}' | xargs kubectl delete pod

Delete all jobs done (successful = 1)
kubectl get jobs | awk '$3 !~ 0 && $1 ~ /^galaxy*/ {print $1}' | xargs kubectl delete jobs

See ports listening

netstat -tulpn

or

ps -ef

See status of the docker service

systemctl status docker.service
# to start / stop the docker daemon
service docker start
service docker stop

After helm init, you should be able to run

kubectl get pods --namespace kube-system 

and see Tiller running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment