kube

package
v0.0.0-...-71932e2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiskKubeConfigPath

func DiskKubeConfigPath() string

DiskKubeConfigPath returns the path to a KubeConfig file on disk.

This is meant for client-side access to Kubernetes, not in-cluster access

func LoadClient

func LoadClient(configPath string) (*k8s.Client, error)

LoadClient parses a kubeconfig from a file and returns a Kubernetes client. It does not support extensions or client auth providers.

This code was taken from: // https://github.com/ericchiang/k8s/tree/68fb2168bedf77759577a56e44f2ccfaf7229673#creating-out-of-cluster-clients

func LoadClientFromDiskKubeConfig

func LoadClientFromDiskKubeConfig() (*k8s.Client, error)

func SetupAndInstallProfile

func SetupAndInstallProfile(
	ctx context.Context,
	cl *k8s.Client,
	pr Profile,
	strat ErrorStrategy,
) error

SetupAndInstallProfile calls pr.Setup and then pr.Install according to strat

Types

type ErrorStrategy

type ErrorStrategy string

ErrorStrategy is the strategy that a profile takes when installing, uninstalling, and updating resources

const (
	ErrorStrategyStop     ErrorStrategy = "stop"
	ErrorStrategyRollback ErrorStrategy = "rollback"
	ErrorStrategyContinue ErrorStrategy = "continue"
)

type Profile

type Profile interface {
	fmt.Stringer
	// Setup prepares Kubernetes to install the profile. This is doing things
	// like creating namespaces, etc...
	Setup(context.Context, *k8s.Client, ErrorStrategy) error
	// AllResources returns all the Kubernetes resources in this profile, in the
	// order they're stored
	AllResources() []resources.Resource
	Install(context.Context, *k8s.Client, ErrorStrategy) error
	// Uninstall calls Delete on all resources in the profile, in reverse order
	Uninstall(context.Context, *k8s.Client, ErrorStrategy) error
	// Update updates every resource in the profile
	Update(context.Context, *k8s.Client, ErrorStrategy) error
	// Status checks all the resources inside the profile and returns nil
	// if everything is installed properly.
	//
	// Otherwise, returns an error(s) indicating what's wrong
	Status(context.Context, *k8s.Client) error
}

Profile is a group of kubernetes resources that make up a specific kind of app

For example, a web server would have a Deployment, Service and Ingress in most cases.

A long-running background job would be just a Job in most cases.

Profiles represent "sensible defaults", and they are represented internally as lists of Resources that are installed in order and uninstalled in reverse-order

func NewLongRunningBatchProfile

func NewLongRunningBatchProfile(
	name,
	ns string,
	cl resources.ContainerList,
) Profile

NewLongRunningBatchProfile creates a new profile that contains all the kubernetes resources you need to launch or update a long running batch job

func NewWebServerProfile

func NewWebServerProfile(
	name,
	ns,
	host string,
	replicas int32,
	containers resources.ContainerList,
) Profile

NewWebServerProfile creates a new profile that contains all the kubernetes resources you need to launch or update a web server

type ProfileComposer

type ProfileComposer struct {
	// contains filtered or unexported fields
}

ProfileComposer is a Profile implementation that composes multiple profiles together and manages them all at once. It's useful for installing more complex applications (like microservices etc...) in one go

Use NewProfileComposer to create a new one of these

func NewComposedProfile

func NewComposedProfile(profiles ...Profile) *ProfileComposer

NewComposedProfile creates a new ProfileComposer from a list of profiles

func (*ProfileComposer) AllResources

func (p *ProfileComposer) AllResources() []resources.Resource

AllResources implements Profile. Since profiles themselves have resource lists, this function flattens each of the lists into one list, in the order of each list, and then in the order of the profiles in p

func (*ProfileComposer) Install

func (p *ProfileComposer) Install(
	ctx context.Context,
	cl *k8s.Client,
	strat ErrorStrategy,
) error

Install implements Profile

func (*ProfileComposer) Setup

func (p *ProfileComposer) Setup(
	ctx context.Context,
	cl *k8s.Client,
	strat ErrorStrategy,
) error

Setup implements Profile

func (*ProfileComposer) Status

func (p *ProfileComposer) Status(ctx context.Context, cl *k8s.Client) error

Status implements Profile

func (*ProfileComposer) String

func (p *ProfileComposer) String() string

String implements fmt.Stringer

func (*ProfileComposer) Uninstall

func (p *ProfileComposer) Uninstall(
	ctx context.Context,
	cl *k8s.Client,
	strat ErrorStrategy,
) error

Uninstall implements Profile

func (*ProfileComposer) Update

func (p *ProfileComposer) Update(ctx context.Context, cl *k8s.Client, strat ErrorStrategy) error

Update implements Profile

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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