Documentation ¶
Overview ¶
Package gce is an implementation of Interface, LoadBalancer and Instances for Google Compute Engine.
Index ¶
- Constants
- func GetGCERegion(zone string) (string, error)
- type Config
- type GCECloud
- func (gce *GCECloud) AddInstancesToInstanceGroup(name string, zone string, instanceNames []string) error
- func (gce *GCECloud) AddPortToInstanceGroup(ig *compute.InstanceGroup, port int64) (*compute.NamedPort, error)
- func (gce *GCECloud) AddSSHKeyToAllInstances(user string, keyData []byte) error
- func (gce *GCECloud) AttachDisk(diskName, instanceID string, readOnly bool) error
- func (gce *GCECloud) Clusters() (cloudprovider.Clusters, bool)
- func (gce *GCECloud) CreateBackendService(bg *compute.BackendService) error
- func (gce *GCECloud) CreateDisk(name string, zone string, sizeGb int64, tags map[string]string) error
- func (gce *GCECloud) CreateFirewall(name, desc string, sourceRanges netsets.IPNet, ports []int64, ...) error
- func (gce *GCECloud) CreateGlobalForwardingRule(targetProxyLink, ip, name, portRange string) (*compute.ForwardingRule, error)
- func (gce *GCECloud) CreateHttpHealthCheck(hc *compute.HttpHealthCheck) error
- func (gce *GCECloud) CreateInstanceGroup(name string, zone string) (*compute.InstanceGroup, error)
- func (gce *GCECloud) CreateRoute(clusterName string, nameHint string, route *cloudprovider.Route) error
- func (gce *GCECloud) CreateSslCertificate(sslCerts *compute.SslCertificate) (*compute.SslCertificate, error)
- func (gce *GCECloud) CreateTargetHttpProxy(urlMap *compute.UrlMap, name string) (*compute.TargetHttpProxy, error)
- func (gce *GCECloud) CreateTargetHttpsProxy(urlMap *compute.UrlMap, sslCert *compute.SslCertificate, name string) (*compute.TargetHttpsProxy, error)
- func (gce *GCECloud) CreateUrlMap(backend *compute.BackendService, name string) (*compute.UrlMap, error)
- func (gce *GCECloud) CurrentNodeName(hostname string) (string, error)
- func (gce *GCECloud) DeleteBackendService(name string) error
- func (gce *GCECloud) DeleteDisk(diskToDelete string) error
- func (gce *GCECloud) DeleteFirewall(name string) error
- func (gce *GCECloud) DeleteGlobalForwardingRule(name string) error
- func (gce *GCECloud) DeleteGlobalStaticIP(name string) error
- func (gce *GCECloud) DeleteHttpHealthCheck(name string) error
- func (gce *GCECloud) DeleteInstanceGroup(name string, zone string) error
- func (gce *GCECloud) DeleteRoute(clusterName string, route *cloudprovider.Route) error
- func (gce *GCECloud) DeleteSslCertificate(name string) error
- func (gce *GCECloud) DeleteTargetHttpProxy(name string) error
- func (gce *GCECloud) DeleteTargetHttpsProxy(name string) error
- func (gce *GCECloud) DeleteUrlMap(name string) error
- func (gce *GCECloud) DetachDisk(devicePath, instanceID string) error
- func (gce *GCECloud) DiskIsAttached(diskName, instanceID string) (bool, error)
- func (gce *GCECloud) EnsureLoadBalancer(name, region string, requestedIP net.IP, ports []*api.ServicePort, ...) (*api.LoadBalancerStatus, error)
- func (gce *GCECloud) EnsureLoadBalancerDeleted(name, region string) error
- func (gce *GCECloud) ExternalID(instance string) (string, error)
- func (gce *GCECloud) GetAutoLabelsForPD(name string) (map[string]string, error)
- func (gce *GCECloud) GetBackendService(name string) (*compute.BackendService, error)
- func (g *GCECloud) GetComputeService() *compute.Service
- func (gce *GCECloud) GetFirewall(name string) (*compute.Firewall, error)
- func (gce *GCECloud) GetGlobalForwardingRule(name string) (*compute.ForwardingRule, error)
- func (gce *GCECloud) GetGlobalStaticIP(name string) (address *compute.Address, err error)
- func (gce *GCECloud) GetHealth(name string, instanceGroupLink string) (*compute.BackendServiceGroupHealth, error)
- func (gce *GCECloud) GetHttpHealthCheck(name string) (*compute.HttpHealthCheck, error)
- func (gce *GCECloud) GetInstanceGroup(name string, zone string) (*compute.InstanceGroup, error)
- func (gce *GCECloud) GetLoadBalancer(name, region string) (*api.LoadBalancerStatus, bool, error)
- func (gce *GCECloud) GetSslCertificate(name string) (*compute.SslCertificate, error)
- func (gce *GCECloud) GetTargetHttpProxy(name string) (*compute.TargetHttpProxy, error)
- func (gce *GCECloud) GetTargetHttpsProxy(name string) (*compute.TargetHttpsProxy, error)
- func (gce *GCECloud) GetUrlMap(name string) (*compute.UrlMap, error)
- func (gce *GCECloud) GetZone() (cloudprovider.Zone, error)
- func (gce *GCECloud) InstanceID(instanceName string) (string, error)
- func (gce *GCECloud) InstanceType(instanceName string) (string, error)
- func (gce *GCECloud) Instances() (cloudprovider.Instances, bool)
- func (gce *GCECloud) List(filter string) ([]string, error)
- func (gce *GCECloud) ListBackendServices() (*compute.BackendServiceList, error)
- func (gce *GCECloud) ListClusters() ([]string, error)
- func (gce *GCECloud) ListGlobalForwardingRules() (*compute.ForwardingRuleList, error)
- func (gce *GCECloud) ListHttpHealthChecks() (*compute.HttpHealthCheckList, error)
- func (gce *GCECloud) ListInstanceGroups(zone string) (*compute.InstanceGroupList, error)
- func (gce *GCECloud) ListInstancesInInstanceGroup(name string, zone string, state string) (*compute.InstanceGroupsListInstances, error)
- func (gce *GCECloud) ListRoutes(clusterName string) ([]*cloudprovider.Route, error)
- func (gce *GCECloud) ListSslCertificates() (*compute.SslCertificateList, error)
- func (gce *GCECloud) ListTargetHttpProxies() (*compute.TargetHttpProxyList, error)
- func (gce *GCECloud) ListTargetHttpsProxies() (*compute.TargetHttpsProxyList, error)
- func (gce *GCECloud) ListUrlMaps() (*compute.UrlMapList, error)
- func (gce *GCECloud) LoadBalancer() (cloudprovider.LoadBalancer, bool)
- func (gce *GCECloud) Master(clusterName string) (string, error)
- func (gce *GCECloud) NodeAddresses(_ string) ([]api.NodeAddress, error)
- func (gce *GCECloud) ProviderName() string
- func (gce *GCECloud) RemoveInstancesFromInstanceGroup(name string, zone string, instanceNames []string) error
- func (gce *GCECloud) ReserveGlobalStaticIP(name, ipAddress string) (address *compute.Address, err error)
- func (gce *GCECloud) Routes() (cloudprovider.Routes, bool)
- func (gce *GCECloud) ScrubDNS(nameservers, searches []string) (nsOut, srchOut []string)
- func (gce *GCECloud) SetProxyForGlobalForwardingRule(fw *compute.ForwardingRule, targetProxyLink string) error
- func (gce *GCECloud) SetSslCertificateForTargetHttpsProxy(proxy *compute.TargetHttpsProxy, sslCert *compute.SslCertificate) error
- func (gce *GCECloud) SetUrlMapForTargetHttpProxy(proxy *compute.TargetHttpProxy, urlMap *compute.UrlMap) error
- func (gce *GCECloud) SetUrlMapForTargetHttpsProxy(proxy *compute.TargetHttpsProxy, urlMap *compute.UrlMap) error
- func (gce *GCECloud) UpdateBackendService(bg *compute.BackendService) error
- func (gce *GCECloud) UpdateFirewall(name, desc string, sourceRanges netsets.IPNet, ports []int64, ...) error
- func (gce *GCECloud) UpdateHttpHealthCheck(hc *compute.HttpHealthCheck) error
- func (gce *GCECloud) UpdateLoadBalancer(name, region string, hostNames []string) error
- func (gce *GCECloud) UpdateUrlMap(urlMap *compute.UrlMap) (*compute.UrlMap, error)
- func (gce *GCECloud) Zones() (cloudprovider.Zones, bool)
Constants ¶
const (
ProviderName = "gce"
)
Variables ¶
This section is empty.
Functions ¶
func GetGCERegion ¶
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.
Types ¶
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) AddInstancesToInstanceGroup ¶
func (gce *GCECloud) AddInstancesToInstanceGroup(name string, zone string, instanceNames []string) error
AddInstancesToInstanceGroup adds the given instances to the given instance group.
func (*GCECloud) AddPortToInstanceGroup ¶
func (gce *GCECloud) AddPortToInstanceGroup(ig *compute.InstanceGroup, port int64) (*compute.NamedPort, error)
AddPortToInstanceGroup adds a port to the given instance group.
func (*GCECloud) AddSSHKeyToAllInstances ¶
func (*GCECloud) AttachDisk ¶
func (*GCECloud) CreateBackendService ¶
func (gce *GCECloud) CreateBackendService(bg *compute.BackendService) error
CreateBackendService creates the given BackendService.
func (*GCECloud) CreateDisk ¶
func (gce *GCECloud) CreateDisk(name string, zone string, sizeGb int64, tags map[string]string) error
CreateDisk creates a new Persistent Disk, with the specified name & size, in the specified zone. It stores specified tags endoced in JSON in Description field.
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) CreateGlobalForwardingRule ¶
func (gce *GCECloud) CreateGlobalForwardingRule(targetProxyLink, ip, name, portRange string) (*compute.ForwardingRule, error)
CreateGlobalForwardingRule creates and returns a GlobalForwardingRule that points to the given TargetHttp(s)Proxy. targetProxyLink is the SelfLink of a TargetHttp(s)Proxy.
func (*GCECloud) CreateHttpHealthCheck ¶
func (gce *GCECloud) CreateHttpHealthCheck(hc *compute.HttpHealthCheck) error
CreateHttpHealthCheck creates the given HttpHealthCheck.
func (*GCECloud) CreateInstanceGroup ¶
CreateInstanceGroup creates an instance group with the given instances. It is the callers responsibility to add named ports.
func (*GCECloud) CreateRoute ¶
func (*GCECloud) CreateSslCertificate ¶
func (gce *GCECloud) CreateSslCertificate(sslCerts *compute.SslCertificate) (*compute.SslCertificate, error)
CreateSslCertificate creates and returns a SslCertificate.
func (*GCECloud) CreateTargetHttpProxy ¶
func (gce *GCECloud) CreateTargetHttpProxy(urlMap *compute.UrlMap, name string) (*compute.TargetHttpProxy, error)
CreateTargetHttpProxy creates and returns a TargetHttpProxy with the given UrlMap.
func (*GCECloud) CreateTargetHttpsProxy ¶
func (gce *GCECloud) CreateTargetHttpsProxy(urlMap *compute.UrlMap, sslCert *compute.SslCertificate, name string) (*compute.TargetHttpsProxy, error)
CreateTargetHttpsProxy creates and returns a TargetHttpsProxy with the given UrlMap and SslCertificate.
func (*GCECloud) CreateUrlMap ¶
func (gce *GCECloud) CreateUrlMap(backend *compute.BackendService, name string) (*compute.UrlMap, error)
CreateUrlMap creates an url map, using the given backend service as the default service.
func (*GCECloud) CurrentNodeName ¶
Implementation of Instances.CurrentNodeName
func (*GCECloud) DeleteBackendService ¶
DeleteBackendService deletes the given BackendService by name.
func (*GCECloud) DeleteDisk ¶
func (*GCECloud) DeleteFirewall ¶
DeleteFirewall deletes the given firewall rule.
func (*GCECloud) DeleteGlobalForwardingRule ¶
DeleteGlobalForwardingRule deletes the GlobalForwardingRule by name.
func (*GCECloud) DeleteGlobalStaticIP ¶
DeleteGlobalStaticIP deletes a global static IP by name.
func (*GCECloud) DeleteHttpHealthCheck ¶
DeleteHttpHealthCheck deletes the given HttpHealthCheck by name.
func (*GCECloud) DeleteInstanceGroup ¶
DeleteInstanceGroup deletes an instance group.
func (*GCECloud) DeleteRoute ¶
func (gce *GCECloud) DeleteRoute(clusterName string, route *cloudprovider.Route) error
func (*GCECloud) DeleteSslCertificate ¶
DeleteSslCertificate deletes the SslCertificate by name.
func (*GCECloud) DeleteTargetHttpProxy ¶
DeleteTargetHttpProxy deletes the TargetHttpProxy by name.
func (*GCECloud) DeleteTargetHttpsProxy ¶
DeleteTargetHttpsProxy deletes the TargetHttpsProxy by name.
func (*GCECloud) DeleteUrlMap ¶
DeleteUrlMap deletes a url map by name.
func (*GCECloud) DetachDisk ¶
func (*GCECloud) DiskIsAttached ¶
func (*GCECloud) EnsureLoadBalancer ¶
func (gce *GCECloud) EnsureLoadBalancer(name, region string, requestedIP net.IP, ports []*api.ServicePort, hostNames []string, svc types.NamespacedName, affinityType api.ServiceAffinity, annotations map[string]string) (*api.LoadBalancerStatus, error)
EnsureLoadBalancer 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) EnsureLoadBalancerDeleted ¶
EnsureLoadBalancerDeleted is an implementation of LoadBalancer.EnsureLoadBalancerDeleted.
func (*GCECloud) ExternalID ¶
ExternalID returns the cloud provider ID of the specified instance (deprecated).
func (*GCECloud) GetAutoLabelsForPD ¶
Builds the labels that should be automatically added to a PersistentVolume backed by a GCE PD Specifically, this builds FailureDomain (zone) and Region labels. The PersistentVolumeLabel admission controller calls this and adds the labels when a PV is created.
func (*GCECloud) GetBackendService ¶
func (gce *GCECloud) GetBackendService(name string) (*compute.BackendService, error)
GetBackendService retrieves a backend by name.
func (*GCECloud) GetComputeService ¶
Raw access to the underlying GCE service, probably should only be used for e2e tests
func (*GCECloud) GetFirewall ¶
GetFirewall returns the Firewall by name.
func (*GCECloud) GetGlobalForwardingRule ¶
func (gce *GCECloud) GetGlobalForwardingRule(name string) (*compute.ForwardingRule, error)
GetGlobalForwardingRule returns the GlobalForwardingRule by name.
func (*GCECloud) GetGlobalStaticIP ¶
GetGlobalStaticIP returns the global static IP by name.
func (*GCECloud) GetHealth ¶
func (gce *GCECloud) GetHealth(name string, instanceGroupLink string) (*compute.BackendServiceGroupHealth, error)
GetHealth returns the health of the BackendService identified by the given name, in the given instanceGroup. The instanceGroupLink is the fully qualified self link of an instance group.
func (*GCECloud) GetHttpHealthCheck ¶
func (gce *GCECloud) GetHttpHealthCheck(name string) (*compute.HttpHealthCheck, error)
GetHttpHealthCheck returns the given HttpHealthCheck by name.
func (*GCECloud) GetInstanceGroup ¶
GetInstanceGroup returns an instance group by name.
func (*GCECloud) GetLoadBalancer ¶
GetLoadBalancer is an implementation of LoadBalancer.GetLoadBalancer
func (*GCECloud) GetSslCertificate ¶
func (gce *GCECloud) GetSslCertificate(name string) (*compute.SslCertificate, error)
GetSslCertificate returns the SslCertificate by name.
func (*GCECloud) GetTargetHttpProxy ¶
func (gce *GCECloud) GetTargetHttpProxy(name string) (*compute.TargetHttpProxy, error)
GetTargetHttpProxy returns the UrlMap by name.
func (*GCECloud) GetTargetHttpsProxy ¶
func (gce *GCECloud) GetTargetHttpsProxy(name string) (*compute.TargetHttpsProxy, error)
GetTargetHttpsProxy returns the UrlMap by name.
func (*GCECloud) InstanceID ¶
InstanceID returns the cloud provider ID of the specified instance.
func (*GCECloud) InstanceType ¶
InstanceType returns the type of the specified instance.
func (*GCECloud) Instances ¶
func (gce *GCECloud) Instances() (cloudprovider.Instances, bool)
Instances returns an implementation of Instances for Google Compute Engine.
func (*GCECloud) ListBackendServices ¶
func (gce *GCECloud) ListBackendServices() (*compute.BackendServiceList, error)
ListBackendServices lists all backend services in the project.
func (*GCECloud) ListClusters ¶
func (*GCECloud) ListGlobalForwardingRules ¶
func (gce *GCECloud) ListGlobalForwardingRules() (*compute.ForwardingRuleList, error)
ListGlobalForwardingRules lists all GlobalForwardingRules in the project.
func (*GCECloud) ListHttpHealthChecks ¶
func (gce *GCECloud) ListHttpHealthChecks() (*compute.HttpHealthCheckList, error)
ListHttpHealthCheck lists all HttpHealthChecks in the project.
func (*GCECloud) ListInstanceGroups ¶
func (gce *GCECloud) ListInstanceGroups(zone string) (*compute.InstanceGroupList, error)
ListInstanceGroups lists all InstanceGroups in the project and zone.
func (*GCECloud) ListInstancesInInstanceGroup ¶
func (gce *GCECloud) ListInstancesInInstanceGroup(name string, zone string, state string) (*compute.InstanceGroupsListInstances, error)
ListInstancesInInstanceGroup lists all the instances in a given instance group and state.
func (*GCECloud) ListRoutes ¶
func (gce *GCECloud) ListRoutes(clusterName string) ([]*cloudprovider.Route, error)
func (*GCECloud) ListSslCertificates ¶
func (gce *GCECloud) ListSslCertificates() (*compute.SslCertificateList, error)
ListSslCertificates lists all SslCertificates in the project.
func (*GCECloud) ListTargetHttpProxies ¶
func (gce *GCECloud) ListTargetHttpProxies() (*compute.TargetHttpProxyList, error)
ListTargetHttpProxies lists all TargetHttpProxies in the project.
func (*GCECloud) ListTargetHttpsProxies ¶
func (gce *GCECloud) ListTargetHttpsProxies() (*compute.TargetHttpsProxyList, error)
ListTargetHttpsProxies lists all TargetHttpsProxies in the project.
func (*GCECloud) ListUrlMaps ¶
func (gce *GCECloud) ListUrlMaps() (*compute.UrlMapList, error)
ListUrlMaps lists all UrlMaps in the project.
func (*GCECloud) LoadBalancer ¶
func (gce *GCECloud) LoadBalancer() (cloudprovider.LoadBalancer, bool)
LoadBalancer returns an implementation of LoadBalancer for Google Compute Engine.
func (*GCECloud) NodeAddresses ¶
func (gce *GCECloud) NodeAddresses(_ string) ([]api.NodeAddress, error)
NodeAddresses is an implementation of Instances.NodeAddresses.
func (*GCECloud) ProviderName ¶
ProviderName returns the cloud provider ID.
func (*GCECloud) RemoveInstancesFromInstanceGroup ¶
func (gce *GCECloud) RemoveInstancesFromInstanceGroup(name string, zone string, instanceNames []string) error
RemoveInstancesFromInstanceGroup removes the given instances from the instance group.
func (*GCECloud) ReserveGlobalStaticIP ¶
func (gce *GCECloud) ReserveGlobalStaticIP(name, ipAddress string) (address *compute.Address, err error)
ReserveGlobalStaticIP creates a global static IP. Caller is allocated a random IP if they do not specify an ipAddress. If an ipAddress is specified, it must belong to the current project, eg: an ephemeral IP associated with a global forwarding rule.
func (*GCECloud) Routes ¶
func (gce *GCECloud) Routes() (cloudprovider.Routes, bool)
Routes returns an implementation of Routes for Google Compute Engine.
func (*GCECloud) SetProxyForGlobalForwardingRule ¶
func (gce *GCECloud) SetProxyForGlobalForwardingRule(fw *compute.ForwardingRule, targetProxyLink string) error
SetProxyForGlobalForwardingRule links the given TargetHttp(s)Proxy with the given GlobalForwardingRule. targetProxyLink is the SelfLink of a TargetHttp(s)Proxy.
func (*GCECloud) SetSslCertificateForTargetHttpsProxy ¶
func (gce *GCECloud) SetSslCertificateForTargetHttpsProxy(proxy *compute.TargetHttpsProxy, sslCert *compute.SslCertificate) error
SetSslCertificateForTargetHttpsProxy sets the given SslCertificate for the given TargetHttpsProxy.
func (*GCECloud) SetUrlMapForTargetHttpProxy ¶
func (gce *GCECloud) SetUrlMapForTargetHttpProxy(proxy *compute.TargetHttpProxy, urlMap *compute.UrlMap) error
SetUrlMapForTargetHttpProxy sets the given UrlMap for the given TargetHttpProxy.
func (*GCECloud) SetUrlMapForTargetHttpsProxy ¶
func (gce *GCECloud) SetUrlMapForTargetHttpsProxy(proxy *compute.TargetHttpsProxy, urlMap *compute.UrlMap) error
SetUrlMapForTargetHttpsProxy sets the given UrlMap for the given TargetHttpsProxy.
func (*GCECloud) UpdateBackendService ¶
func (gce *GCECloud) UpdateBackendService(bg *compute.BackendService) error
UpdateBackendService applies the given BackendService as an update to an existing service.
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.
func (*GCECloud) UpdateHttpHealthCheck ¶
func (gce *GCECloud) UpdateHttpHealthCheck(hc *compute.HttpHealthCheck) error
UpdateHttpHealthCheck applies the given HttpHealthCheck as an update.
func (*GCECloud) UpdateLoadBalancer ¶
UpdateLoadBalancer is an implementation of LoadBalancer.UpdateLoadBalancer.
func (*GCECloud) UpdateUrlMap ¶
UpdateUrlMap applies the given UrlMap as an update, and returns the new UrlMap.