azure

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Implements interaction with the Azure API.

Instance metadata is retrieved from the Azure IMDS API.

Retrieving metadata of other instances is done by using the Azure API, and requires Azure credentials.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cloud

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

Cloud provides Azure metadata and API access.

func New

func New(ctx context.Context) (*Cloud, error)

New initializes Cloud with the needed API clients. Default credentials are used for authentication.

func (*Cloud) GetLoadBalancerEndpoint

func (c *Cloud) GetLoadBalancerEndpoint(ctx context.Context) (host, port string, retErr error)

GetLoadBalancerEndpoint retrieves the first load balancer IP from cloud provider metadata.

The returned string is an IP address without a port, but the method name needs to satisfy the metadata interface.

func (*Cloud) InitSecretHash

func (c *Cloud) InitSecretHash(ctx context.Context) ([]byte, error)

InitSecretHash retrieves the InitSecretHash of the current instance.

func (*Cloud) List

func (c *Cloud) List(ctx context.Context) ([]metadata.InstanceMetadata, error)

List retrieves all instances belonging to the current constellation.

func (*Cloud) PrepareControlPlaneNode

func (c *Cloud) PrepareControlPlaneNode(ctx context.Context, log *slog.Logger) error

PrepareControlPlaneNode sets up iptables for the control plane node only if an internal load balancer is used.

This is needed since during `kubeadm init` the API server must talk to the kubeAPIEndpoint, which is the load balancer IP address. During that time, the only healthy VM is the VM itself. Therefore, traffic is sent to the load balancer and the 5-tuple is (VM IP, <some port>, LB IP, 6443, TCP). Now the load balancer does not re-write the source IP address only the destination (DNAT). Therefore the 5-tuple is (VM IP, <some port>, VM IP, 6443, TCP). Now the VM responds to the SYN packet with a SYN-ACK packet, but the outgoing connection waits on a response from the load balancer and not the VM therefore dropping the packet.

OpenShift also uses the same mechanism to redirect traffic to the API server: https://github.com/openshift/machine-config-operator/blob/e453bd20bac0e48afa74e9a27665abaf454d93cd/templates/master/00-master/azure/files/opt-libexec-openshift-azure-routes-sh.yaml

func (*Cloud) Self

Self retrieves the current instance.

func (*Cloud) UID

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

UID retrieves the UID of the constellation.

type IMDSClient

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

IMDSClient is a client for the Azure Instance Metadata Service.

func NewIMDSClient

func NewIMDSClient() *IMDSClient

NewIMDSClient creates a new IMDSClient.

func (*IMDSClient) Tags

func (c *IMDSClient) Tags(ctx context.Context) (map[string]string, error)

Tags returns the tags of the instance the function is called from.

Jump to

Keyboard shortcuts

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