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 ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
Setup(...interface{}) (ClusterOperations, error)
}
Client is the entrypoint
type ClusterOperations ¶
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 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 also releases Boskos resource if running in Prow.
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 // ResourceType: the boskos resource type to acquire to hold the cluster in create ResourceType string // SaveMetaData: save the meta data for the created cluster into a file SaveMetaData bool }
GKERequest contains all requests collected for cluster creation