inband

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Overview

Package inband contains common functions used for the in-band peer and unpeer commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	Waiter *wait.Waiter

	PortForwardOpts *PortForwardOptions
	// contains filtered or unexported fields
}

Cluster struct that models a k8s cluster for connect and disconnect commands.

func NewCluster

func NewCluster(local, remote *factory.Factory) *Cluster

NewCluster returns a new cluster object. The cluster has to be initialized before being consumed.

func (*Cluster) CheckForeignCluster

func (c *Cluster) CheckForeignCluster(ctx context.Context, remoteIdentity *discoveryv1alpha1.ClusterIdentity) (err error)

CheckForeignCluster retrieves the ForeignCluster resource associated with the remote cluster (if any), and stores it for later usage. Additionally, it performs the appropriate sanity checks, ensuring that the type of peering is not mutated.

func (*Cluster) DeleteForeignCluster

func (c *Cluster) DeleteForeignCluster(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity) error

DeleteForeignCluster deletes the foreignclusters instance for the given remote cluster.

func (*Cluster) DisablePeering

func (c *Cluster) DisablePeering(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity, incoming bool) (err error)

DisablePeering disables the peering for the remote cluster by patching the foreigncusters resource.

func (*Cluster) EnforceForeignCluster

func (c *Cluster) EnforceForeignCluster(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity,
	token, authURL, proxyURL string) error

EnforceForeignCluster enforces the presence of the foreignclusters instance for a given remote cluster. This function must be executed after CheckForeignCluster, which retrieves the ForeignCluster and performs the appropriate sanity checks. The newly created foreigncluster has the following fields set to:

  • ForeignAuthURL -> the remapped ip address for the local cluster of the auth service living in the remote cluster;
  • ForeignProxyURL -> the remapped ip address for the local cluster of the proxy service living in the remote cluster;
  • NetworkingEnabled -> No, we do not want the networking to be handled by the peering process. Networking is handled manually by the licoctl connect/disconnect commands.

func (*Cluster) EnforceIncomingPeeringFlag added in v0.10.2

func (c *Cluster) EnforceIncomingPeeringFlag(ctx context.Context, remoteID *discoveryv1alpha1.ClusterIdentity, enabled bool) error

EnforceIncomingPeeringFlag sets the incoming peering flag for a given foreign cluster.

func (*Cluster) EnforceOutgoingPeeringFlag added in v0.7.0

func (c *Cluster) EnforceOutgoingPeeringFlag(ctx context.Context, remoteID *discoveryv1alpha1.ClusterIdentity, enabled bool) error

EnforceOutgoingPeeringFlag sets the outgoing peering flag for a given foreign cluster.

func (*Cluster) ExchangeNetworkCfg

func (c *Cluster) ExchangeNetworkCfg(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity) error

ExchangeNetworkCfg creates the local networkconfigs resource for the remote cluster, replicates it into the remote cluster, waits for the remote cluster to populate the status of the resource and then sets the remote status in the local networkconfigs resource.

func (*Cluster) GetAuthToken

func (c *Cluster) GetAuthToken() string

GetAuthToken returns the authentication token of the local cluster.

func (*Cluster) GetAuthURL

func (c *Cluster) GetAuthURL() string

GetAuthURL returns the authentication URL of the local cluster.

func (*Cluster) GetClusterID

func (c *Cluster) GetClusterID() *discoveryv1alpha1.ClusterIdentity

GetClusterID returns the cluster identity.

func (*Cluster) GetLocTenantNS

func (c *Cluster) GetLocTenantNS() string

GetLocTenantNS returns the tenant namespace created for the remote cluster.

func (*Cluster) GetProxyURL

func (c *Cluster) GetProxyURL() string

GetProxyURL returns the proxy URL of the local cluster.

func (*Cluster) Init

func (c *Cluster) Init(ctx context.Context) error

Init initializes the cluster struct.

func (*Cluster) MapAuthIPForCluster

func (c *Cluster) MapAuthIPForCluster(ctx context.Context, ipamClient ipam.IpamClient, remoteCluster *discoveryv1alpha1.ClusterIdentity) error

MapAuthIPForCluster maps the ClusterIP address of the local auth service on the local external CIDR as seen by the remote cluster.

func (*Cluster) MapProxyIPForCluster

func (c *Cluster) MapProxyIPForCluster(ctx context.Context, ipamClient ipam.IpamClient, remoteCluster *discoveryv1alpha1.ClusterIdentity) error

MapProxyIPForCluster maps the ClusterIP address of the local proxy on the local external CIDR as seen by the remote cluster.

func (*Cluster) NewIPAMClient

func (c *Cluster) NewIPAMClient(ctx context.Context) (ipam.IpamClient, error)

NewIPAMClient creates and returns a client to the IPAM service.

func (*Cluster) PortForwardIPAM

func (c *Cluster) PortForwardIPAM(ctx context.Context) error

PortForwardIPAM starts the port forwarding for the IPAM service.

func (*Cluster) SetRemTenantNS

func (c *Cluster) SetRemTenantNS(remTenantNamespace string)

SetRemTenantNS sets the tenant namespace of the local cluster created by the remote cluster.

func (*Cluster) SetUpTenantNamespace

func (c *Cluster) SetUpTenantNamespace(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity) error

SetUpTenantNamespace creates the tenant namespace in the local custer for the given remote cluster.

func (*Cluster) StopPortForwardIPAM

func (c *Cluster) StopPortForwardIPAM()

StopPortForwardIPAM stops the port forwarding for the IPAM service.

func (*Cluster) TearDownTenantNamespace

func (c *Cluster) TearDownTenantNamespace(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity) error

TearDownTenantNamespace deletes the tenant namespace in the local cluster for the given remote cluster.

func (*Cluster) UnmapAuthIPForCluster

func (c *Cluster) UnmapAuthIPForCluster(ctx context.Context, ipamClient ipam.IpamClient, remoteCluster *discoveryv1alpha1.ClusterIdentity) error

UnmapAuthIPForCluster unmaps the ClusterIP address of the local auth service on the local external CIDR as seen by the remote cluster.

func (*Cluster) UnmapProxyIPForCluster

func (c *Cluster) UnmapProxyIPForCluster(ctx context.Context, ipamClient ipam.IpamClient, remoteCluster *discoveryv1alpha1.ClusterIdentity) error

UnmapProxyIPForCluster unmaps the ClusterIP address of the local proxy on the local external CIDR as seen by the remote cluster.

type DefaultPortForwarder

type DefaultPortForwarder struct {
	genericclioptions.IOStreams
}

DefaultPortForwarder default forwarder implementation used to forward ports.

func (*DefaultPortForwarder) ForwardPorts

func (f *DefaultPortForwarder) ForwardPorts(method string, podURL *url.URL, opt *PortForwardOptions) error

ForwardPorts forwards the ports given in the options for the given pod url.

type Endpoint

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

Endpoint maps a service that has to be accessed by a remote cluster.

func (*Endpoint) GetHTTPSURL

func (ep *Endpoint) GetHTTPSURL() string

GetHTTPSURL return the https url for the endpoint.

func (*Endpoint) GetHTTPURL

func (ep *Endpoint) GetHTTPURL() string

GetHTTPURL returns the http url for the endpoint.

func (*Endpoint) GetIP

func (ep *Endpoint) GetIP() string

GetIP returns the ip address that has on the cluster where the endpoint lives.

func (*Endpoint) SetRemappedIP

func (ep *Endpoint) SetRemappedIP(ip string)

SetRemappedIP sets the ip address as seen by the remote cluster.

type PortForwardOptions

type PortForwardOptions struct {
	Namespace     string
	Selector      *metav1.LabelSelector
	Config        *restclient.Config
	Client        client.Client
	PortForwarder PortForwarder
	RemotePort    int
	LocalPort     int
	Ports         []string
	StopChannel   chan struct{}
	ReadyChannel  chan struct{}
}

PortForwardOptions contains all the options in order to port-forward a pod's port.

func (*PortForwardOptions) RunPortForward

func (o *PortForwardOptions) RunPortForward(ctx context.Context) error

RunPortForward starts the forwarding.

func (*PortForwardOptions) StopPortForward

func (o *PortForwardOptions) StopPortForward()

StopPortForward stops the forwarding.

type PortForwarder

type PortForwarder interface {
	ForwardPorts(method string, podURL *url.URL, opts *PortForwardOptions) error
}

PortForwarder interface that a port forwarder needs to implement.

type WireGuardConfig

type WireGuardConfig struct {
	PubKey       string
	EndpointIP   string
	EndpointPort string
	BackEndType  string
}

WireGuardConfig holds the WireGuard configuration.

Jump to

Keyboard shortcuts

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