workloads

package
v1.6.8 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Overview

Copyright 2018-2019 Authors of Cilium

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package workloads abstracts individual workload types

Index

Constants

View Source
const (
	// EpOpt is the option name for path to endpoint
	EpOpt = "endpoint"
	// DatapathModeOpt is the option name for datapath mode
	DatapathModeOpt = "datapath-mode"
)
View Source
const (
	// EventTypeStart represents when a workload was started
	EventTypeStart eventType = "start"
	// EventTypeDelete represents when a workload was deleted
	EventTypeDelete eventType = "delete"
)
View Source
const (
	// EndpointCorrelationMaxRetries is the number of retries to correlate
	// a workload start event with an existing endpoint before giving up.
	EndpointCorrelationMaxRetries = 20
)

Variables

This section is empty.

Functions

func EnableEventListener

func EnableEventListener() (eventsCh chan<- *EventMessage, err error)

EnableEventListener watches for docker events. Performs the plumbing for the containers started or dead.

func EndpointCorrelationSleepTime

func EndpointCorrelationSleepTime(try int) time.Duration

EndpointCorrelationSleepTime returns the sleep time between correlation attempts

func GetDefaultEPOptsStringWithPrefix

func GetDefaultEPOptsStringWithPrefix(prefix string) string

GetDefaultEPOptsStringWithPrefix returns the defaults options for each runtime with the given prefix.

func GetRuntimeDefaultOpt

func GetRuntimeDefaultOpt(crt WorkloadRuntimeType, opt string) string

GetRuntimeDefaultOpt returns the default options for the given container runtime.

func GetRuntimeOptions

func GetRuntimeOptions() string

GetRuntimeOptions returns a string representation of the container runtimes stored and the list of options for each container runtime.

func IgnoreRunningWorkloads

func IgnoreRunningWorkloads()

IgnoreRunningWorkloads checks for already running containers and checks their IP address, then adds the containers to the list of ignored containers and allocates the IPs they are using to prevent future collisions.

func Init

func Init(o WorkloadOwner)

Init initializes the workloads package

func IsRunning

func IsRunning(ep *endpoint.Endpoint) bool

IsRunning returns false if the provided endpoint cannot be associated with a running workload. The runtime must be reachable to make this decision.

func Setup

func Setup(a allocatorInterface, workloadRuntimes []string, opts map[WorkloadRuntimeType]map[string]string) error

Setup sets up the workload runtime specified in workloadRuntime and configures it with the options provided in opts

func Status

func Status() *models.Status

Status returns the status of the workload runtime

Types

type EventMessage

type EventMessage struct {
	WorkloadID string
	EventType  eventType
}

EventMessage is the structure use for the different workload events.

type WorkloadOwner

type WorkloadOwner interface {
	regeneration.Owner

	// DeleteEndpoint is called when the underlying workload has died
	DeleteEndpoint(id string) (int, error)
}

WorkloadOwner is the interface that the owner of workloads must implement.

func Owner

func Owner() WorkloadOwner

Owner returns the owner instance of all workloads

type WorkloadRuntime

type WorkloadRuntime interface {
	// EnableEventListener enables the event listener of the workload runtime
	// If the workload runtime does not support events, it will return a
	// events channel where the caller will be in charge of sending the
	// create and stop events.
	EnableEventListener() (eventsCh chan<- *EventMessage, err error)
	// Status returns the status of the workload runtime.
	Status() *models.Status
	// IsRunning returns true if the endpoint is available and in a running
	// state in the respective workload runtime.
	IsRunning(ep *endpoint.Endpoint) bool
	// IgnoreRunningWorkloads sets the runtime to ignore all running workloads.
	IgnoreRunningWorkloads()

	// GetAllInfraContainersPID returns a list of workload IDs running in the
	// workload that represent a infra container.
	GetAllInfraContainersPID() (map[string]int, error)
	// contains filtered or unexported methods
}

WorkloadRuntime are the individual workload runtime operations that each workload must implement.

func Client

func Client() WorkloadRuntime

Client returns the global WorkloadRuntime being used.

type WorkloadRuntimeType

type WorkloadRuntimeType string

WorkloadRuntimeType is the type of a container runtime

const (
	None WorkloadRuntimeType = "none"
	Auto WorkloadRuntimeType = "auto"
)
const (
	CRIO WorkloadRuntimeType = "crio"
)
const (
	ContainerD WorkloadRuntimeType = "containerd"
)
const (
	Docker WorkloadRuntimeType = "docker"
)

Jump to

Keyboard shortcuts

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