gce

package
v1.27.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2023 License: Apache-2.0 Imports: 32 Imported by: 476

Documentation

Index

Constants

View Source
const (
	// The tag name we use to differentiate multiple logically independent clusters running in the same region
	GceLabelNameKubernetesCluster = "k8s-io-cluster-name"
	GceLabelNameInstanceGroup     = "k8s-io-instance-group"
	GceLabelNameRolePrefix        = "k8s-io-role-"
	GceLabelNameEtcdClusterPrefix = "k8s-io-etcd-"
	ControlPlane                  = "control-plane"
	Bastion                       = "bastion"
	Node                          = "node"
)

Variables

This section is empty.

Functions

func CacheGCECloudInstance added in v1.21.0

func CacheGCECloudInstance(region string, project string, c GCECloud)

func ClusterPrefixedName added in v1.24.0

func ClusterPrefixedName(objectName string, clusterName string, maxLength int) string

ClusterPrefixedName returns a cluster-prefixed name, with a maxLength

func ClusterSuffixedName added in v1.24.0

func ClusterSuffixedName(objectName string, clusterName string, maxLength int) string

ClusterSuffixedName returns a cluster-suffixed name, with a maxLength

func DecodeGCELabel added in v1.10.0

func DecodeGCELabel(s string) (string, error)

DecodeGCELabel reverse EncodeGCELabel, taking the encoded RFC1035 compatible value back to a string

func DefaultProject added in v1.10.0

func DefaultProject() (string, error)

DefaultProject returns the current project configured in the gcloud SDK, ("", nil) if no project was set

func DeleteInstance added in v1.10.0

func DeleteInstance(c GCECloud, instanceSelfLink string) error

DeleteInstance deletes the specified instance (by URL) in GCE

func DeleteInstanceGroupManager added in v1.10.0

func DeleteInstanceGroupManager(c GCECloud, t *compute.InstanceGroupManager) error

DeleteInstanceGroupManager deletes the specified InstanceGroupManager in GCE

func DeleteInstanceTemplate added in v1.10.0

func DeleteInstanceTemplate(c GCECloud, selfLink string) error

DeleteInstanceTemplate deletes the specified InstanceTemplate (by URL) in GCE

func EncodeGCELabel added in v1.10.0

func EncodeGCELabel(s string) string

EncodeGCELabel encodes a string into an RFC1035 compatible value, suitable for use as GCE label key or value We use a URI inspired escaping, but with - instead of %.

func FindInstanceTemplates added in v1.10.0

func FindInstanceTemplates(c GCECloud, clusterName string) ([]*compute.InstanceTemplate, error)

FindInstanceTemplates finds all instance templates that are associated with the current cluster It matches them by looking for instance metadata with key='cluster-name' and value of our cluster name

func IsNotFound

func IsNotFound(err error) bool

func IsNotReady

func IsNotReady(err error) bool

func LastComponent added in v1.10.0

func LastComponent(s string) string

LastComponent returns the last component of a URL, i.e. anything after the last slash If there is no slash, returns the whole string

func LimitedLengthName added in v1.10.0

func LimitedLengthName(s string, n int) string

LimitedLengthName returns a string subject to a maximum length

func ListManagedInstances added in v1.10.0

func ListManagedInstances(c GCECloud, igm *compute.InstanceGroupManager) ([]*compute.ManagedInstance, error)

ListManagedInstances lists the specified InstanceGroupManagers in GCE

func MutexForProjectIAM added in v1.27.0

func MutexForProjectIAM(projectID string) mutexes.LocalMutex

MutexForProjectIAM returns a mutex to prevent local concurrent operations on project IAM.

func NameForInstanceGroupManager added in v1.10.0

func NameForInstanceGroupManager(c *kops.Cluster, ig *kops.InstanceGroup, zone string) string

NameForInstanceGroupManager builds a name for an InstanceGroupManager in the specified zone

func ParseNameAndProjectFromNetworkID added in v1.24.0

func ParseNameAndProjectFromNetworkID(networkID string) (string, string, error)

ParseNameAndProjectFromNetworkID will take in the GCE-flavored network ID, and return the project and name of the resource. The permitted formats are "network-name", or "project-id/network-name". Empty string is also accepted.

func PerformNetworkAssignments added in v1.15.1

func PerformNetworkAssignments(ctx context.Context, c *kops.Cluster, cloudObj fi.Cloud) error

PerformNetworkAssignments assigns suitable pod and service assignments for GCE, in particular for IP alias support.

func SafeClusterName added in v1.10.0

func SafeClusterName(clusterName string) string

SafeClusterName returns a safe cluster name deprecated: prefer ClusterSuffixedName

func SafeObjectName added in v1.10.0

func SafeObjectName(name string, clusterName string) string

SafeObjectName returns the object name and cluster name escaped for GCE

func SafeTruncatedClusterName added in v1.24.2

func SafeTruncatedClusterName(clusterName string, maxLength int) string

SafeTruncatedClusterName returns a safe and truncated cluster name

func ServiceAccountName added in v1.24.0

func ServiceAccountName(name string, clusterName string) string

ServiceAccountName returns the cluster-suffixed service-account name

func SplitServiceAccountEmail added in v1.24.0

func SplitServiceAccountEmail(email string) (string, string, error)

SplitServiceAccountEmail splits service account email

func TagForRole added in v1.23.0

func TagForRole(clusterName string, role kops.InstanceGroupRole) string

TagForRole return the instance (network) tag used for instances with the given role.

func UsesIPAliases added in v1.15.1

func UsesIPAliases(c *kops.Cluster) bool

UsesIPAliases checks if the cluster uses IP aliases for network connectivity

func WaitForOp added in v1.10.0

func WaitForOp(client *compute.Service, op *compute.Operation) error

func ZoneToRegion added in v1.10.0

func ZoneToRegion(zone string) (string, error)

ZoneToRegion maps a GCE zone name to a GCE region name, returning an error if it cannot be mapped

Types

type AddressClient added in v1.21.0

type AddressClient interface {
	Insert(project, region string, addr *compute.Address) (*compute.Operation, error)
	Delete(project, region, name string) (*compute.Operation, error)
	Get(project, region, name string) (*compute.Address, error)
	List(ctx context.Context, project, region string) ([]*compute.Address, error)
	ListWithFilter(project, region, filter string) ([]*compute.Address, error)
}

type ChangeClient added in v1.21.0

type ChangeClient interface {
	Create(project, zone string, ch *dns.Change) (*dns.Change, error)
}

type ComputeClient added in v1.21.0

type ComputeClient interface {
	Projects() ProjectClient
	Regions() RegionClient
	Zones() ZoneClient
	Networks() NetworkClient
	Subnetworks() SubnetworkClient
	Routes() RouteClient
	ForwardingRules() ForwardingRuleClient
	HTTPHealthChecks() HttpHealthChecksClient
	RegionHealthChecks() RegionHealthChecksClient
	Addresses() AddressClient
	Firewalls() FirewallClient
	Routers() RouterClient
	Instances() InstanceClient
	InstanceTemplates() InstanceTemplateClient
	InstanceGroupManagers() InstanceGroupManagerClient
	TargetPools() TargetPoolClient
	Disks() DiskClient
	RegionBackendServices() RegionBackendServiceClient
}

type DNSClient added in v1.21.0

type DNSClient interface {
	ManagedZones() ManagedZoneClient
	ResourceRecordSets() ResourceRecordSetClient
	Changes() ChangeClient
}

type DiskClient added in v1.21.0

type DiskClient interface {
	Insert(project, zone string, disk *compute.Disk) (*compute.Operation, error)
	Delete(project, zone, name string) (*compute.Operation, error)
	Get(project, zone, name string) (*compute.Disk, error)
	List(ctx context.Context, project, zone string) ([]*compute.Disk, error)
	AggregatedList(ctx context.Context, project string) ([]compute.DisksScopedList, error)
	SetLabels(project, zone, name string, req *compute.ZoneSetLabelsRequest) error
}

type FirewallClient added in v1.21.0

type FirewallClient interface {
	Insert(project string, fw *compute.Firewall) (*compute.Operation, error)
	Delete(project, name string) (*compute.Operation, error)
	Update(project, name string, fw *compute.Firewall) (*compute.Operation, error)
	Get(project, name string) (*compute.Firewall, error)
	List(ctx context.Context, project string) ([]*compute.Firewall, error)
}

type ForwardingRuleClient added in v1.21.0

type ForwardingRuleClient interface {
	Insert(project, region string, fr *compute.ForwardingRule) (*compute.Operation, error)
	Delete(project, region, name string) (*compute.Operation, error)
	Get(project, region, name string) (*compute.ForwardingRule, error)
	List(ctx context.Context, project, region string) ([]*compute.ForwardingRule, error)
}

type GCEAPITarget

type GCEAPITarget struct {
	Cloud GCECloud
}

func NewGCEAPITarget

func NewGCEAPITarget(cloud GCECloud) *GCEAPITarget

func (*GCEAPITarget) DefaultCheckExisting added in v1.26.0

func (t *GCEAPITarget) DefaultCheckExisting() bool

func (*GCEAPITarget) Finish

func (t *GCEAPITarget) Finish(taskMap map[string]fi.CloudupTask) error

func (*GCEAPITarget) ProcessDeletions added in v1.10.0

func (t *GCEAPITarget) ProcessDeletions() bool

type GCECloud

type GCECloud interface {
	fi.Cloud
	Compute() ComputeClient
	Storage() *storage.Service
	IAM() IamClient
	CloudDNS() DNSClient
	Project() string
	WaitForOp(op *compute.Operation) error
	Labels() map[string]string
	Zones() ([]string, error)

	// ServiceAccount returns the email for the service account that the instances will run under
	ServiceAccount() (string, error)

	// CloudResourceManager returns the client for the cloudresourcemanager API
	CloudResourceManager() *cloudresourcemanager.Service
}

func NewGCECloud

func NewGCECloud(region string, project string, labels map[string]string) (GCECloud, error)

type GoogleCloudURL

type GoogleCloudURL struct {
	Version string
	Project string
	Type    string
	Name    string
	Global  bool
	Region  string
	Zone    string
}

func ParseGoogleCloudURL

func ParseGoogleCloudURL(u string) (*GoogleCloudURL, error)

func (*GoogleCloudURL) BuildURL

func (u *GoogleCloudURL) BuildURL() string

type HttpHealthChecksClient added in v1.23.0

type HttpHealthChecksClient interface {
	Insert(project string, fr *compute.HttpHealthCheck) (*compute.Operation, error)
	Delete(project, name string) (*compute.Operation, error)
	Get(project, name string) (*compute.HttpHealthCheck, error)
	List(ctx context.Context, project string) ([]*compute.HttpHealthCheck, error)
}

type IamClient added in v1.24.0

type IamClient interface {
	ServiceAccounts() ServiceAccountClient
}

type InstanceClient added in v1.21.0

type InstanceClient interface {
	Insert(project, zone string, i *compute.Instance) (*compute.Operation, error)
	Get(project, zone, name string) (*compute.Instance, error)
	List(ctx context.Context, project, zone string) ([]*compute.Instance, error)
	Delete(project, zone, name string) (*compute.Operation, error)
	SetMetadata(project, zone, name string, metadata *compute.Metadata) (*compute.Operation, error)
}

type InstanceGroupManagerClient added in v1.21.0

type InstanceGroupManagerClient interface {
	Insert(project, zone string, i *compute.InstanceGroupManager) (*compute.Operation, error)
	Delete(project, zone, name string) (*compute.Operation, error)
	Get(project, zone, name string) (*compute.InstanceGroupManager, error)
	List(ctx context.Context, project, zone string) ([]*compute.InstanceGroupManager, error)
	ListManagedInstances(ctx context.Context, project, zone, name string) ([]*compute.ManagedInstance, error)
	RecreateInstances(project, zone, name, id string) (*compute.Operation, error)
	SetTargetPools(project, zone, name string, targetPools []string) (*compute.Operation, error)
	SetInstanceTemplate(project, zone, name, instanceTemplateURL string) (*compute.Operation, error)
	Resize(project, zone, name string, newSize int64) (*compute.Operation, error)
}

type InstanceTemplateClient added in v1.21.0

type InstanceTemplateClient interface {
	Insert(project string, template *compute.InstanceTemplate) (*compute.Operation, error)
	Delete(project, name string) (*compute.Operation, error)
	List(ctx context.Context, project string) ([]*compute.InstanceTemplate, error)
}

type ManagedZoneClient added in v1.21.0

type ManagedZoneClient interface {
	List(project string) ([]*dns.ManagedZone, error)
}

type NetworkClient added in v1.21.0

type NetworkClient interface {
	Insert(project string, nw *compute.Network) (*compute.Operation, error)
	Get(project, name string) (*compute.Network, error)
	Delete(project, name string) (*compute.Operation, error)
	List(project string) (*compute.NetworkList, error)
}

type ProjectClient added in v1.21.0

type ProjectClient interface {
	Get(project string) (*compute.Project, error)
}

type RegionBackendServiceClient added in v1.24.0

type RegionBackendServiceClient interface {
	Insert(project, region string, fr *compute.BackendService) (*compute.Operation, error)
	Delete(project, region, name string) (*compute.Operation, error)
	Get(project, region, name string) (*compute.BackendService, error)
	List(ctx context.Context, project, region string) ([]*compute.BackendService, error)
}

===

type RegionClient added in v1.21.0

type RegionClient interface {
	List(ctx context.Context, project string) ([]*compute.Region, error)
}

type RegionHealthChecksClient added in v1.24.0

type RegionHealthChecksClient interface {
	Insert(project, region string, fr *compute.HealthCheck) (*compute.Operation, error)
	Delete(project, region, name string) (*compute.Operation, error)
	Get(project, region, name string) (*compute.HealthCheck, error)
	List(ctx context.Context, project, region string) ([]*compute.HealthCheck, error)
}

type ResourceRecordSetClient added in v1.21.0

type ResourceRecordSetClient interface {
	List(project, zone string) ([]*dns.ResourceRecordSet, error)
}

type RouteClient added in v1.21.0

type RouteClient interface {
	Delete(project, name string) (*compute.Operation, error)
	List(ctx context.Context, project string) ([]*compute.Route, error)
}

type RouterClient added in v1.21.0

type RouterClient interface {
	Insert(project, region string, r *compute.Router) (*compute.Operation, error)
	Delete(project, region, name string) (*compute.Operation, error)
	Get(project, region, name string) (*compute.Router, error)
	List(ctx context.Context, project, region string) ([]*compute.Router, error)
}

type ServiceAccountClient added in v1.24.0

type ServiceAccountClient interface {
	Get(ctx context.Context, fqn string) (*iam.ServiceAccount, error)
	Create(ctx context.Context, project string, req *iam.CreateServiceAccountRequest) (*iam.ServiceAccount, error)
	Update(ctx context.Context, fqn string, sa *iam.ServiceAccount) (*iam.ServiceAccount, error)
	Delete(saName string) (*iam.Empty, error)
	List(ctx context.Context, project string) ([]*iam.ServiceAccount, error)
}

type SubnetworkClient added in v1.21.0

type SubnetworkClient interface {
	Insert(project, region string, subnet *compute.Subnetwork) (*compute.Operation, error)
	Patch(project, region, name string, subnet *compute.Subnetwork) (*compute.Operation, error)
	Delete(project, region, name string) (*compute.Operation, error)
	Get(project, region, name string) (*compute.Subnetwork, error)
	List(ctx context.Context, project, region string) ([]*compute.Subnetwork, error)
}

type TargetPoolClient added in v1.21.0

type TargetPoolClient interface {
	Insert(project, region string, tp *compute.TargetPool) (*compute.Operation, error)
	Delete(project, region, name string) (*compute.Operation, error)
	Get(project, region, name string) (*compute.TargetPool, error)
	List(ctx context.Context, project, region string) ([]*compute.TargetPool, error)
	AddHealthCheck(project, region, name string, req *compute.TargetPoolsAddHealthCheckRequest) (*compute.Operation, error)
}

type ZoneClient added in v1.21.0

type ZoneClient interface {
	List(ctx context.Context, project string) ([]*compute.Zone, error)
}

Directories

Path Synopsis
tpm

Jump to

Keyboard shortcuts

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