Skip to content

Galaxy inside Kubernetes

jbradbury edited this page Jul 26, 2018 · 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 to the cluster.

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

To create the service:

  • Create a file named galaxy-k8s-service.yaml and add the following content to it:
apiVersion: v1
kind: Service
metadata:
  name: galaxy-svc-k8s
  labels:
    app: galaxy-k8s
spec:
  type: NodePort
  ports:
   - name: http 
     port: 8080
     nodePort: 30700
  selector:
    app: galaxy-k8s
  • Execute, standing on the same directory where the file was created, the following command on the shell:
$ kubectl create -f galaxy-k8s-service.yaml

Take note of the output, it will tell you that you can access Galaxy on port 30700 later, as Galaxy becomes available.

Finally, to create the Replication Controller, follow these steps:

  • Create a file named galaxy-k8s-rc.yaml and add the following yaml content:
apiVersion: v1
kind: ReplicationController
metadata:
  name: galaxy-k8s 
spec:
  replicas: 1
  template:
    metadata:
      labels:
         app: galaxy-k8s
    spec:
      containers:
      - name: galaxy-k8s
        image: container-registry.phenomenal-h2020.eu/phnmnl/galaxy-k8s-runtime
        command: ["/bin/bash","-c","mkdir -p /opt/galaxy_data/database-sqlite && ./run.sh --daemon && tail -f paster.log"]
        lifecycle: 
          preStop:
            exec:
               command:
                   - "./run.sh"
                   - "--stop"
        imagePullPolicy: Always
        ports:
          - containerPort: 8080
        volumeMounts:
          - mountPath: "/opt/galaxy_data"
            name: galaxy-pvc
      volumes:
        - name: galaxy-pvc
          persistentVolumeClaim:
              claimName: galaxy-pvc
  • Standing on the same directory, execute on the shell
$ 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. DO NOT USE HTTPS, BUT HTTP ONLY.

This means that to access Galaxy, you need to point to your browser to port 30700 (as we fixed that on the SVC previously) of your Kubernetes cluster IP. So for our example, Galaxy should be accessible on http://192.168.99.100:30700/. Please DO NOT USE HTTPS, BUT HTTP ONLY.

For Galaxy tool developers

If you want to try Galaxy tools that you're developing within this Galaxy installation, please click to follow this guide.

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: container-registry.phenomenal-h2020.eu/phnmnl/galaxy-k8s-runtime
        imagePullPolicy: Always
        command: ["/bin/bash","-c","mkdir -p /opt/galaxy_data/database-sqlite && ./run.sh --daemon && tail -f paster.log"]
        lifecycle: 
          preStop:
            exec:
               command:
                   - "./run.sh"
                   - "--stop"
        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