gce

package
v0.0.0-...-d0c0f99 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2017 License: Apache-2.0 Imports: 25 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) CreateFirewall

func (gce *GCECloud) CreateFirewall(name, desc string, sourceRanges netsets.IPNet, ports []int64, hostNames []string) error

CreateFirewall creates the given firewall rule.

func (*GCECloud) DeleteFirewall

func (gce *GCECloud) DeleteFirewall(name string) error

DeleteFirewall deletes the given firewall rule.

func (*GCECloud) EnsureFirewall

func (gce *GCECloud) EnsureFirewall(apiService *apiv1.Service, hostName 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(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 (g *GCECloud) GetComputeService() *compute.Service

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

func (*GCECloud) GetFirewall

func (gce *GCECloud) GetFirewall(name string) (*compute.Firewall, error)

GetFirewall returns the Firewall by name.

func (*GCECloud) ProviderName

func (gce *GCECloud) ProviderName() string

ProviderName returns the cloud provider ID.

func (*GCECloud) UpdateFirewall

func (gce *GCECloud) UpdateFirewall(name, desc string, sourceRanges netsets.IPNet, ports []int64, hostNames []string) error

UpdateFirewall applies the given firewall rule as an update to an existing firewall rule with the same name.

Jump to

Keyboard shortcuts

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