项目作者: StefanoFioravanzo

项目描述 :
General purpose Kubernetes operator for DL frameworks written in Python
高级语言: Python
项目地址: git://github.com/StefanoFioravanzo/dl-operator.git
创建时间: 2018-09-13T15:40:30Z
项目社区:https://github.com/StefanoFioravanzo/dl-operator

开源协议:

下载


Custom Operator for DL jobs

Overview

This project is a proof of concept of a Python Kubernetes operator for deep learning jobs. The project was inspired by Kuberflow’s tf-operator and then by the work done to implement the mx-operator.

Supported frameworks:

  • Tensorflow
  • MXNet

The operator was build to be general purpose, so adding any new deep learning frameworks should be straightforward. The operator works best with deep learning framework that can setup a cluster just by reading environment variables. In this way one just needs to extend the standard base class providing the framework specific env variables and container parameters.

Structure

  1. .
  2. ├── controller.py
  3. ├── crds
  4. ├── crd
  5. └── mxjob.yml
  6. └── mxjob_test.yml
  7. ├── dl_job.py
  8. ├── logging.ini
  9. ├── main.py
  10. ├── replica.py
  11. └── settings
  12. └── settings.py

DLOperator

Defined in controller.py, the DLOperator object is tasked to continuously watch for new job requests by registering to the new custom resources stream.

Once the Operator receives a new unregistered job, it creates a new DLJob.

DLJob

Object responsible to maintain the state of the provided job spec with respect to the actual cluster state. This constant cycle of checking the current state and reconciling it with the desired state is the focal point of any custom Kubernetes controller.

DLJob is an abstract class that must be extended with the specific deep learning framework details.

A correct subclass must provide the following class variables:

  • job_type: crd name (e.g. MXJob)
  • replica_types: list with the names of the types of replicas (e.g. scheduler, master, …)
  • container_properties: Dictionary with container properties (e.g. open ports, mount volume paths)

Also, the following abstract methods must be implemented:

  • get_environment_variables(): This method must return a dictionary of environment variables to be injected into the container.

Replica

A Replica object encapsulates all the logic related to one running pod. One replica manages the reconciliation process, from pod-service creation until its death.

Run

To test and run the operator it is advisable to use a local single-node cluster via minikube. The operator will create the necessary custom resource definitions by itself and clean up all the allocated resources when killed.

  1. # start minikube cluster
  2. minikube start
  3. # check cluster status
  4. minikube status
  5. # check kubectl is using the proper context
  6. kubectl config get-contexts
  7. # run the operator
  8. python main.py
  9. # depoy dljob
  10. kubectl create -f crds/maxjob_test.yml

TODO

  • Allow network communication via hostnames
  • Monitor process exit statuses and react accordingly
  • Improve job status and result reporting
  • Add automated tests