container

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: Apache-2.0 Imports: 48 Imported by: 2

Documentation

Index

Constants

View Source
const (
	KubernetesName           = "kubernetes"
	KubernetesConfigFileName = ".melange.k8s.yaml"
)
View Source
const BubblewrapName = "bubblewrap"
View Source
const DockerName = "docker"
View Source
const (
	LimaName = "lima"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BindMount

type BindMount struct {
	Source      string
	Destination string
}

type Capabilities

type Capabilities struct {
	Networking bool
}

type Config

type Config struct {
	PackageName  string
	Mounts       []BindMount
	Capabilities Capabilities
	Logger       log.Logger
	Environment  map[string]string
	ImgRef       string
	PodID        string
	Arch         apko_types.Architecture
}

type KubernetesRunnerConfig added in v0.4.0

type KubernetesRunnerConfig struct {
	Provider    string            `json:"provider" yaml:"provider"`
	Repo        string            `json:"repo" yaml:"repo"`
	Namespace   string            `json:"namespace" yaml:"namespace"`
	Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
	Labels      map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`

	StartTimeout time.Duration `json:"startTimeout" yaml:"startTimeout"`
	BuildTimeout time.Duration `json:"buildTimeout" yaml:"buildTimeout"`

	PodTemplate *KubernetesRunnerConfigPodTemplate `json:"podTemplate,omitempty" yaml:"podTemplate,omitempty" ignored:"true"`

	// A "burstable" QOS is really the only thing that makes sense for ephemeral builder pods
	// Only set the requests, and not the limits
	Resources corev1.ResourceList
	// contains filtered or unexported fields
}

KubernetesRunnerConfig handles the configuration for the Kubernetes runner It sources from various locations, in the following order of precedence:

  1. The "global" config file
  2. Defaults

TODO: Add loaders from package config and environment

func NewKubernetesConfig added in v0.4.0

func NewKubernetesConfig(opt ...KubernetesRunnerConfigOptions) *KubernetesRunnerConfig

NewKubernetesConfig returns a default Kubernetes runner config setup

type KubernetesRunnerConfigOptions added in v0.4.0

type KubernetesRunnerConfigOptions func(*KubernetesRunnerConfig)

func WithKubernetesRunnerConfigBaseConfigFile added in v0.4.0

func WithKubernetesRunnerConfigBaseConfigFile(path string) KubernetesRunnerConfigOptions

type KubernetesRunnerConfigPodTemplate added in v0.4.0

type KubernetesRunnerConfigPodTemplate struct {
	ServiceAccountName string               `json:"serviceAccountName,omitempty" yaml:"serviceAccountName,omitempty"`
	NodeSelector       map[string]string    `json:"nodeSelector,omitempty" yaml:"nodeSelector,omitempty"`
	Env                []corev1.EnvVar      `json:"env,omitempty" yaml:"env,omitempty"`
	Affinity           *corev1.Affinity     `json:"affinity,omitempty" yaml:"affinity,omitempty"`
	RuntimeClassName   *string              `json:"runtimeClassName,omitempty" yaml:"runtimeClassName,omitempty"`
	Volumes            []corev1.Volume      `json:"volumes,omitempty" yaml:"volumes,omitempty"`
	VolumeMounts       []corev1.VolumeMount `json:"volumeMounts,omitempty" yaml:"volumeMounts,omitempty"`
}

type Loader added in v0.4.0

type Loader interface {
	LoadImage(ctx context.Context, layer v1.Layer, arch apko_types.Architecture, bc *apko_build.Context) (ref string, err error)
}

type Runner

type Runner interface {
	Name() string
	TestUsability(ctx context.Context) bool
	// OCIImageLoader returns a Loader that will load an OCI image from a stream.
	// It should return the Loader, which will be used to load the provided image
	// as a tar stream into the Loader. That image will be used as the root when StartPod() the container.
	OCIImageLoader() Loader
	StartPod(ctx context.Context, cfg *Config) error
	Run(ctx context.Context, cfg *Config, cmd ...string) error
	TerminatePod(ctx context.Context, cfg *Config) error
	// TempDir returns the base for temporary directory, or "" if whatever is provided by the system is fine
	TempDir() string
	// WorkspaceTar returns an io.ReadCloser that can be used to read the status of the workspace.
	// The io.ReadCloser itself is a tar stream, which can be written to an io.Writer as is,
	// or passed to an fs.FS processor
	WorkspaceTar(ctx context.Context, cfg *Config) (io.ReadCloser, error)
}

func BubblewrapRunner

func BubblewrapRunner(logger log.Logger) Runner

BubblewrapRunner returns a Bubblewrap Runner implementation.

func DockerRunner

func DockerRunner(logger log.Logger) Runner

DockerRunner returns a Docker Runner implementation.

func GetRunner

func GetRunner(ctx context.Context, s string, log log.Logger) (Runner, error)

GetRunner returns the requested runner implementation.

func KubernetesRunner added in v0.4.0

func KubernetesRunner(_ context.Context, logger log.Logger) (Runner, error)

func LimaRunner added in v0.4.0

func LimaRunner(ctx context.Context, logger log.Logger) (Runner, error)

LimaRunner returns a lima with nerdctl Runner implementation. It uses the limactl CLI to manage the VM, and lima CLI to execute commands inside the VM. This could be replaced at some point by a lima library, when such a thing exists. For now, most commands that we use - limactl start, limactl stop, limactl delete, limactl list, lima nerctl run - are implemented as logic in github.com/lima-vm/lima/cmd rather than as a library surface.

Jump to

Keyboard shortcuts

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