nomad

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

This file transforms a Nomad scheduler as an orchestration platform for persistent volume placement. OpenEBS calls this as placement of storage pod.

Package nomad provides Nomad implementation of orchestration provider that aligns by the interfaces suggested by mayaserver's orchprovider.

This package primarily consists of below files: 1. nomad.go 2. api.go 3. client.go

The dependencies can be depicted as shown below:

nomad   ==    aligns with   ==>   orchprovider

nomad   ==    depends on    ==>   api
nomad   ==    depends on    ==>   client
api     ==    depends on    ==>   client

This file acts a bi-directional plug to below resources:

  1. Mayaserver's orchprovider types
  2. Hashicorp Nomad's types

Index

Constants

View Source
const (
	// Names of environment variables used to supply the coordinates
	// of a Nomad deployment
	EnvNomadAddress = "NOMAD_ADDR"
	EnvNomadRegion  = "NOMAD_REGION"
)
View Source
const NomadOrchProviderName = "nomad"

Name of this orchestration provider.

Variables

This section is empty.

Functions

func JobSummaryToPv

func JobSummaryToPv(jobSummary *api.JobSummary) (*v1.PersistentVolume, error)

func PvToJob

func PvToJob(pv *v1.PersistentVolume) (*api.Job, error)

Transform a PersistentVolume type to Nomad Job type

func PvcToJob

func PvcToJob(pvc *v1.PersistentVolumeClaim) (*api.Job, error)

Transform a PersistentVolumeClaim type to Nomad job type

Types

type Apis

type Apis interface {

	// This returns a client that can communicate with Nomad
	Client() (NomadClient, error)

	// This returns a concrete implementation of StorageApis
	StorageApis(nApiClient NomadClient) (StorageApis, error)
}

Apis provides a means to communicate with Nomad Apis

type NomadClient

type NomadClient interface {
	Http() (*api.Client, error)
}

NomadClient is an abstraction over various connection modes (http, rpc) to Nomad. Http client is currently supported.

NOTE:

This abstraction makes use of Nomad's api package. Nomad's api

package provides:

1. http client abstraction & 2. structures that can send http requests to Nomad's APIs.

type NomadConfig

type NomadConfig struct {
	Address string
}

NomadConfig provides the settings that has the coordinates of a Nomad server or a Nomad cluster deployment.

type NomadOrchestrator

type NomadOrchestrator struct {
	// contains filtered or unexported fields
}

NomadOrchestrator is a concrete representation of following interfaces:

  1. orchprovider.OrchestratorInterface &
  2. orchprovider.StoragePlacements

func (*NomadOrchestrator) Name

func (n *NomadOrchestrator) Name() string

Name provides the name of this orchestrator. This is an implementation of the orchprovider.OrchestratorInterface interface.

func (*NomadOrchestrator) StoragePlacementReq

func (n *NomadOrchestrator) StoragePlacementReq(pvc *v1.PersistentVolumeClaim) (*v1.PersistentVolume, error)

StoragePlacementReq is a contract method implementation of orchprovider.StoragePlacements interface. In this implementation, a resource will be created at a Nomad deployment.

NOTE:

Nomad does not have persistent volume as its first class citizen.

Hence, this resource should exhibit storage characteristics. The validations for this should have been done at the volume plugin implementation.

func (*NomadOrchestrator) StoragePlacements

func (n *NomadOrchestrator) StoragePlacements() (orchprovider.StoragePlacements, bool)

StoragePlacements is this orchestration provider's implementation of the orchprovider.OrchestratorInterface interface.

func (*NomadOrchestrator) StorageRemovalReq

func (n *NomadOrchestrator) StorageRemovalReq(pv *v1.PersistentVolume) error

StorageRemovalReq is a contract method implementation of orchprovider.StoragePlacements interface. In this implementation, the resource will be removed from the Nomad deployment.

NOTE:

Nomad does not have persistent volume as its first class citizen.

Hence, this resource should exhibit storage characteristics. The validations for this should have been done at the volume plugin implementation.

type StorageApis

type StorageApis interface {
	// Create makes a request to Nomad to create a storage resource
	CreateStorage(job *api.Job) (*api.JobSummary, error)

	// Delete makes a request to Nomad to delete the storage resource
	DeleteStorage(job *api.Job) (string, error)
}

StorageApis provides a means to communicate with Nomad Apis w.r.t storage.

NOTE:

A Nomad job spec is treated as a persistent volume storage

spec & then submitted to a Nomad deployment.

NOTE:

Nomad has no notion of Persistent Volume.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL