netboot

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotYetDownloaded = fmt.Errorf("file not yet downloaded")

ErrNotYetDownloaded is returned when an OCI image has not yet been pulled and unpacked to the local cache.

Functions

This section is empty.

Types

type ClusterInfo

type ClusterInfo struct {
	ApiserverURL string
	CACertBase64 string
}

ClusterInfo holds the API server URL and CA certificate discovered from the cluster-info ConfigMap in kube-public. These values may change at runtime (e.g. API server URL rotation), so they are provided through ClusterInfoProvider rather than stored statically.

type ClusterInfoProvider

type ClusterInfoProvider interface {
	ClusterInfo() ClusterInfo
}

ClusterInfoProvider returns the current cluster-info snapshot. Implementations should be safe for concurrent use.

type FileResolver

type FileResolver struct {
	Cache             *OCICache
	Reader            client.Reader
	Cluster           ClusterInfoProvider
	ServeURL          string
	KubernetesVersion string
	ClusterDNS        string
	ProviderLabels    map[string]string
}

func (*FileResolver) LookupNodeByIP

func (f *FileResolver) LookupNodeByIP(ctx context.Context, ip string) (*v1alpha3.Machine, error)

func (*FileResolver) ResolveFileByPath

func (f *FileResolver) ResolveFileByPath(ctx context.Context, path string, node *v1alpha3.Machine, imageRef string) (*ResolvedFile, error)

type HTTPServer

type HTTPServer struct {
	BindAddr string
	Port     int
	Client   client.Client
	Mux      *http.ServeMux
	FileResolver
}

func (*HTTPServer) NeedLeaderElection

func (h *HTTPServer) NeedLeaderElection() bool

func (*HTTPServer) Start

func (h *HTTPServer) Start(ctx context.Context) error

type ImageMetadata

type ImageMetadata struct {
	DHCPBootImageName string `yaml:"dhcpBootImageName"`
}

type OCICache

type OCICache struct {
	CacheDir string
	// contains filtered or unexported fields
}

OCICache manages unpacked OCI images on the local filesystem. Images are stored under {cacheDir}/oci/{digest}/disk/... This follows the kubevirt containerDisk convention where image contents live under /disk/ in the OCI layer.

func NewOCICache

func NewOCICache(cacheDir string) *OCICache

func (*OCICache) DigestFor

func (c *OCICache) DigestFor(imageRef string) string

func (*OCICache) DiskDir

func (c *OCICache) DiskDir(digest string) string

DiskDir returns the /disk/ directory for a cached image.

func (*OCICache) ImageDir

func (c *OCICache) ImageDir(digest string) string

ImageDir returns the base directory for a cached image by digest.

func (*OCICache) InvalidateRef

func (c *OCICache) InvalidateRef(imageRef string)

InvalidateRef removes the digest mapping for an image reference, so it will be re-pulled on next reconcile.

func (*OCICache) IsCached

func (c *OCICache) IsCached(digest string) bool

IsCached returns true if the image digest is already unpacked locally.

func (*OCICache) Metadata

func (c *OCICache) Metadata(digest string) (*ImageMetadata, error)

Metadata returns the parsed metadata.yaml for a cached image, reading it from disk and caching in memory on first access.

func (*OCICache) MetadataForRef

func (c *OCICache) MetadataForRef(imageRef string) (*ImageMetadata, error)

MetadataForRef returns the metadata for an image reference by resolving its digest first.

func (*OCICache) ResolvePath

func (c *OCICache) ResolvePath(imageRef, reqPath string) (diskPath string, isTemplate bool, err error)

ResolvePath looks for a file at the given path under the disk directory for the given image reference. It follows the .tmpl convention: if the path doesn't end in .tmpl, it checks for path.tmpl first (template), then the path itself (static file).

reqPath must be a relative path with no ".." components that escape the cache directory; absolute paths and paths with volume names are rejected.

func (*OCICache) SetDigest

func (c *OCICache) SetDigest(imageRef, digest string)

type OCIReconciler

type OCIReconciler struct {
	Client client.Client
	Cache  *OCICache
}

OCIReconciler watches Machine CRs and pulls their referenced OCI images. Work items are deduplicated by image reference so that multiple machines sharing the same image only trigger a single download.

func (*OCIReconciler) Reconcile

func (r *OCIReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

func (*OCIReconciler) SetupWithManager

func (r *OCIReconciler) SetupWithManager(mgr ctrl.Manager) error

type ResolvedFile

type ResolvedFile struct {
	DiskPath    string // on-disk path for static files
	Data        []byte // rendered content for template files
	ContentType string // MIME type hint for the response
}

ResolvedFile is the result of resolving a file from an OCI image. For static files on disk, DiskPath is set so callers can stream from disk. For template files, Data holds the rendered content.

type StaticClusterInfo

type StaticClusterInfo struct {
	Info ClusterInfo
}

StaticClusterInfo is a ClusterInfoProvider that returns a fixed configuration. Useful for tests and simple deployments where runtime refresh is not needed.

func (*StaticClusterInfo) ClusterInfo

func (s *StaticClusterInfo) ClusterInfo() ClusterInfo

type TFTPServer

type TFTPServer struct {
	BindAddr string
	FileResolver
}

func (*TFTPServer) NeedLeaderElection

func (t *TFTPServer) NeedLeaderElection() bool

func (*TFTPServer) Start

func (t *TFTPServer) Start(ctx context.Context) error

Jump to

Keyboard shortcuts

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