Documentation
¶
Index ¶
- Constants
- Variables
- func DeployPackage(filename, rootdir, pkgname string) (err error)
- func DiffUnits(spec []api.Unit, status []api.Unit, allModifiedVolumes sets.String) ([]api.Unit, []api.Unit)
- func DiffVolumes(spec []api.Volume, status []api.Volume) (map[string]api.Volume, map[string]api.Volume, sets.String)
- func IsUnitExist(rootdir, name string) bool
- func MergeSecretsIntoSpec(secrets map[string]map[string][]byte, units []api.Unit)
- func StartUnit(rootdir, podname, hostname, unitname, workingdir, netns string, ...) error
- type Config
- type EnvStore
- type HealthConfig
- type ImagePuller
- type Link
- type LogPipe
- type MiniUnit
- type Mounter
- type ParameterError
- type PodController
- func (pc *PodController) GetStatus() ([]api.UnitStatus, []api.UnitStatus, error)
- func (pc *PodController) GetUnitName(unitName string) (string, error)
- func (pc *PodController) SetPodNetwork(netNS, podIP string)
- func (pc *PodController) Start()
- func (pc *PodController) SyncPodUnits(spec *api.PodSpec, status *api.PodSpec, ...)
- func (pc *PodController) UpdatePod(params *api.PodParameters) error
- type Puller
- type Server
- type Unit
- func (u *Unit) CreateCommand(command []string, args []string) []string
- func (u *Unit) Destroy() error
- func (u *Unit) GetEnv() []string
- func (u *Unit) GetRootfs() string
- func (u *Unit) GetStatus() (*api.UnitStatus, error)
- func (u *Unit) GetUser(lookup util.UserLookup) (uid, gid uint32, groups []uint32, homedir string, err error)
- func (u *Unit) GetWorkingDir() string
- func (u *Unit) OpenStdinWriter() (io.WriteCloser, error)
- func (u *Unit) PullAndExtractImage(image, server, username, password string) error
- func (u *Unit) Run(podname, hostname string, command []string, workingdir string, ...) error
- func (u *Unit) SaveUnitConfig(unitConfig UnitConfig) error
- func (u *Unit) SetImage(image string) error
- func (u *Unit) SetState(state api.UnitState, restarts *int) error
- func (u *Unit) SetStatus(status *api.UnitStatus) error
- func (u *Unit) UpdateStatusAttr(ready, started *bool) error
- type UnitConfig
- type UnitManager
- func (um *UnitManager) CaptureLogs(name string, unit *Unit)
- func (um *UnitManager) GetLogBuffer(unit string) (*logbuf.LogBuffer, error)
- func (um *UnitManager) GetPid(unitName string) (int, bool)
- func (um *UnitManager) ReadLogBuffer(unit string, n int) ([]logbuf.LogEntry, error)
- func (um *UnitManager) RemoveUnit(name string) error
- func (um *UnitManager) StartUnit(podname, hostname, unitname, workingdir, netns string, ...) error
- func (um *UnitManager) StopUnit(name string) error
- func (um *UnitManager) UnitRunning(unit string) bool
- type UnitRunner
Constants ¶
const ( PIPE_UNIT_STDOUT = "unit-stdout" PIPE_UNIT_STDERR = "unit-stderr" )
const ( MULTIPART_PACKAGE = "package" ITZO_DIR = "/tmp/itzo" CERTS_DIR = ITZO_DIR DEFAULT_ROOTDIR = ITZO_DIR + "/units" ITZO_VERSION = "1.0" FILE_BYTES_LIMIT = 4096 )
const ( MAX_BACKOFF_TIME = 5 * time.Minute BACKOFF_RESET_TIME = 10 * time.Minute CHILD_OOM_SCORE = 15 // chosen arbitrarily... kernel will adjust this value MAX_HOSTNAME_LEN = 63 MaxContainerTerminationMessageLength = 1024 * 4 )
Variables ¶
var ( KubeRouterProg = "kube-router" KubeRouterURL = "https://milpa-builds.s3.amazonaws.com/kube-router" KubeRouterMinimumVersion = "v0.3.1" MaxBufferSize int64 = 1024 * 1024 * 10 // 10MB NVIDIA_CONTAINER_CLI_PRG = "nvidia-container-cli" NVIDIA_SMI_PRG = "nvidia-smi" )
var UNIT_PIPES = []string{PIPE_UNIT_STDOUT, PIPE_UNIT_STDERR}
Functions ¶
func DeployPackage ¶
func DiffVolumes ¶
func IsUnitExist ¶
func MergeSecretsIntoSpec ¶
Modifies the PodSpec and inserts secrets into the spec
Types ¶
type Config ¶
type Config struct {
Hostname string
Domainname string
User string
AttachStdin bool
AttachStdout bool
AttachStderr bool
ExposedPorts map[string]struct{} `json:",omitempty"`
Tty bool
OpenStdin bool
StdinOnce bool
Env []string
Cmd []string
Healthcheck *HealthConfig `json:",omitempty"`
ArgsEscaped bool `json:",omitempty"`
Image string
Volumes map[string]struct{}
WorkingDir string
Entrypoint []string
NetworkDisabled bool `json:",omitempty"`
MacAddress string `json:",omitempty"`
OnBuild []string
Labels map[string]string
StopSignal string `json:",omitempty"`
StopTimeout *int `json:",omitempty"`
Shell []string `json:",omitempty"`
}
This is the main config struct for docker images.
type HealthConfig ¶
type HealthConfig struct {
Test []string `json:",omitempty"`
Interval time.Duration `json:",omitempty"`
Timeout time.Duration `json:",omitempty"`
StartPeriod time.Duration `json:",omitempty"`
Retries int `json:",omitempty"`
}
This is part of the config of docker images.
type ImagePuller ¶
type ImagePuller struct {
}
func (*ImagePuller) PullImage ¶
func (ip *ImagePuller) PullImage(rootdir, name, image, server, username, password string) error
type MiniUnit ¶
type MiniUnit struct {
Name string
Image string
Command []string
Args []string
VolumeMounts []api.VolumeMount
Env []api.EnvVar
}
Only diff the parts of the unit we care about
type ParameterError ¶
type ParameterError struct {
// contains filtered or unexported fields
}
Some kind of invalid input from the user. Useful here to decide when to return a 4xx vs a 5xx.
func (*ParameterError) Error ¶
func (pe *ParameterError) Error() string
type PodController ¶
type PodController struct {
// contains filtered or unexported fields
}
I know how to do one thing: Make Controllers. A ton of controllers...
func NewPodController ¶
func NewPodController(rootdir string, mounter Mounter, unitMgr UnitRunner) *PodController
func (*PodController) GetStatus ¶
func (pc *PodController) GetStatus() ([]api.UnitStatus, []api.UnitStatus, error)
func (*PodController) GetUnitName ¶
func (pc *PodController) GetUnitName(unitName string) (string, error)
func (*PodController) SetPodNetwork ¶
func (pc *PodController) SetPodNetwork(netNS, podIP string)
func (*PodController) Start ¶
func (pc *PodController) Start()
func (*PodController) SyncPodUnits ¶
func (pc *PodController) SyncPodUnits(spec *api.PodSpec, status *api.PodSpec, allCreds map[string]api.RegistryCredentials)
func (*PodController) UpdatePod ¶
func (pc *PodController) UpdatePod(params *api.PodParameters) error
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) ListenAndServe ¶
func (*Server) RunLogTailer ¶
type Unit ¶
type Unit struct {
*LogPipe
Directory string
Name string
Image string
// contains filtered or unexported fields
}
func (*Unit) GetWorkingDir ¶
func (*Unit) OpenStdinWriter ¶
func (u *Unit) OpenStdinWriter() (io.WriteCloser, error)
func (*Unit) PullAndExtractImage ¶
func (*Unit) SaveUnitConfig ¶
func (u *Unit) SaveUnitConfig(unitConfig UnitConfig) error
func (*Unit) UpdateStatusAttr ¶
type UnitConfig ¶
type UnitConfig struct {
api.PodSecurityContext `json:"podSecurityContext"`
api.SecurityContext `json:"securityContext"`
StartupProbe *api.Probe `json:",omitempty"`
ReadinessProbe *api.Probe `json:",omitempty"`
LivenessProbe *api.Probe `json:",omitempty"`
TerminationMessagePolicy api.TerminationMessagePolicy
TerminationMessagePath string
PodIP string
}
type UnitManager ¶
type UnitManager struct {
// contains filtered or unexported fields
}
func NewUnitManager ¶
func NewUnitManager(rootDir string) *UnitManager
func (*UnitManager) CaptureLogs ¶
func (um *UnitManager) CaptureLogs(name string, unit *Unit)
func (*UnitManager) GetLogBuffer ¶
func (um *UnitManager) GetLogBuffer(unit string) (*logbuf.LogBuffer, error)
func (*UnitManager) ReadLogBuffer ¶
func (*UnitManager) RemoveUnit ¶
func (um *UnitManager) RemoveUnit(name string) error
This removes the unit and its files/directories from the filesystem.
func (*UnitManager) StartUnit ¶
func (um *UnitManager) StartUnit(podname, hostname, unitname, workingdir, netns string, command, args, appenv []string, policy api.RestartPolicy) error
This is a bit tricky in Go, since we are not supposed to use fork(). Instead, call the daemon with command line flags indicating that it is only used as a helper to start a new unit in a new filesystem namespace.
func (*UnitManager) StopUnit ¶
func (um *UnitManager) StopUnit(name string) error
It's possible we need to set up some communication with the waiting process that it doesn't need to clean up everything. Lets see how the logging works out...
func (*UnitManager) UnitRunning ¶
func (um *UnitManager) UnitRunning(unit string) bool
type UnitRunner ¶
type UnitRunner interface {
StartUnit(string, string, string, string, string, []string, []string, []string, api.RestartPolicy) error
StopUnit(string) error
RemoveUnit(string) error
}
Too bad there isn't a word for a creator AND destroyer Coulda gone with Shiva(er) but that's a bit imprecise...