packages/teraslice/lib/cluster/services/cluster/backends/kubernetes/index.js
function allocateSlicer(execution) {
        const exSvcResource = new K8sResource(
            'services', 'execution_controller', context.sysconfig.teraslice, execution
        );

        const exService = exSvcResource.resource;

        execution.slicer_port = _.get(exService, 'spec.ports[0].targetPort');
        execution.slicer_hostname = _.get(exService, 'metadata.name');

        const exJobResource = new K8sResource(
            'jobs', 'execution_controller', context.sysconfig.teraslice, execution
        );
        const exJob = exJobResource.resource;

        logger.debug(`exJob:\n\n${JSON.stringify(exJob, null, 2)}`);

        // TODO: This should try slicerAllocationAttempts times??
        return k8s.post(exService, 'service')
            .then(result => logger.debug(`k8s slicer service submitted: ${JSON.stringify(result)}`))
            .catch((err) => {
                const error = new TSError(err, {
                    reason: 'Error submitting k8s slicer service'
                });
                return Promise.reject(error);
            })
            .then(() => k8s.post(exJob, 'job'))
            .then(result => logger.debug(`k8s slicer job submitted: ${JSON.stringify(result)}`))
            .catch((err) => {
                const error = new TSError(err, {
                    reason: 'Error submitting k8s slicer job'
                });
                return Promise.reject(error);
            });
    }
function allocateSlicer(execution) {
        const exSvcResource = new K8sResource(
            'services', 'execution_controller', context.sysconfig.teraslice, execution
        );

        const exService = exSvcResource.resource;

        execution.slicer_port = _.get(exService, 'spec.ports[0].targetPort');
        execution.slicer_hostname = _.get(exService, 'metadata.name');

        const exJobResource = new K8sResource(
            'jobs', 'execution_controller', context.sysconfig.teraslice, execution
        );
        const exJob = exJobResource.resource;

        logger.debug(`exJob:\n\n${JSON.stringify(exJob, null, 2)}`);

        // TODO: This should try slicerAllocationAttempts times??
        return k8s.post(exService, 'service')
            .then(result => logger.debug(`k8s slicer service submitted: ${JSON.stringify(result)}`))
            .catch((err) => {
                const error = new TSError(err, {
                    reason: 'Error submitting k8s slicer service'
                });
                return Promise.reject(error);
            })
            .then(() => k8s.post(exJob, 'job'))
            .then(result => logger.debug(`k8s slicer job submitted: ${JSON.stringify(result)}`))
            .catch((err) => {
                const error = new TSError(err, {
                    reason: 'Error submitting k8s slicer job'
                });
                return Promise.reject(error);
            });
    }
Creates k8s Service and Job for the Teraslice Execution Controller
(formerly slicer).  This currently works by creating a service with a
hostname that contains the exId in it listening on a well known port.
The hostname and port are used later by the workers to contact this
Execution Controller.
@param  {Object} execution        Object containing execution details
@return {Promise}                 [description]