gcp

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	// UID retrieves the current instances uid.
	UID(context.Context) (string, error)
	// RetrieveInstances retrieves a list of all accessible GCP instances with their metadata.
	RetrieveInstances(ctx context.Context, project, zone string) ([]metadata.InstanceMetadata, error)
	// RetrieveInstances retrieves a single GCP instances with its metadata.
	RetrieveInstance(ctx context.Context, project, zone, instanceName string) (metadata.InstanceMetadata, error)
	// RetrieveInstanceMetadata retrieves the GCP instance metadata of the current instance.
	RetrieveInstanceMetadata(attr string) (string, error)
	// RetrieveProjectID retrieves the GCP  projectID containing the current instance.
	RetrieveProjectID() (string, error)
	// RetrieveZone retrieves the GCP zone containing the current instance.
	RetrieveZone() (string, error)
	// RetrieveInstanceName retrieves the instance name of the current instance.
	RetrieveInstanceName() (string, error)
	// RetrieveSubnetworkAliasCIDR retrieves the subnetwork CIDR of the current instance.
	RetrieveSubnetworkAliasCIDR(ctx context.Context, project, zone, instanceName string) (string, error)
	// RetrieveLoadBalancerEndpoint retrieves the load balancer endpoint of the current instance.
	RetrieveLoadBalancerEndpoint(ctx context.Context, project string) (string, error)
	// SetInstanceMetadata sets metadata key: value of the instance specified by project, zone and instanceName.
	SetInstanceMetadata(ctx context.Context, project, zone, instanceName, key, value string) error
	// UnsetInstanceMetadata removes a metadata key-value pair of the instance specified by project, zone and instanceName.
	UnsetInstanceMetadata(ctx context.Context, project, zone, instanceName, key string) error
}

API handles all GCP API requests.

type Client

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

Client implements the gcp.API interface.

func NewClient

func NewClient(ctx context.Context) (*Client, error)

NewClient creates a new Client.

func (*Client) Close

func (c *Client) Close() error

Close closes the instanceAPI client.

func (*Client) RetrieveInstance

func (c *Client) RetrieveInstance(ctx context.Context, project, zone, instanceName string) (metadata.InstanceMetadata, error)

RetrieveInstance returns a an instance including ips and metadata.

func (*Client) RetrieveInstanceMetadata

func (c *Client) RetrieveInstanceMetadata(attr string) (string, error)

func (*Client) RetrieveInstanceName

func (c *Client) RetrieveInstanceName() (string, error)

func (*Client) RetrieveInstances

func (c *Client) RetrieveInstances(ctx context.Context, project, zone string) ([]metadata.InstanceMetadata, error)

RetrieveInstances returns list of instances including their ips and metadata.

func (*Client) RetrieveLoadBalancerEndpoint

func (c *Client) RetrieveLoadBalancerEndpoint(ctx context.Context, project string) (string, error)

RetrieveLoadBalancerEndpoint returns the endpoint of the load balancer with the constellation-uid tag.

func (*Client) RetrieveProjectID

func (c *Client) RetrieveProjectID() (string, error)

RetrieveProjectID retrieves the GCP projectID containing the current instance.

func (*Client) RetrieveSubnetworkAliasCIDR

func (c *Client) RetrieveSubnetworkAliasCIDR(ctx context.Context, project, zone, instanceName string) (string, error)

RetrieveSubnetworkAliasCIDR returns the alias CIDR of the subnetwork specified by project, zone and subnetworkName.

func (*Client) RetrieveZone

func (c *Client) RetrieveZone() (string, error)

RetrieveZone retrieves the GCP zone containing the current instance.

func (*Client) SetInstanceMetadata

func (c *Client) SetInstanceMetadata(ctx context.Context, project, zone, instanceName, key, value string) error

SetInstanceMetadata modifies a key value pair of metadata for the instance specified by project, zone and instanceName.

func (*Client) UID

func (c *Client) UID(ctx context.Context) (string, error)

UID retrieves the current instances uid.

func (*Client) UnsetInstanceMetadata

func (c *Client) UnsetInstanceMetadata(ctx context.Context, project, zone, instanceName, key string) error

UnsetInstanceMetadata modifies a key value pair of metadata for the instance specified by project, zone and instanceName.

type CloudControllerManager

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

CloudControllerManager holds the gcp cloud-controller-manager configuration.

func NewCloudControllerManager

func NewCloudControllerManager(ctx context.Context, metadata *Metadata) (*CloudControllerManager, error)

NewCloudControllerManager returns an initialized cloud controller manager configuration struct for GCP.

func (*CloudControllerManager) ConfigMaps

ConfigMaps returns a list of ConfigMaps to deploy together with the k8s cloud-controller-manager Reference: https://kubernetes.io/docs/concepts/configuration/configmap/ .

func (*CloudControllerManager) Env

func (c *CloudControllerManager) Env() []k8s.EnvVar

Env returns a list of k8s environment key-value pairs to deploy together with the k8s cloud-controller-manager.

func (*CloudControllerManager) ExtraArgs

func (c *CloudControllerManager) ExtraArgs() []string

ExtraArgs returns a list of arguments to append to the cloud-controller-manager command.

func (*CloudControllerManager) Image

Image returns the container image used to provide cloud-controller-manager for the cloud-provider.

func (*CloudControllerManager) Name

func (c *CloudControllerManager) Name() string

Name returns the cloud-provider name as used by k8s cloud-controller-manager (k8s.gcr.io/cloud-controller-manager).

func (*CloudControllerManager) Path

func (c *CloudControllerManager) Path() string

Path returns the path used by cloud-controller-manager executable within the container image.

func (*CloudControllerManager) Secrets

func (c *CloudControllerManager) Secrets(_ context.Context, _ string, cloudServiceAccountURI string) (kubernetes.Secrets, error)

Secrets returns a list of secrets to deploy together with the k8s cloud-controller-manager. Reference: https://kubernetes.io/docs/concepts/configuration/secret/ .

func (*CloudControllerManager) Supported

func (c *CloudControllerManager) Supported() bool

Supported is used to determine if cloud controller manager is implemented for this cloud provider.

func (*CloudControllerManager) VolumeMounts

func (c *CloudControllerManager) VolumeMounts() []k8s.VolumeMount

VolumeMounts returns a list of volume mounts to deploy together with the k8s cloud-controller-manager.

func (*CloudControllerManager) Volumes

func (c *CloudControllerManager) Volumes() []k8s.Volume

Volumes returns a list of volumes to deploy together with the k8s cloud-controller-manager. Reference: https://kubernetes.io/docs/concepts/storage/volumes/ .

type CloudNodeManager

type CloudNodeManager struct{}

CloudNodeManager holds the GCP cloud-node-manager configuration.

func (*CloudNodeManager) ExtraArgs

func (c *CloudNodeManager) ExtraArgs() []string

ExtraArgs returns a list of arguments to append to the cloud-node-manager command. Not used on GCP.

func (*CloudNodeManager) Image

func (c *CloudNodeManager) Image(k8sVersion versions.ValidK8sVersion) (string, error)

Image returns the container image used to provide cloud-node-manager for the cloud-provider. Not used on GCP.

func (*CloudNodeManager) Path

func (c *CloudNodeManager) Path() string

Path returns the path used by cloud-node-manager executable within the container image. Not used on GCP.

func (*CloudNodeManager) Supported

func (c *CloudNodeManager) Supported() bool

Supported is used to determine if cloud node manager is implemented for this cloud provider.

type ForwardingRuleIterator

type ForwardingRuleIterator interface {
	Next() (*computepb.ForwardingRule, error)
}

type InstanceIterator

type InstanceIterator interface {
	Next() (*computepb.Instance, error)
}

type Logger

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

func NewLogger

func NewLogger(ctx context.Context, providerID string, logName string) (*Logger, error)

NewLogger creates a new Cloud Logger for GCP. https://cloud.google.com/logging/docs/setup/go

func (*Logger) Close

func (l *Logger) Close() error

Close waits for all buffer to be written.

func (*Logger) Disclose

func (l *Logger) Disclose(msg string)

Disclose stores log information in GCP Cloud Logging! Do **NOT** log sensitive information!

type Metadata

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

Metadata implements core.ProviderMetadata interface.

func New

func New(api API) *Metadata

New creates a new Provider with real API and FS.

func (*Metadata) GetInstance

func (m *Metadata) GetInstance(ctx context.Context, providerID string) (metadata.InstanceMetadata, error)

GetInstance retrieves an instance using its providerID.

func (*Metadata) GetLoadBalancerEndpoint

func (m *Metadata) GetLoadBalancerEndpoint(ctx context.Context) (string, error)

GetLoadBalancerEndpoint returns the endpoint of the load balancer.

func (*Metadata) List

List retrieves all instances belonging to the current constellation.

func (*Metadata) Self

Self retrieves the current instance.

func (*Metadata) Supported

func (m *Metadata) Supported() bool

Supported is used to determine if metadata API is implemented for this cloud provider.

func (*Metadata) SupportsLoadBalancer

func (m *Metadata) SupportsLoadBalancer() bool

SupportsLoadBalancer returns true if the cloud provider supports load balancers.

func (*Metadata) UID

func (m *Metadata) UID(ctx context.Context) (string, error)

UID retrieves the UID of the constellation.

type Operation

type Operation interface {
	Proto() *computepb.Operation
}

type SubnetworkIterator

type SubnetworkIterator interface {
	Next() (*computepb.Subnetwork, error)
}

type Writer

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

Writer implements ConfigWriter.

func (*Writer) WriteGCEConf

func (w *Writer) WriteGCEConf(config string) error

WriteGCEConf persists the GCE config on disk.

Jump to

Keyboard shortcuts

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