netboot

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 44 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

func HTTPBootPathFromMetadata added in v0.1.20

func HTTPBootPathFromMetadata(meta *ImageMetadata) string

func JoinServeURLPath added in v0.1.20

func JoinServeURLPath(serveURL, path string) (string, error)

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
	DefaultNetbootRef string
	KubernetesVersion string
	ClusterDNS        string
	ProviderLabels    map[string]string
}

func (*FileResolver) HTTPBootPath added in v0.1.20

func (f *FileResolver) HTTPBootPath(node *v1alpha3.Machine) (string, error)

func (*FileResolver) HTTPBootURL added in v0.1.20

func (f *FileResolver) HTTPBootURL(node *v1alpha3.Machine) (string, error)

func (*FileResolver) LookupNodeByIP

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

func (*FileResolver) NetbootImageRef added in v0.1.20

func (f *FileResolver) NetbootImageRef(node *v1alpha3.Machine) string

func (*FileResolver) ResolveFileByPath

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

func (*FileResolver) ResolveFileByPathForIP added in v0.1.21

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

type HTTPServer

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

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"`
	HTTPBootPath      string `yaml:"httpBootPath"`
}

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}/{architecture}/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) DigestForArchitecture added in v0.1.20

func (c *OCICache) DigestForArchitecture(imageRef, architecture string) string

func (*OCICache) DiskDir

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

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

func (*OCICache) DiskDirForArchitecture added in v0.1.20

func (c *OCICache) DiskDirForArchitecture(digest, architecture string) string

DiskDirForArchitecture 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) ImageDirForArchitecture added in v0.1.20

func (c *OCICache) ImageDirForArchitecture(digest, architecture string) string

ImageDirForArchitecture returns the base directory for a cached image by digest and target architecture.

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) InvalidateRefForArchitecture added in v0.1.20

func (c *OCICache) InvalidateRefForArchitecture(imageRef, architecture string)

InvalidateRefForArchitecture removes the digest mapping for an image reference and target architecture, 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) IsCachedForArchitecture added in v0.1.20

func (c *OCICache) IsCachedForArchitecture(digest, architecture string) bool

IsCachedForArchitecture 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) MetadataForArchitecture added in v0.1.20

func (c *OCICache) MetadataForArchitecture(digest, architecture string) (*ImageMetadata, error)

MetadataForArchitecture returns the parsed metadata.yaml for a cached image.

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) MetadataForRefArchitecture added in v0.1.20

func (c *OCICache) MetadataForRefArchitecture(imageRef, architecture string) (*ImageMetadata, error)

MetadataForRefArchitecture returns the metadata for an image reference and target architecture 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) ResolvePathForArchitecture added in v0.1.20

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

ResolvePathForArchitecture looks for a file at the given path under the disk directory for the given image reference and target architecture.

func (*OCICache) SetDigest

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

func (*OCICache) SetDigestForArchitecture added in v0.1.20

func (c *OCICache) SetDigestForArchitecture(imageRef, architecture, digest string)

type OCIReconciler

type OCIReconciler struct {
	Client                      client.Client
	Cache                       *OCICache
	DefaultNetbootRef           string
	DefaultNetbootPullSecretRef *v1alpha3.NamespacedSecretReference
}

OCIReconciler watches Machine CRs and pulls their referenced OCI images. Work items are deduplicated by image reference, architecture, and pull secret so machines sharing the same pull identity only trigger one 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 StatusRecorder added in v0.1.20

type StatusRecorder interface {
	RecordBootLoaderDownloaded(ctx context.Context, machineName, filename string) error
	RecordBootImageWritten(ctx context.Context, machineName string) error
	RecordCloudInitDone(ctx context.Context, machineName string) error
	RecordOperationCondition(ctx context.Context, machineName string, condition metav1.Condition) error
	RecordPXEDisabled(ctx context.Context, machineName, imageName string) error
}

type TFTPServer

type TFTPServer struct {
	BindAddr string
	FileResolver
	StatusRecorder TFTPStatusRecorder
}

func (*TFTPServer) NeedLeaderElection

func (t *TFTPServer) NeedLeaderElection() bool

func (*TFTPServer) Start

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

type TFTPStatusRecorder added in v0.1.20

type TFTPStatusRecorder interface {
	RecordBootLoaderDownloaded(ctx context.Context, machineName, filename string) error
}

Jump to

Keyboard shortcuts

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