Skip to content

Commit

Permalink
Adds pieces for PersistentVolume and PersistentVolumesClaims
Browse files Browse the repository at this point in the history
  • Loading branch information
pcm32 committed Apr 7, 2016
1 parent d5abfb6 commit 2c485d7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions config/job_conf_k8s.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<plugin id="k8s" type="runner" load="galaxy.jobs.runners.kubernetes:kubernetes">
<param id="k8s_config_path">/path/to/kubeconfig</param>
<param id="k8s_persistent_volume_claim_name">galaxy_pvc</param>
<!-- The following mount path needs to be the initial part of the "file_path" and "new_file_path" paths
set in universe_wsgi.ini (or equivalent general galaxy config file).
-->
<param id="k8s_persistent_volume_claim_mount_path">/mnt/glusterfs</param>
</plugin>
</plugins>
<handlers>
Expand Down
19 changes: 16 additions & 3 deletions lib/galaxy/jobs/runners/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__( self, app, nworkers ):

# here we need to fetch the default kubeconfig path from the plugin defined in job_conf...
self._pykube_api = HTTPClient(KubeConfig.from_file(self.runner_params["k8s_config_path"]))
self._galaxy_vol_name = "pvc_galaxy"

# TODO do we need these?
# self._init_monitor_thread()
Expand Down Expand Up @@ -131,15 +132,27 @@ def __get_k8s_restart_policy(self, job_wrapper):

def __get_k8s_mountable_volumes(self, job_wrapper):
"""Provides the required volumes that the containers in the pod should be able to mount. This should be using
the new persistent volumes and persistent volumes claim objects.
the new persistent volumes and persistent volumes claim objects. This requires that both a PersistentVolume and
a PersistentVolumeClaim are created before starting galaxy (starting a k8s job).
"""

# TODO on this initial version we only support a single volume to be mounted.
k8s_mountable_volume = {
"name": self._galaxy_vol_name,
"persistentVolumeClaim": {
"claimName": self.runner_params['k8s_persistent_volume_claim_name']
}
}
return k8s_mountable_volume

def __get_k8s_containers(self, job_wrapper):
"""Fills in all required for setting up the docker containers to be used."""
k8s_container = {
"name": self.__get_k8s_container_name(job_wrapper),
"image": self.__assemble_k8s_container_image_name(job_wrapper)
"image": self.__assemble_k8s_container_image_name(job_wrapper),
"volumeMounts": {
"mountPath": self.runner_params['k8s_persistent_volume_claim_mount_path'],
"name": self._galaxy_vol_name
}
}

if self.__requires_ports(job_wrapper):
Expand Down

0 comments on commit 2c485d7

Please sign in to comment.