gce

package
v0.0.0-...-56e15b1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2021 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package gce is an implementation of Interface, LoadBalancer and Instances for Google Compute Engine.

Index

Constants

View Source
const (
	ProviderName = "gce"
)

Variables

This section is empty.

Functions

func GetGCERegion

func GetGCERegion(zone string) (string, error)

GetGCERegion returns region of the gce zone. Zone names are of the form: ${region-name}-${ix}. For example, "us-central1-b" has a region of "us-central1". So we look for the last '-' and trim to just before that.

func NewAltTokenSource

func NewAltTokenSource(tokenURL, tokenBody string) oauth2.TokenSource

Types

type AltTokenSource

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

func (*AltTokenSource) Token

func (a *AltTokenSource) Token() (*oauth2.Token, error)

type Config

type Config struct {
	Global struct {
		TokenURL           string   `gcfg:"token-url"`
		TokenBody          string   `gcfg:"token-body"`
		ProjectID          string   `gcfg:"project-id"`
		NetworkName        string   `gcfg:"network-name"`
		NodeTags           []string `gcfg:"node-tags"`
		NodeInstancePrefix string   `gcfg:"node-instance-prefix"`
		Multizone          bool     `gcfg:"multizone"`
	}
}

type GCECloud

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

GCECloud is an implementation of Interface, LoadBalancer and Instances for Google Compute Engine.

func CreateGCECloud

func CreateGCECloud(projectID, region, zone string, managedZones []string, networkURL string, nodeTags []string, nodeInstancePrefix string, tokenSource oauth2.TokenSource, useMetadataServer bool) (*GCECloud, error)

Creates a GCECloud object using the specified parameters. If no networkUrl is specified, loads networkName via rest call. If no tokenSource is specified, uses oauth2.DefaultTokenSource. If managedZones is nil / empty all zones in the region will be managed.

func (*GCECloud) EnsureFirewall

func (gce *GCECloud) EnsureFirewall(ctx context.Context, apiService *apiv1.Service, hostnames []string) error

EnsureFirewall is an implementation of LoadBalancer.EnsureLoadBalancer. Our load balancers in GCE consist of four separate GCE resources - a static IP address, a firewall rule, a target pool, and a forwarding rule. This function has to manage all of them. Due to an interesting series of design decisions, this handles both creating new load balancers and updating existing load balancers, recognizing when each is needed.

func (*GCECloud) EnsureFirewallDeleted

func (gce *GCECloud) EnsureFirewallDeleted(ctx context.Context, service *apiv1.Service) error

EnsureFirewallDeleted is an implementation of Firewall.EnsureFirewallDeleted.

func (*GCECloud) Firewall

func (gce *GCECloud) Firewall() (cloudprovider.Firewall, bool)

Firewall returns an implementation of Firewall for Google Compute Engine.

func (*GCECloud) GetComputeService

func (gce *GCECloud) GetComputeService() *compute.Service

Raw access to the underlying GCE service, probably should only be used for e2e tests

func (*GCECloud) GetSecurityGroupName

func (gce *GCECloud) GetSecurityGroupName(service *apiv1.Service) string

func (*GCECloud) ProviderName

func (gce *GCECloud) ProviderName() string

ProviderName returns the cloud provider ID.

Jump to

Keyboard shortcuts

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