Documentation ¶
Overview ¶
Package rkt contains the Containerruntime interface implementation for rkt.
Index ¶
- Constants
- type Config
- type ImageManager
- type Runtime
- func (r *Runtime) AttachContainer(containerID kubecontainer.ContainerID, stdin io.Reader, ...) error
- func (r *Runtime) ConvertRawToPodStatus(_ *api.Pod, _ *kubecontainer.RawPodStatus) (*api.PodStatus, error)
- func (r *Runtime) ExecInContainer(containerID kubecontainer.ContainerID, cmd []string, stdin io.Reader, ...) error
- func (r *Runtime) GarbageCollect(gcPolicy kubecontainer.ContainerGCPolicy) error
- func (r *Runtime) GetContainerLogs(pod *api.Pod, containerID kubecontainer.ContainerID, ...) error
- func (r *Runtime) GetPodStatus(pod *api.Pod) (*api.PodStatus, error)
- func (r *Runtime) GetPods(all bool) ([]*kubecontainer.Pod, error)
- func (r *Runtime) GetRawPodStatus(uid types.UID, name, namespace string) (*kubecontainer.RawPodStatus, error)
- func (r *Runtime) IsImagePresent(image kubecontainer.ImageSpec) (bool, error)
- func (r *Runtime) KillPod(pod *api.Pod, runningPod kubecontainer.Pod) error
- func (r *Runtime) ListImages() ([]kubecontainer.Image, error)
- func (r *Runtime) PortForward(pod *kubecontainer.Pod, port uint16, stream io.ReadWriteCloser) error
- func (r *Runtime) PullImage(image kubecontainer.ImageSpec, pullSecrets []api.Secret) error
- func (r *Runtime) RemoveImage(image kubecontainer.ImageSpec) error
- func (r *Runtime) RunInContainer(containerID kubecontainer.ContainerID, cmd []string) ([]byte, error)
- func (r *Runtime) RunPod(pod *api.Pod, pullSecrets []api.Secret) error
- func (r *Runtime) SyncPod(pod *api.Pod, runningPod kubecontainer.Pod, podStatus api.PodStatus, ...) error
- func (r *Runtime) Type() string
- func (r *Runtime) Version() (kubecontainer.Version, error)
Constants ¶
const ( CAP_CHOWN = iota CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH CAP_FOWNER CAP_FSETID CAP_KILL CAP_SETGID CAP_SETUID CAP_SETPCAP CAP_LINUX_IMMUTABLE CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_ADMIN CAP_NET_RAW CAP_IPC_LOCK CAP_IPC_OWNER CAP_SYS_MODULE CAP_SYS_RAWIO CAP_SYS_CHROOT CAP_SYS_PTRACE CAP_SYS_PACCT CAP_SYS_ADMIN CAP_SYS_BOOT CAP_SYS_NICE CAP_SYS_RESOURCE CAP_SYS_TIME CAP_SYS_TTY_CONFIG CAP_MKNOD CAP_LEASE CAP_AUDIT_WRITE CAP_AUDIT_CONTROL CAP_SETFCAP CAP_MAC_OVERRIDE CAP_MAC_ADMIN CAP_SYSLOG CAP_WAKE_ALARM CAP_BLOCK_SUSPEND CAP_AUDIT_READ )
TODO(yifan): Export this to higher level package.
const ( Embryo = "embryo" Preparing = "preparing" AbortedPrepare = "aborted prepare" Prepared = "prepared" Running = "running" Deleting = "deleting" // This covers pod.isExitedDeleting and pod.isDeleting. Exited = "exited" // This covers pod.isExited and pod.isExitedGarbage. Garbage = "garbage" )
rkt pod state. TODO(yifan): Use exported definition in rkt.
const (
RktType = "rkt"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // The absolute path to the binary, or leave empty to find it in $PATH. Path string // The image to use as stage1. Stage1Image string // The debug flag for rkt. Debug bool // The rkt data directory. Dir string // This flag controls whether we skip image or key verification. InsecureSkipVerify bool // The local config directory. LocalConfigDir string }
Config stores the global configuration for the rkt runtime. Run 'rkt' for more details.
type ImageManager ¶
type ImageManager struct {
// contains filtered or unexported fields
}
ImageManager manages and garbage collects the container images for rkt.
func NewImageManager ¶
func NewImageManager(r *Runtime) *ImageManager
func (*ImageManager) GarbageCollect ¶
func (im *ImageManager) GarbageCollect() error
GarbageCollect collects the images. TODO(yifan): Enforce ImageGCPolicy.
func (*ImageManager) Start ¶
func (im *ImageManager) Start() error
Start is a no-op for rkt as we don't need to mark unused images in kubelet.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime implements the Containerruntime for rkt. The implementation uses systemd, so in order to run this runtime, systemd must be installed on the machine.
func New ¶
func New(config *Config, generator kubecontainer.RunContainerOptionsGenerator, recorder record.EventRecorder, containerRefManager *kubecontainer.RefManager, livenessManager proberesults.Manager, volumeGetter volumeGetter, imageBackOff *util.Backoff, serializeImagePulls bool, ) (*Runtime, error)
New creates the rkt container runtime which implements the container runtime interface. It will test if the rkt binary is in the $PATH, and whether we can get the version of it. If so, creates the rkt container runtime, otherwise returns an error.
func (*Runtime) AttachContainer ¶
func (r *Runtime) AttachContainer(containerID kubecontainer.ContainerID, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool) error
func (*Runtime) ConvertRawToPodStatus ¶
func (r *Runtime) ConvertRawToPodStatus(_ *api.Pod, _ *kubecontainer.RawPodStatus) (*api.PodStatus, error)
func (*Runtime) ExecInContainer ¶
func (r *Runtime) ExecInContainer(containerID kubecontainer.ContainerID, cmd []string, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool) error
Note: In rkt, the container ID is in the form of "UUID:appName", where UUID is the rkt UUID, and appName is the container name. TODO(yifan): If the rkt is using lkvm as the stage1 image, then this function will fail.
func (*Runtime) GarbageCollect ¶
func (r *Runtime) GarbageCollect(gcPolicy kubecontainer.ContainerGCPolicy) error
GarbageCollect collects the pods/containers. TODO(yifan): Enforce the gc policy, also, it would be better if we can just GC kubernetes pods.
func (*Runtime) GetContainerLogs ¶
func (r *Runtime) GetContainerLogs(pod *api.Pod, containerID kubecontainer.ContainerID, logOptions *api.PodLogOptions, stdout, stderr io.Writer) error
GetContainerLogs uses journalctl to get the logs of the container. By default, it returns a snapshot of the container log. Set |follow| to true to stream the log. Set |follow| to false and specify the number of lines (e.g. "100" or "all") to tail the log.
In rkt runtime's implementation, per container log is get via 'journalctl -m _HOSTNAME=[rkt-$UUID] -u [APP_NAME]'. See https://github.com/coreos/rkt/blob/master/Documentation/commands.md#logging for more details.
TODO(yifan): If the rkt is using lkvm as the stage1 image, then this function will fail.
func (*Runtime) GetPodStatus ¶
GetPodStatus returns the status of the given pod.
func (*Runtime) GetPods ¶
func (r *Runtime) GetPods(all bool) ([]*kubecontainer.Pod, error)
GetPods runs 'systemctl list-unit' and 'rkt list' to get the list of rkt pods. Then it will use the result to construct a list of container runtime pods. If all is false, then only running pods will be returned, otherwise all pods will be returned.
func (*Runtime) GetRawPodStatus ¶
func (r *Runtime) GetRawPodStatus(uid types.UID, name, namespace string) (*kubecontainer.RawPodStatus, error)
func (*Runtime) IsImagePresent ¶
func (r *Runtime) IsImagePresent(image kubecontainer.ImageSpec) (bool, error)
TODO(yifan): Searching the image via 'rkt images' might not be the most efficient way.
func (*Runtime) KillPod ¶
KillPod invokes 'systemctl kill' to kill the unit that runs the pod. TODO(yifan): Handle network plugin.
func (*Runtime) ListImages ¶
func (r *Runtime) ListImages() ([]kubecontainer.Image, error)
ListImages lists all the available appc images on the machine by invoking 'rkt image list'.
func (*Runtime) PortForward ¶
func (r *Runtime) PortForward(pod *kubecontainer.Pod, port uint16, stream io.ReadWriteCloser) error
PortForward executes socat in the pod's network namespace and copies data between stream (representing the user's local connection on their computer) and the specified port in the container.
TODO:
- match cgroups of container
- should we support nsenter + socat on the host? (current impl)
- should we support nsenter + socat in a container, running with elevated privs and --pid=host?
TODO(yifan): Merge with the same function in dockertools. TODO(yifan): If the rkt is using lkvm as the stage1 image, then this function will fail.
func (*Runtime) PullImage ¶
PullImage invokes 'rkt fetch' to download an aci. TODO(yifan): Now we only support docker images, this should be changed once the format of image is landed, see:
func (*Runtime) RemoveImage ¶
func (r *Runtime) RemoveImage(image kubecontainer.ImageSpec) error
RemoveImage removes an on-disk image using 'rkt image rm'. TODO(yifan): Use image ID to reference image.
func (*Runtime) RunInContainer ¶
func (r *Runtime) RunInContainer(containerID kubecontainer.ContainerID, cmd []string) ([]byte, error)
Note: In rkt, the container ID is in the form of "UUID:appName", where appName is the container name. TODO(yifan): If the rkt is using lkvm as the stage1 image, then this function will fail.
func (*Runtime) RunPod ¶
RunPod first creates the unit file for a pod, and then starts the unit over d-bus.