Orchestrator interface
Context
The orchestrator interface will have methods to support different orchestrator implementations. These orchestrators will be used to register nodes as part of the orchestrator's cluster, and containers that will run some process inside of them.
For our current milestone, we'll be using Kubernetes, that provides support for managing nodes and pods. Other orchestrators (Docker Swarm, Rancher, OpenShift, AWS Fargate) should be taken into account while designing this interface.
Nodes
- Wait until a node is ready
- Wait until a node matches a certain condition
Pods (Container? Worker?)
- Execute a command
- Get logs from a container
- Get all pods that match a certain label
- Wait for ready condition
- Wait until a pod matches a certain condition
Proposed changes
type Condition string
var (
ReadyCondition Condition = "Ready"
)
type Orchestrator interface {
Nodes() Nodes
Pods() Pods
}
type Nodes interface {
Waiter
}
type Pods interface {
Run(selector string) Runner
Reader(selector string) Reader
Waiter
}
type Runner interface {
// Cmd runs a command inside a container.
Cmd(command[]string)
// Script runs a script inside a container.
// Could be used to run copy_to_s3.sh
Script(path string) error
}
type Reader interface {
File(paths ...string) (*bytes.Buffer, error)
Logs(lines int64) (*string, error)
}
type Waiter interface {
Wait(selector string, condition Condition, timeout time.Duration, pollFrequency time.Duration)
Other information
Edited by Marcos Huck