runtime

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Overview

Package runtime provides the ability for Vela to integrate with different supported Runtime environments.

Currently the following runtimes are supported:

* Docker - https://docker.io/ * Kubernetes - https://kubernetes.io/

Usage:

import "github.com/go-vela/worker/runtime"

Index

Constants

This section is empty.

Variables

View Source
var Flags = []cli.Flag{

	&cli.StringFlag{
		EnvVars:  []string{"VELA_RUNTIME_DRIVER", "RUNTIME_DRIVER"},
		FilePath: "/vela/runtime/driver",
		Name:     "runtime.driver",
		Usage:    "driver to be used for the runtime",
		Value:    constants.DriverDocker,
	},
	&cli.StringFlag{
		EnvVars:  []string{"VELA_RUNTIME_CONFIG", "RUNTIME_CONFIG"},
		FilePath: "/vela/runtime/config",
		Name:     "runtime.config",
		Usage:    "path to configuration file for the runtime",
	},
	&cli.StringFlag{
		EnvVars:  []string{"VELA_RUNTIME_NAMESPACE", "RUNTIME_NAMESPACE"},
		FilePath: "/vela/runtime/namespace",
		Name:     "runtime.namespace",
		Usage:    "namespace to use for the runtime (only used by kubernetes)",
	},
	&cli.StringFlag{
		EnvVars:  []string{"VELA_RUNTIME_PODS_TEMPLATE_NAME", "RUNTIME_PODS_TEMPLATE_NAME"},
		FilePath: "/vela/runtime/pods_template_name",
		Name:     "runtime.pods-template-name",
		Usage:    "name of the PipelinePodsTemplate to retrieve from the runtime.namespace (only used by kubernetes)",
	},
	&cli.PathFlag{
		EnvVars:  []string{"VELA_RUNTIME_PODS_TEMPLATE_FILE", "RUNTIME_PODS_TEMPLATE_FILE"},
		FilePath: "/vela/runtime/pods_template_file",
		Name:     "runtime.pods-template-file",
		Usage:    "path to local fallback file containing a PipelinePodsTemplate in YAML (only used by kubernetes; only used if runtime.pods-template-name is not defined)",
	},
	&cli.StringSliceFlag{
		EnvVars:  []string{"VELA_RUNTIME_PRIVILEGED_IMAGES", "RUNTIME_PRIVILEGED_IMAGES"},
		FilePath: "/vela/runtime/privileged_images",
		Name:     "runtime.privileged-images",
		Usage:    "list of images allowed to run in privileged mode for the runtime",
	},
	&cli.StringSliceFlag{
		EnvVars:  []string{"VELA_RUNTIME_VOLUMES", "RUNTIME_VOLUMES"},
		FilePath: "/vela/runtime/volumes",
		Name:     "runtime.volumes",
		Usage:    "list of host volumes to mount for the runtime",
	},
	&cli.StringSliceFlag{
		EnvVars:  []string{"VELA_RUNTIME_DROP_CAPABILITIES", "RUNTIME_DROP_CAPABILITIES"},
		FilePath: "/vela/runtime/drop_capabilities",
		Name:     "runtime.drop-capabilities",
		Usage:    "list of kernel capabilities to drop from container privileges (only used by Docker)",
	},
}

Flags represents all supported command line interface (CLI) flags for the runtime.

https://pkg.go.dev/github.com/urfave/cli?tab=doc#Flag

Functions

func WithContext added in v0.11.0

func WithContext(c context.Context, e Engine) context.Context

WithContext inserts the runtime Engine into the context.Context.

func WithGinContext added in v0.11.0

func WithGinContext(c *gin.Context, e Engine)

WithGinContext inserts the runtime Engine into the gin.Context.

Types

type Engine

type Engine interface {

	// Driver defines a function that outputs
	// the configured runtime driver.
	Driver() string

	// InspectBuild defines a function that
	// displays details about the build for the init step.
	InspectBuild(ctx context.Context, b *pipeline.Build) ([]byte, error)
	// SetupBuild defines a function that
	// prepares the pipeline build.
	SetupBuild(context.Context, *pipeline.Build) error
	// StreamBuild defines a function that initializes
	// log/event streaming if the runtime needs it.
	// StreamBuild and AssembleBuild run concurrently.
	StreamBuild(context.Context, *pipeline.Build) error
	// AssembleBuild defines a function that
	// finalizes pipeline build setup.
	AssembleBuild(context.Context, *pipeline.Build) error
	// RemoveBuild defines a function that deletes
	// (kill, remove) the pipeline build metadata.
	RemoveBuild(context.Context, *pipeline.Build) error

	// InspectContainer defines a function that inspects
	// the pipeline container.
	InspectContainer(context.Context, *pipeline.Container) error
	// RemoveContainer defines a function that deletes
	// (kill, remove) the pipeline container.
	RemoveContainer(context.Context, *pipeline.Container) error
	// RunContainer defines a function that creates
	// and starts the pipeline container.
	RunContainer(context.Context, *pipeline.Container, *pipeline.Build) error
	// SetupContainer defines a function that prepares
	// the image for the pipeline container.
	SetupContainer(context.Context, *pipeline.Container) error
	// TailContainer defines a function that captures
	// the logs on the pipeline container.
	TailContainer(context.Context, *pipeline.Container) (io.ReadCloser, error)
	// WaitContainer defines a function that blocks
	// until the pipeline container completes.
	WaitContainer(context.Context, *pipeline.Container) error

	// CreateImage defines a function that
	// creates the pipeline container image.
	CreateImage(context.Context, *pipeline.Container) error
	// InspectImage defines a function that
	// inspects the pipeline container image.
	InspectImage(context.Context, *pipeline.Container) ([]byte, error)

	// CreateNetwork defines a function that
	// creates the pipeline network.
	CreateNetwork(context.Context, *pipeline.Build) error
	// InspectNetwork defines a function that
	// inspects the pipeline network.
	InspectNetwork(context.Context, *pipeline.Build) ([]byte, error)
	// RemoveNetwork defines a function that
	// deletes the pipeline network.
	RemoveNetwork(context.Context, *pipeline.Build) error

	// CreateVolume defines a function that
	// creates the pipeline volume.
	CreateVolume(context.Context, *pipeline.Build) error
	// InspectVolume defines a function that
	// inspects the pipeline volume.
	InspectVolume(context.Context, *pipeline.Build) ([]byte, error)
	// RemoveVolume defines a function that
	// deletes the pipeline volume.
	RemoveVolume(context.Context, *pipeline.Build) error
}

Engine represents the interface for Vela integrating with the different supported Runtime environments.

func FromContext

func FromContext(c context.Context) Engine

FromContext retrieves the runtime Engine from the context.Context.

func FromGinContext added in v0.11.0

func FromGinContext(c *gin.Context) Engine

FromGinContext retrieves the runtime Engine from the gin.Context.

func New added in v0.11.0

func New(s *Setup) (Engine, error)

New creates and returns a Vela engine capable of integrating with the configured runtime.

Currently the following runtimes are supported:

* docker * kubernetes .

type Setup added in v0.11.0

type Setup struct {
	// https://pkg.go.dev/github.com/sirupsen/logrus#Entry
	Logger *logrus.Entry

	// Mock should only be true for tests.
	Mock bool

	// specifies the driver to use for the runtime client
	Driver string
	// specifies the path to a configuration file to use for the runtime client
	ConfigFile string
	// specifies a list of host volumes to use for the runtime client
	HostVolumes []string
	// specifies the namespace to use for the runtime client (only used by kubernetes)
	Namespace string
	// specifies the name of the PipelinePodsTemplate to retrieve from the given namespace (only used by kubernetes)
	PodsTemplateName string
	// specifies the fallback path of a PipelinePodsTemplate in a local YAML file (only used by kubernetes; only used if PodsTemplateName not defined)
	PodsTemplateFile string
	// specifies a list of privileged images to use for the runtime client
	PrivilegedImages []string
	// specifies a list of kernel capabilities to drop from container (only used by Docker)
	DropCapabilities []string
}

Setup represents the configuration necessary for creating a Vela engine capable of integrating with a configured runtime environment.

func (*Setup) Docker added in v0.11.0

func (s *Setup) Docker() (Engine, error)

Docker creates and returns a Vela engine capable of integrating with a Docker runtime environment.

func (*Setup) Kubernetes added in v0.11.0

func (s *Setup) Kubernetes() (Engine, error)

Kubernetes creates and returns a Vela engine capable of integrating with a Kubernetes runtime environment.

func (*Setup) Validate added in v0.11.0

func (s *Setup) Validate() error

Validate verifies the necessary fields for the provided configuration are populated correctly.

Directories

Path Synopsis
Package docker provides the ability for Vela to integrate with Docker as a runtime environment.
Package docker provides the ability for Vela to integrate with Docker as a runtime environment.
Package kubernetes provides the ability for Vela to integrate with Kubernetes as a runtime environment.
Package kubernetes provides the ability for Vela to integrate with Kubernetes as a runtime environment.
apis
Package apis defines the worker-config CRD and related utilities.
Package apis defines the worker-config CRD and related utilities.
apis/vela/v1alpha1
Package v1alpha1 defines version 1alpha1 of the worker-config CRD.
Package v1alpha1 defines version 1alpha1 of the worker-config CRD.
generated/clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
generated/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
generated/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
generated/clientset/versioned/typed/vela/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
generated/clientset/versioned/typed/vela/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.

Jump to

Keyboard shortcuts

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