Documentation ¶
Overview ¶
Package common contains common definition and utils used across liqoctl
Index ¶
- Constants
- Variables
- func ExtractValueFromArgumentList(key string, argumentList []string) (string, error)
- func GetLiqoctlRestConf() (*rest.Config, error)
- func WaitForEventOnForeignCluster(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity, ...) error
- type Cluster
- func (c *Cluster) DeleteForeignCluster(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity) error
- func (c *Cluster) DisablePeering(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity) error
- func (c *Cluster) EnforceForeignCluster(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity, ...) error
- func (c *Cluster) ExchangeNetworkCfg(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity) error
- func (c *Cluster) GetAuthToken() string
- func (c *Cluster) GetAuthURL() string
- func (c *Cluster) GetClusterID() *discoveryv1alpha1.ClusterIdentity
- func (c *Cluster) GetLocTenantNS() string
- func (c *Cluster) GetProxyURL() string
- func (c *Cluster) Init(ctx context.Context) error
- func (c *Cluster) MapAuthIPForCluster(ctx context.Context, ipamClient ipam.IpamClient, ...) error
- func (c *Cluster) MapProxyIPForCluster(ctx context.Context, ipamClient ipam.IpamClient, ...) error
- func (c *Cluster) NewIPAMClient(ctx context.Context) (ipam.IpamClient, error)
- func (c *Cluster) PortForwardIPAM(ctx context.Context) error
- func (c *Cluster) SetRemTenantNS(remTenantNamespace string)
- func (c *Cluster) SetUpTenantNamespace(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity) error
- func (c *Cluster) StopPortForwardIPAM()
- func (c *Cluster) TearDownTenantNamespace(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity, ...) error
- func (c *Cluster) UnmapAuthIPForCluster(ctx context.Context, ipamClient ipam.IpamClient, ...) error
- func (c *Cluster) UnmapProxyIPForCluster(ctx context.Context, ipamClient ipam.IpamClient, ...) error
- func (c *Cluster) WaitForAuth(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity, ...) error
- func (c *Cluster) WaitForUnpeering(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity, ...) error
- type DefaultPortForwarder
- type Endpoint
- type PortForwardOptions
- type PortForwarder
- type Printer
- type WireGuardConfig
Constants ¶
const ( // Cluster1Name name used in output messages for cluster passed as first argument. Cluster1Name = "cluster1" // Cluster1Color color used in output messages for cluster passed as first argument. Cluster1Color = pterm.FgLightBlue // Cluster2Name name used in output messages for cluster passed as second argument. Cluster2Name = "cluster2" // Cluster2Color color used in output messages for cluster passed as second argument. Cluster2Color = pterm.FgLightMagenta )
const ( // UnpeeringEvent name of the unpeering event. UnpeeringEvent fcEventType = "unpeer" // AuthEvent name of the authentication event. AuthEvent fcEventType = "authentication" )
const LiqoctlLongHelp = `` /* 612-byte string literal not displayed */
LiqoctlLongHelp contains the long help message for root Liqoctl command.
const LiqoctlShortHelp = "liqoctl - the Liqo Command Line Interface"
LiqoctlShortHelp contains the short help message for root Liqoctl command.
Variables ¶
var ( // UnpeerChecker checks if the two clusters are unpeered. UnpeerChecker fcEventChecker = func(fc *discoveryv1alpha1.ForeignCluster) bool { return foreigncluster.IsIncomingPeeringNone(fc) && foreigncluster.IsOutgoingPeeringNone(fc) } // AuthChecker checks if the authentication has been completed. AuthChecker fcEventChecker = foreigncluster.IsAuthenticated )
var ( // GenericPrinter used to print generic output. GenericPrinter = pterm.PrefixPrinter{ Prefix: pterm.Prefix{}, Scope: pterm.Scope{ Text: "cmd", Style: pterm.NewStyle(pterm.FgGray), }, MessageStyle: pterm.NewStyle(pterm.FgDefault), } // SuccessPrinter used to print success output. SuccessPrinter = GenericPrinter.WithPrefix(pterm.Prefix{ Text: "[SUCCESS]", Style: pterm.NewStyle(pterm.FgGreen), }) // WarningPrinter used to print warning output. WarningPrinter = GenericPrinter.WithPrefix(pterm.Prefix{ Text: "[WARNING]", Style: pterm.NewStyle(pterm.FgYellow), }) // ErrorPrinter used to print error output. ErrorPrinter = GenericPrinter.WithPrefix(pterm.Prefix{ Text: "[ERROR]", Style: pterm.NewStyle(pterm.FgRed), }) )
var ( // Scheme used for the controller runtime clients. Scheme *runtime.Scheme )
Functions ¶
func ExtractValueFromArgumentList ¶
ExtractValueFromArgumentList extracts the argument value from an argument list.
func GetLiqoctlRestConf ¶ added in v0.3.1
GetLiqoctlRestConf gets a valid REST config and set a default value for the RateLimiters.
func WaitForEventOnForeignCluster ¶ added in v0.4.0
func WaitForEventOnForeignCluster(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity, event fcEventType, checker fcEventChecker, timeout time.Duration, cl client.Client) error
WaitForEventOnForeignCluster given the remote cluster identity if waits for the given event to be verified on the associated foreigncluster.
Types ¶
type Cluster ¶ added in v0.4.0
type Cluster struct { PortForwardOpts *PortForwardOptions // contains filtered or unexported fields }
Cluster struct that models a k8s cluster for connect and disconnect commands.
func NewCluster ¶ added in v0.4.0
func NewCluster(localK8sClient k8s.Interface, localCtrlRunClient, remoteCtrlRunClient client.Client, restConfig *rest.Config, namespace, name string, printerColor pterm.Color) *Cluster
NewCluster returns a new cluster object. The cluster has to be initialized before being consumed.
func (*Cluster) DeleteForeignCluster ¶ added in v0.4.0
func (c *Cluster) DeleteForeignCluster(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity) error
DeleteForeignCluster deletes the foreignclusters instance for the given remote cluster.
func (*Cluster) DisablePeering ¶ added in v0.4.0
func (c *Cluster) DisablePeering(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity) error
DisablePeering disables the peering for the remote cluster by patching the foreigncusters resource.
func (*Cluster) EnforceForeignCluster ¶ added in v0.4.0
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. 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;
- OutgoingPeeringEnabled -> Yes
- 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) ExchangeNetworkCfg ¶ added in v0.4.0
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 ¶ added in v0.4.0
GetAuthToken returns the authentication token of the local cluster.
func (*Cluster) GetAuthURL ¶ added in v0.4.0
GetAuthURL returns the authentication URL of the local cluster.
func (*Cluster) GetClusterID ¶ added in v0.4.0
func (c *Cluster) GetClusterID() *discoveryv1alpha1.ClusterIdentity
GetClusterID returns the cluster identity.
func (*Cluster) GetLocTenantNS ¶ added in v0.4.0
GetLocTenantNS returns the tenant namespace created for the remote cluster.
func (*Cluster) GetProxyURL ¶ added in v0.4.0
GetProxyURL returns the proxy URL of the local cluster.
func (*Cluster) MapAuthIPForCluster ¶ added in v0.4.0
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 ¶ added in v0.4.0
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 ¶ added in v0.4.0
NewIPAMClient creates and returns a client to the IPAM service.
func (*Cluster) PortForwardIPAM ¶ added in v0.4.0
PortForwardIPAM starts the port forwarding for the IPAM service.
func (*Cluster) SetRemTenantNS ¶ added in v0.4.0
SetRemTenantNS sets the tenant namespace of the local cluster created by the remote cluster.
func (*Cluster) SetUpTenantNamespace ¶ added in v0.4.0
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 ¶ added in v0.4.0
func (c *Cluster) StopPortForwardIPAM()
StopPortForwardIPAM stops the port forwarding for the IPAM service.
func (*Cluster) TearDownTenantNamespace ¶ added in v0.4.0
func (c *Cluster) TearDownTenantNamespace(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity, timeout time.Duration) error
TearDownTenantNamespace deletes the tenant namespace in the local cluster for the given remote cluster.
func (*Cluster) UnmapAuthIPForCluster ¶ added in v0.4.0
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 ¶ added in v0.4.0
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.
func (*Cluster) WaitForAuth ¶ added in v0.4.0
func (c *Cluster) WaitForAuth(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity, timeout time.Duration) error
WaitForAuth waits until the authentication has been established with the remote cluster or the timeout expires.
func (*Cluster) WaitForUnpeering ¶ added in v0.4.0
func (c *Cluster) WaitForUnpeering(ctx context.Context, remoteClusterID *discoveryv1alpha1.ClusterIdentity, timeout time.Duration) error
WaitForUnpeering waits until the status on the foreiglcusters resource states that the in/outgoing peering has been successfully set to None or the timeout expires.
type DefaultPortForwarder ¶ added in v0.4.0
type DefaultPortForwarder struct {
genericclioptions.IOStreams
}
DefaultPortForwarder default forwarder implementation used to forward ports.
func (*DefaultPortForwarder) ForwardPorts ¶ added in v0.4.0
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 ¶ added in v0.4.0
type Endpoint struct {
// contains filtered or unexported fields
}
Endpoint maps a service that has to be accessed by a remote cluster.
func (*Endpoint) GetHTTPSURL ¶ added in v0.4.0
GetHTTPSURL return the https url for the endpoint.
func (*Endpoint) GetHTTPURL ¶ added in v0.4.0
GetHTTPURL returns the http url for the endpoint.
func (*Endpoint) GetIP ¶ added in v0.4.0
GetIP returns the ip address that has on the cluster where the endpoint lives.
func (*Endpoint) SetRemappedIP ¶ added in v0.4.0
SetRemappedIP sets the ip address as seen by the remote cluster.
type PortForwardOptions ¶ added in v0.4.0
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 ¶ added in v0.4.0
func (o *PortForwardOptions) RunPortForward(ctx context.Context) error
RunPortForward starts the forwarding.
func (*PortForwardOptions) StopPortForward ¶ added in v0.4.0
func (o *PortForwardOptions) StopPortForward()
StopPortForward stops the forwarding.
type PortForwarder ¶ added in v0.4.0
type PortForwarder interface {
ForwardPorts(method string, podURL *url.URL, opts *PortForwardOptions) error
}
PortForwarder interface that a port forwarder needs to implement.
type Printer ¶ added in v0.4.0
type Printer struct { Info *pterm.PrefixPrinter Success *pterm.PrefixPrinter Warning *pterm.PrefixPrinter Error *pterm.PrefixPrinter Spinner *pterm.SpinnerPrinter InfoMessage string }
Printer manages all kinds of outputs.