Skip to content

Galaxy inside Kubernetes

Pablo Moreno edited this page Jul 6, 2016 · 16 revisions

Running Galaxy inside Kubernetes

In this installation, the Galaxy server runs as a Kubernetes Pod (controlled by a Replication Controller) inside Kubernetes, and uses the Service Account to communicate to the master nodes to send jobs to run. This simplifies greatly the installation of Galaxy as compared to the other schema, as in this case Galaxy runs inside a container and we only need to specify this the cluster.

Given that the PVC has already been created, the only necessary thing to do is to create a Service (for access) and Replication Controller that invokes the desired Galaxy docker image previously configured to run inside Kubernetes. The service looks like this:

apiVersion: v1
kind: Service
metadata:
  name: galaxy-svc-k8s
  labels:
    app: galaxy-k8s
spec:
  type: NodePort
  ports:
   - 
     port: 8080
  selector:
    app: galaxy-k8s

Put this in a file named galaxy-k8s-service.yaml and issue kubectl create -f galaxy-k8s-service.yaml. Take note of the output, it will tell you on which port you can access it later as galaxy becomes available.

And the Replication Controller:

apiVersion: v1
kind: ReplicationController
metadata:
  name: galaxy-k8s 
spec:
  replicas: 1
  template:
    metadata:
      labels:
         app: galaxy-k8s
    spec:
      containers:
      - name: galaxy-k8s
        image: docker-registry.phenomenal-h2020.eu/phnmnl/galaxy-k8s-runtime
        imagePullPolicy: IfNotPresent
        ports:
          - containerPort: 8080
        volumeMounts:
          - mountPath: "/opt/galaxy-data"
            name: galaxy-pvc
      volumes:
        - name: galaxy-pvc
          persistentVolumeClaim:
              claimName: galaxy-pvc

again, save this file as galaxy-k8s-rc.yaml and execute kubectl create -f galaxy-k8s-rc.yaml.

Accessing the Galaxy instance

To access Galaxy deployed like we showed, you need to know the IP of your Kubernetes master (or of one of its nodes) and the port number in which Galaxy is being served. The IP can be obtained by executing:

kubectl cluster-info

which should produce something like:

Kubernetes master is running at https://192.168.99.100:443
kubernetes-dashboard is running at https://192.168.99.100:443/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard

In this case 192.168.99.100 is the IP of the Kubernetes master.

If you didn't take notice on the message of the created service, you can execute kubectl describe svc/galaxy-svc-k8s and you should get an output like this (which shows the port that you need to access):

Name:			galaxy-svc-k8s
Namespace:		default
Labels:			app=galaxy-k8s
Selector:		app=galaxy-k8s
Type:			NodePort
IP:			10.0.0.111
Port:			<unset>	8080/TCP
NodePort:		<unset>	32328/TCP
Endpoints:		172.17.0.3:8080
Session Affinity:	None
No events.

This means that to access Galaxy, you need to point to your browser to port 32328 of your Kubernetes cluster IP. So for our example, Galaxy should be accessible on http://192.168.99.100:32328/.

TL;DR

Copy paste this:

apiVersion: v1
kind: Service
metadata:
  name: galaxy-svc-k8s
  labels:
    app: galaxy-k8s
spec:
  type: NodePort
  ports:
   - 
     port: 8080
  selector:
    app: galaxy-k8s
--
apiVersion: v1
kind: ReplicationController
metadata:
  name: galaxy-k8s 
spec:
  replicas: 1
  template:
    metadata:
      labels:
         app: galaxy-k8s
    spec:
      containers:
      - name: galaxy-k8s
        image: docker-registry.phenomenal-h2020.eu/phnmnl/galaxy-k8s-runtime
        imagePullPolicy: IfNotPresent
        ports:
          - containerPort: 8080
        volumeMounts:
          - mountPath: "/opt/galaxy-data"
            name: galaxy-pvc
      volumes:
        - name: galaxy-pvc
          persistentVolumeClaim:
              claimName: galaxy-pvc

into a file called galaxy-k8s-sv-rc.yaml and execute kubectl create -f galaxy-k8s-sv-rc.yaml. A message will indicate on which port of any of the node's IPs you can access Galaxy.

Clone this wiki locally