Help us shape the future of Go! Take the 2026 Go Developer Survey

k3dkmsg

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package k3dkmsg lets `k3d cluster create` work on a Linux host that has no /dev/kmsg, as a kata or gVisor sandbox does.

k3s's kubelet opens /dev/kmsg for its OOM watcher and exits fatally when it cannot ("open /dev/kmsg: no such file or directory"). k3s then shuts down about two seconds after it started, the k3d entrypoint keeps the container "running", `--wait` hangs for its whole timeout, and :6443 refuses connections — which reads as a networking failure and is not one.

Docker's --privileged copies the HOST's /dev nodes into a container, so a host without /dev/kmsg gives the node none either. The fix is a character device (1:11) made by mknod under forge's cache directory and bind-mounted over /dev/kmsg in every server and agent node. A host that has /dev/kmsg is left exactly as it is.

Index

Constants

View Source
const HostPath = "/dev/kmsg"

HostPath is the device k3s's kubelet needs.

Variables

This section is empty.

Functions

func AddArgs

func AddArgs(args []string) ([]string, error)

AddArgs adds the kmsg mount to a `k3d cluster create` argv, creating the device file first when it is needed. It returns args unchanged on a host whose /dev/kmsg exists, and on one where the question does not arise.

Types

type Host

type Host struct {
	GOOS       string
	Euid       int
	DockerHost string
	// Dir is the forge-owned directory the device file is made in.
	Dir    string
	Stat   func(path string) (State, error)
	Run    func(name string, args ...string) error
	Remove func(path string) error
	Mkdir  func(path string) error
}

Host is everything AddArgs reads from or does to the machine, so a test supplies all of it.

func OSHost

func OSHost() (Host, error)

OSHost is the real machine.

func (Host) AddArgs

func (h Host) AddArgs(args []string) ([]string, error)

AddArgs is the package-level AddArgs for an explicit Host.

type State

type State int

State is what a path is, as far as kmsg is concerned.

const (
	// StateMissing means the device path does not exist.
	StateMissing State = iota
	// StateKmsg is a character device with the kernel's kmsg numbers (1:11).
	StateKmsg
	// StateOther is anything else: a regular file, or a different device.
	StateOther
)

Jump to

Keyboard shortcuts

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