clustermanager

package
v0.0.0-...-42d1b00 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package clustermanager provides support for managing clusters for e2e tests, responsible for creating/deleting cluster, and cluster life cycle management if running in Prow

Example

This is not a real test, it's for documenting purpose, showcasing the usage of entire clustermanager package Important: DO NOT add `// Output` comment inside this function as it will cause `go test` execute this function. See here: https://blog.golang.org/examples

var (
	minNodes int64 = 1
	maxNodes int64 = 3
	nodeType       = "e2-standard-8"
	region         = "us-east1"
	zone           = "a"
	project        = "myGKEproject"
	addons         = []string{"istio"}
)
gkeClient := GKEClient{}
clusterOps := gkeClient.Setup(GKERequest{
	Request: gke.Request{
		MinNodes: minNodes,
		MaxNodes: maxNodes,
		NodeType: nodeType,
		Region:   region,
		Zone:     zone,
		Project:  project,
		Addons:   addons,
	}})
// Cast to GKEOperation
gkeOps := clusterOps.(*GKECluster)
if err := gkeOps.Acquire(); err != nil {
	log.Fatalf("failed acquire cluster: '%v'", err)
}
log.Printf("GKE project is: %q", gkeOps.Project)
log.Printf("GKE cluster is: %v", gkeOps.Cluster)
Output:

Index

Examples

Constants

View Source
const (
	DefaultGKEMinNodes = 1
	DefaultGKEMaxNodes = 3
	DefaultGKENodeType = "e2-standard-4"
	DefaultGKERegion   = "us-central1"
	DefaultGKEZone     = ""

	DefaultResourceType = boskos.GKEProjectResource

	ClusterRunning = "RUNNING"
)

Variables

View Source
var (
	DefaultGKEBackupRegions = []string{"us-west1", "us-east1"}
)

Functions

This section is empty.

Types

type Client

type Client interface {
	Setup(...interface{}) (ClusterOperations, error)
}

Client is the entrypoint

type ClusterOperations

type ClusterOperations interface {
	Provider() string
	Acquire() error
	Delete() error
}

ClusterOperations contains all provider specific logics

type GKEClient

type GKEClient struct {
}

GKEClient implements Client

func (*GKEClient) Setup

func (gs *GKEClient) Setup(r GKERequest) ClusterOperations

Setup sets up a GKECluster client, takes GEKRequest as parameter and applies all defaults if not defined.

type GKECluster

type GKECluster struct {
	Request *GKERequest
	// Project might be GKE specific, so put it here
	Project string
	// NeedsCleanup tells whether the cluster needs to be deleted afterwards
	// This probably should be part of task wrapper's logic
	NeedsCleanup bool
	Cluster      *container.Cluster
	// contains filtered or unexported fields
}

GKECluster implements ClusterOperations

func (*GKECluster) Acquire

func (gc *GKECluster) Acquire() error

Acquire gets existing cluster or create a new one, the creation logic contains retries in BackupRegions. Default creating cluster in us-central1, and default BackupRegions are us-west1 and us-east1. If Region or Zone is provided then there is no retries

func (*GKECluster) Delete

func (gc *GKECluster) Delete() error

Delete takes care of GKE cluster resource cleanup. It only release Boskos resource if running in Prow, otherwise deletes the cluster if marked NeedsCleanup

func (*GKECluster) Provider

func (gc *GKECluster) Provider() string

Provider returns gke

type GKERequest

type GKERequest struct {
	// Request holds settings for GKE native operations
	gke.Request

	// BackupRegions: fall back regions to try out in case of cluster creation
	// failure due to regional issue(s)
	BackupRegions []string

	// SkipCreation: skips cluster creation
	SkipCreation bool

	// NeedsCleanup: enforce clean up if given this option, used when running
	// locally
	NeedsCleanup bool

	// ResourceType: the boskos resource type to acquire to hold the cluster in create
	ResourceType string
}

GKERequest contains all requests collected for cluster creation

type ResourceType

type ResourceType string
var (
	ClusterResource ResourceType = "e2e-cls"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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