types

package
v0.0.0-...-9b4d37b Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LabelRequestCPU is the label to be used to specify cpu request/limits
	LabelRequestCPU = "com.joyrex2001.kubedock.request-cpu"
	// LabelRequestMemory is the label to use to specify memory request/limits
	LabelRequestMemory = "com.joyrex2001.kubedock.request-memory"
	// LabelPullPolicy is the label to be used to configure the pull policy
	LabelPullPolicy = "com.joyrex2001.kubedock.pull-policy"
	// LabelServiceAccount is the label to be used to enforce a service account
	// other than 'default' for the created pods.
	LabelServiceAccount = "com.joyrex2001.kubedock.service-account"
	// LabelNamePrefix is the label to be used to enforce a prefix for the names used
	// for the container deployments.
	LabelNamePrefix = "com.joyrex2001.kubedock.name-prefix"
	// LabelRunasUser is the label to be used to enforce a specific user (uid) that
	// runs inside the container can also be enforced w
	LabelRunasUser = "com.joyrex2001.kubedock.runas-user"
	// LabelActiveDeadlineSeconds is the label to be used to specify active deadline in seconds
	LabelActiveDeadlineSeconds = "com.joyrex2001.kubedock.active-deadline-seconds"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container struct {
	ID             string
	ShortID        string
	Name           string
	Image          string
	Labels         map[string]string
	Entrypoint     []string
	Cmd            []string
	Env            []string
	Binds          []string
	Mounts         []Mount
	PreArchives    []PreArchive
	HostIP         string
	ExposedPorts   map[string]interface{}
	ImagePorts     map[string]interface{}
	HostPorts      map[int]int
	MappedPorts    map[int]int
	Networks       map[string]interface{}
	NetworkAliases []string
	StopChannels   []chan struct{}
	AttachChannels []chan struct{}
	Running        bool
	Completed      bool
	Failed         bool
	Stopped        bool
	Killed         bool
	Created        time.Time
	Finished       time.Time
}

Container describes the details of a container.

func (*Container) AddAttachChannel

func (co *Container) AddAttachChannel(stop chan struct{})

AddAttachChannel will add channels that should be notified when SignalDetach is called.

func (*Container) AddHostPort

func (co *Container) AddHostPort(src string, dst string) error

AddHostPort will add a predefined port mapping.

func (*Container) AddStopChannel

func (co *Container) AddStopChannel(stop chan struct{})

AddStopChannel will add channels that should be notified when SignalStop is called.

func (*Container) ConnectNetwork

func (co *Container) ConnectNetwork(id string)

ConnectNetwork will attach a network to the container.

func (*Container) DisconnectNetwork

func (co *Container) DisconnectNetwork(id string) error

DisconnectNetwork will detach a network from the container.

func (*Container) GetActiveDeadlineSeconds

func (co *Container) GetActiveDeadlineSeconds() (*int64, error)

GetActiveDeadlineSeconds will return the active deadline seconds to be used for containers that are deployed.

func (*Container) GetContainerTCPPorts

func (co *Container) GetContainerTCPPorts() []int

GetContainerTCPPorts will return a list of all ports that are exposed by this container.

func (*Container) GetEnvVar

func (co *Container) GetEnvVar() []corev1.EnvVar

GetEnvVar will return the environment variables of the container as k8s EnvVars.

func (*Container) GetImagePullPolicy

func (co *Container) GetImagePullPolicy() (corev1.PullPolicy, error)

GetImagePullPolicy will return the image pull policy that should be applied for this container.

func (*Container) GetImageTCPPorts

func (co *Container) GetImageTCPPorts() []int

GetImageTCPPorts will return a list of all ports that are exposed by the image.

func (*Container) GetPodName

func (co *Container) GetPodName() string

GetPodName will return a human friendly name that can be used for the container deployments.

func (*Container) GetPodSecurityContext

func (co *Container) GetPodSecurityContext(context *corev1.PodSecurityContext) (*corev1.PodSecurityContext, error)

GetPodSecurityContext will create a security context for the Pod that implements the relevant features of the Docker API. Right now this only covers the ability to specify the numeric user a container should run as.

func (*Container) GetPreArchiveFiles

func (co *Container) GetPreArchiveFiles() map[string][]byte

GetPreArchiveFiles will return all single files from the pre-archives as a map with the filename as key, and the actual file contents as value.

func (*Container) GetResourceRequirements

func (co *Container) GetResourceRequirements(req corev1.ResourceRequirements) (corev1.ResourceRequirements, error)

GetResourceRequirements will return a k8s request/limits configuration based on the LabelRequestCPU and LabelRequestMemory labels set on the container.

func (*Container) GetServiceAccountName

func (co *Container) GetServiceAccountName(current string) string

GetServiceAccountName will return the service account to be used for containers that are deployed.

func (*Container) GetServicePorts

func (co *Container) GetServicePorts() map[int]int

GetServicePorts will return a list of ports and their mapping as they should be applied on a k8s service.

func (*Container) GetVolumeFiles

func (co *Container) GetVolumeFiles() map[string]string

GetVolumeFiles will return a map of volumes that are pointing to a single file and should be mounted on the target container. The key is the target location, and the value is the local location.

func (*Container) GetVolumeFolders

func (co *Container) GetVolumeFolders() map[string]string

GetVolumeFolders will return a map of volumes that are pointing to a folder and should be mounted on the target container. The key is the target location, and the value is the local location.

func (*Container) GetVolumes

func (co *Container) GetVolumes() map[string]string

GetVolumes will return a map of volumes that should be mounted on the target container. The key is the target location, and the value is the local location.

func (*Container) HasDockerSockBinding

func (co *Container) HasDockerSockBinding() bool

HasDockerSockBinding will check the bindings specified in the container and will return true if one pf these bindings is the docker socket.

func (*Container) HasVolumes

func (co *Container) HasVolumes() bool

HasVolumes will return true if the container has volumes configured.

func (*Container) MapPort

func (co *Container) MapPort(pod, local int)

MapPort will map a pod port to a local port.

func (*Container) Match

func (co *Container) Match(typ string, key string, val string) bool

Match will match given type with given key value pair.

func (*Container) SignalDetach

func (co *Container) SignalDetach()

SignalDetach will signal all stop channels.

func (*Container) SignalStop

func (co *Container) SignalStop()

SignalStop will signal all stop channels.

func (*Container) StateString

func (co *Container) StateString() string

StateString returns a string that describes the state.

func (*Container) StatusString

func (co *Container) StatusString() string

StatusString returns a string that describes the status.

type Exec

type Exec struct {
	ID          string
	ContainerID string
	Cmd         []string
	TTY         bool
	Stdin       bool
	Stdout      bool
	Stderr      bool
	ExitCode    int
	Created     time.Time
}

Exec describes the details of an execute command.

type Image

type Image struct {
	ID           string
	ShortID      string
	Name         string
	ExposedPorts map[string]struct{}
	Created      time.Time
}

Image describes the details of an image.

type Mount

type Mount struct {
	Type     string
	Source   string
	Target   string
	ReadOnly bool
}

Mount contains the details of a mounted volume/binding.

type Network

type Network struct {
	ID      string
	ShortID string
	Name    string
	Labels  map[string]string
	Created time.Time
}

Network describes the details of a network.

func (*Network) IsPredefined

func (nw *Network) IsPredefined() bool

IsPredefined will return if the network is a pre-defined system network.

func (*Network) Match

func (nw *Network) Match(typ string, key string, val string) bool

Match will match given type with given key value pair.

type PreArchive

type PreArchive struct {
	Path    string
	Archive []byte
}

PreArchive contains the path and contents of archives (tar) that need to be copied over to the container before it has been started.

Jump to

Keyboard shortcuts

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