Documentation ¶
Index ¶
- func NewHostUtil(ne *NsEnter) hostutil.HostUtils
- type Mounter
- func (n *Mounter) GetMountRefs(pathname string) ([]string, error)
- func (n *Mounter) IsLikelyNotMountPoint(file string) (bool, error)
- func (*Mounter) IsMountPointMatch(mp mount.MountPoint, dir string) bool
- func (*Mounter) List() ([]mount.MountPoint, error)
- func (n *Mounter) Mount(source string, target string, fstype string, options []string) error
- func (n *Mounter) Unmount(target string) error
- type NsEnter
- func (ne *NsEnter) AbsHostPath(command string) string
- func (ne *NsEnter) Command(cmd string, args ...string) exec.Cmd
- func (ne *NsEnter) CommandContext(ctx context.Context, cmd string, args ...string) exec.Cmd
- func (ne *NsEnter) ContainerPath(pathname string) string
- func (ne *NsEnter) EvalSymlinks(pathname string, mustExist bool) (string, error)
- func (ne *NsEnter) Exec(cmd string, args []string) exec.Cmd
- func (ne *NsEnter) LookPath(file string) (string, error)
- func (ne *NsEnter) SupportsSystemd() (string, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHostUtil ¶
NewHostUtil returns a new mount.HostUtils implementation that works for kubelet running in a container
Types ¶
type Mounter ¶
type Mounter struct {
// contains filtered or unexported fields
}
Mounter implements mount.Interface Currently, all docker containers receive their own mount namespaces. Mounter works by executing nsenter to run commands in the host's mount namespace.
func NewMounter ¶
NewMounter creates a new nsenter mounter that operates in the host namespace
func (*Mounter) GetMountRefs ¶
GetMountRefs finds all mount references to the path, returns a list of paths. Path could be a mountpoint path, device or a normal directory (for bind mount).
func (*Mounter) IsLikelyNotMountPoint ¶
IsLikelyNotMountPoint determines whether a path is a mountpoint by calling findmnt in the host's root mount namespace.
func (*Mounter) IsMountPointMatch ¶
func (*Mounter) IsMountPointMatch(mp mount.MountPoint, dir string) bool
IsMountPointMatch tests if dir and mp are the same path
func (*Mounter) List ¶
func (*Mounter) List() ([]mount.MountPoint, error)
List returns a list of all mounted filesystems in the host's mount namespace.
type NsEnter ¶
type NsEnter struct {
// contains filtered or unexported fields
}
func NewNsEnter ¶
func (*NsEnter) AbsHostPath ¶
AbsHostPath returns the absolute runnable path for a specified command
func (*NsEnter) CommandContext ¶
CommandContext returns a CommandContext wrapped with nsenter
func (*NsEnter) ContainerPath ¶
ContainerPath TODO: remove this once the direct syscalls of stat are replaced with invocations of the namespaced stat command
func (*NsEnter) EvalSymlinks ¶
EvalSymlinks returns the path name on the host after evaluating symlinks on the host. mustExist makes EvalSymlinks to return error when the path does not exist. When it's false, it evaluates symlinks of the existing part and blindly adds the non-existing part: pathname: /mnt/volume/non/existing/directory
/mnt/volume exists non/existing/directory does not exist
-> It resolves symlinks in /mnt/volume to say /mnt/foo and returns
/mnt/foo/non/existing/directory.
BEWARE! EvalSymlinks is not able to detect symlink looks with mustExist=false! If /tmp/link is symlink to /tmp/link, EvalSymlinks(/tmp/link/foo) returns /tmp/link/foo.
func (*NsEnter) SupportsSystemd ¶
SupportsSystemd checks whether command systemd-run exists