envtest

package module
v0.0.0-...-f5d5267 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

README

controller-runtime-envtest-k3s

A drop in replacement for https://sigs.k8s.io/controller-runtime/pkg/envtest using https://k3s.io

Why?

  • sigs.k8s.io/controller-runtime/pkg/envtest uses process execution under the hood to run clusters. This uses containers to wrap those processes!
  • Lesss CPU and Memory overhead
  • Provides a full Kubernetes environment for full end-to-end tests (eg. Nodes provided)
  • Easier to debug fails eg. Get a session on the clusters container

Usage

The following example is taking an autogenerated test suite from the Kubebuilder project and converting it to use K3s as it's test Kubernetes cluster.

Can you spot the difference? :)

Before After
before after

Thankyou

This project is standing on the shoulders of giants.

  • K3s - Amazing project which makes it super easy to spin up Kubernetes environments.
  • envtest - We are still using this under the hood for some of the heavily lifting eg. Installing CRDs.

Documentation

Index

Constants

View Source
const (
	// DefaultImage which will be used if non is provided.
	DefaultImage = "docker.io/rancher/k3s:v0.4.0"
	// InsecurePort assigned to the K3s cluster.
	InsecurePort = "8080"
	// BindAddress assigned to the K3s cluster.
	BindAddress = "0.0.0.0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Environment

type Environment struct {
	// Image which will be used for spinning up K3s.
	Image string
	// CRDDirectoryPaths for preloading CustomResourceDefinitions.
	// This is field name was taken from the controller-runtime envtest package
	// for compatibility reasons.
	CRDDirectoryPaths []string
	// contains filtered or unexported fields
}

Environment which will back the Kubebuilder testsuite.

func (*Environment) Start

func (e *Environment) Start() (*rest.Config, error)

Start the test environment.

func (*Environment) Stop

func (e *Environment) Stop() error

Stop the test environment.

Jump to

Keyboard shortcuts

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