createconfig

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// TypeBind is the type for mounting host dir
	TypeBind mountType = "bind"
	// TypeVolume is the type for remote storage volumes
	// TypeVolume mountType = "volume"  // re-enable upon use
	// TypeTmpfs is the type for mounting tmpfs
	TypeTmpfs mountType = "tmpfs"
)

Type constants

View Source
const Pod = "pod"

Pod signifies a kernel namespace is being shared by a container with the pod it is associated with

Variables

This section is empty.

Functions

func CreateConfigToOCISpec

func CreateConfigToOCISpec(config *CreateConfig) (*spec.Spec, error)

CreateConfigToOCISpec parses information needed to create a container into an OCI runtime spec

func CreatePortBinding

func CreatePortBinding(hostPort int, hostIP string) []nat.PortBinding

CreatePortBinding takes port (int) and IP (string) and creates an array of portbinding structs

func Device

func Device(d *configs.Device) spec.LinuxDevice

Device transforms a libcontainer configs.Device to a specs.LinuxDevice object.

func ExposedPorts

func ExposedPorts(expose, publish []string, publishAll bool, imageExposedPorts map[string]struct{}) (map[nat.Port][]nat.PortBinding, error)

ExposedPorts parses user and image ports and returns binding information

func IsNS added in v0.7.4

func IsNS(s string) bool

IsNS returns if the specified string has a ns: prefix

func IsPod added in v0.8.4

func IsPod(s string) bool

IsPod returns if the specified string is pod

func IsValidDeviceMode added in v0.11.1

func IsValidDeviceMode(mode string) bool

IsValidDeviceMode checks if the mode for device is valid or not. IsValid mode is a composition of r (read), w (write), and m (mknod).

func NS added in v0.7.4

func NS(s string) string

NS is the path to the namespace to join.

func NatToOCIPortBindings added in v0.12.1

func NatToOCIPortBindings(ports nat.PortMap) ([]ocicni.PortMapping, error)

NatToOCIPortBindings iterates a nat.portmap slice and creates []ocicni portmapping slice

func ParseDevice added in v0.11.1

func ParseDevice(device string) (string, string, string, error)

ParseDevice parses device mapping string to a src, dest & permissions string

func Valid added in v0.8.4

func Valid(s string, ns LinuxNS) bool

Valid checks the validity of a linux namespace s should be the string representation of ns

Types

type CreateConfig

type CreateConfig struct {
	Runtime            *libpod.Runtime
	Annotations        map[string]string
	Args               []string
	CapAdd             []string // cap-add
	CapDrop            []string // cap-drop
	CidFile            string
	ConmonPidFile      string
	CgroupParent       string // cgroup-parent
	Command            []string
	Detach             bool              // detach
	Devices            []string          // device
	DNSOpt             []string          //dns-opt
	DNSSearch          []string          //dns-search
	DNSServers         []string          //dns
	Entrypoint         []string          //entrypoint
	Env                map[string]string //env
	ExposedPorts       map[nat.Port]struct{}
	GroupAdd           []string // group-add
	HostAdd            []string //add-host
	Hostname           string   //hostname
	Image              string
	ImageID            string
	BuiltinImgVolumes  map[string]struct{} // volumes defined in the image config
	IDMappings         *storage.IDMappingOptions
	ImageVolumeType    string                 // how to handle the image volume, either bind, tmpfs, or ignore
	Interactive        bool                   //interactive
	IpcMode            namespaces.IpcMode     //ipc
	IP6Address         string                 //ipv6
	IPAddress          string                 //ip
	Labels             map[string]string      //label
	LinkLocalIP        []string               // link-local-ip
	LogDriver          string                 // log-driver
	LogDriverOpt       []string               // log-opt
	MacAddress         string                 //mac-address
	Name               string                 //name
	NetMode            namespaces.NetworkMode //net
	Network            string                 //network
	NetworkAlias       []string               //network-alias
	PidMode            namespaces.PidMode     //pid
	Pod                string                 //pod
	PortBindings       nat.PortMap
	Privileged         bool     //privileged
	Publish            []string //publish
	PublishAll         bool     //publish-all
	Quiet              bool     //quiet
	ReadOnlyRootfs     bool     //read-only
	Resources          CreateResourceConfig
	Rm                 bool              //rm
	StopSignal         syscall.Signal    // stop-signal
	StopTimeout        uint              // stop-timeout
	Sysctl             map[string]string //sysctl
	Systemd            bool
	Tmpfs              []string              // tmpfs
	Tty                bool                  //tty
	UsernsMode         namespaces.UsernsMode //userns
	User               string                //user
	UtsMode            namespaces.UTSMode    //uts
	Mounts             []spec.Mount          //mounts
	Volumes            []string              //volume
	VolumesFrom        []string
	WorkDir            string   //workdir
	LabelOpts          []string //SecurityOpts
	NoNewPrivs         bool     //SecurityOpts
	ApparmorProfile    string   //SecurityOpts
	SeccompProfilePath string   //SecurityOpts
	SecurityOpts       []string
	Rootfs             string
	LocalVolumes       []spec.Mount //Keeps track of the built-in volumes of container used in the --volumes-from flag
	Syslog             bool         // Whether to enable syslog on exit commands
}

CreateConfig is a pre OCI spec structure. It represents user input from varlink or the CLI

func (*CreateConfig) AddContainerInitBinary added in v1.0.0

func (c *CreateConfig) AddContainerInitBinary(path string) error

AddContainerInitBinary adds the init binary specified by path iff the container will run in a private PID namespace that is not shared with the host or another pre-existing container, where an init-like process is already running.

Note that AddContainerInitBinary prepends "/dev/init" "--" to the command to execute the bind-mounted binary as PID 1.

func (*CreateConfig) AddPrivilegedDevices

func (c *CreateConfig) AddPrivilegedDevices(g *generate.Generator) error

AddPrivilegedDevices iterates through host devices and adds all host devices to the spec

func (*CreateConfig) CreateBlockIO

func (c *CreateConfig) CreateBlockIO() (*spec.LinuxBlockIO, error)

CreateBlockIO returns a LinuxBlockIO struct from a CreateConfig

func (*CreateConfig) CreatePortBindings

func (c *CreateConfig) CreatePortBindings() ([]ocicni.PortMapping, error)

CreatePortBindings iterates ports mappings and exposed ports into a format CNI understands

func (*CreateConfig) GetContainerCreateOptions

func (c *CreateConfig) GetContainerCreateOptions(runtime *libpod.Runtime, pod *libpod.Pod) ([]libpod.CtrCreateOption, error)

GetContainerCreateOptions takes a CreateConfig and returns a slice of CtrCreateOptions

func (*CreateConfig) GetTmpfsMounts

func (c *CreateConfig) GetTmpfsMounts() []spec.Mount

GetTmpfsMounts takes user provided input for Tmpfs mounts and creates Mount structs

func (*CreateConfig) GetVolumeMounts

func (c *CreateConfig) GetVolumeMounts(specMounts []spec.Mount) ([]spec.Mount, error)

GetVolumeMounts takes user provided input for bind mounts and creates Mount structs

func (*CreateConfig) GetVolumesFrom added in v0.7.2

func (c *CreateConfig) GetVolumesFrom() error

GetVolumesFrom reads the create-config artifact of the container to get volumes from and adds it to c.Volumes of the current container.

type CreateResourceConfig

type CreateResourceConfig struct {
	BlkioWeight       uint16   // blkio-weight
	BlkioWeightDevice []string // blkio-weight-device
	CPUPeriod         uint64   // cpu-period
	CPUQuota          int64    // cpu-quota
	CPURtPeriod       uint64   // cpu-rt-period
	CPURtRuntime      int64    // cpu-rt-runtime
	CPUShares         uint64   // cpu-shares
	CPUs              float64  // cpus
	CPUsetCPUs        string
	CPUsetMems        string   // cpuset-mems
	DeviceReadBps     []string // device-read-bps
	DeviceReadIOps    []string // device-read-iops
	DeviceWriteBps    []string // device-write-bps
	DeviceWriteIOps   []string // device-write-iops
	DisableOomKiller  bool     // oom-kill-disable
	KernelMemory      int64    // kernel-memory
	Memory            int64    //memory
	MemoryReservation int64    // memory-reservation
	MemorySwap        int64    //memory-swap
	MemorySwappiness  int      // memory-swappiness
	OomScoreAdj       int      //oom-score-adj
	PidsLimit         int64    // pids-limit
	ShmSize           int64
	Ulimit            []string //ulimit
}

CreateResourceConfig represents resource elements in CreateConfig structures

type LinuxNS added in v0.8.4

type LinuxNS interface {
	Valid() bool
}

LinuxNS is a struct that contains namespace information It implemented Valid to show it is a valid namespace

Jump to

Keyboard shortcuts

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