Documentation
¶
Index ¶
- func IsTerminalError(err error) bool
- type Client
- func (c *Client) CreateAndWaitForInstance(ctx context.Context, instance api.InstancesPost) error
- func (c *Client) CreateInstance(ctx context.Context, machine *clusterv1.Machine, ...) ([]string, error)
- func (c *Client) CreateInstanceSnapshot(ctx context.Context, instanceName string, snapshotName string) error
- func (c *Client) DeleteInstance(ctx context.Context, lxcMachine *infrav1.LXCMachine) error
- func (c *Client) DeleteProfile(ctx context.Context, profileName string) error
- func (c *Client) ForceRemoveInstance(ctx context.Context, instanceName string) error
- func (c *Client) InitProfile(ctx context.Context, profile api.ProfilesPost) error
- func (c *Client) LoadBalancerManagerForCluster(cluster *clusterv1.Cluster, lxcCluster *infrav1.LXCCluster) LoadBalancerManager
- func (c *Client) ParseActiveMachineAddresses(state *api.InstanceState) []string
- func (c *Client) PublishImage(ctx context.Context, instanceName string, imageAliasName string, ...) error
- func (c *Client) RunCommand(ctx context.Context, instanceName string, command []string, stdin io.Reader, ...) error
- func (c *Client) StopInstance(ctx context.Context, name string) error
- func (c *Client) SupportsInstanceOCI() error
- func (c *Client) SupportsNetworkLoadBalancer() error
- type LoadBalancerManager
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTerminalError ¶
IsTerminalError checks whether the error is a terminalError. These are returned to indicate non-retriable errors.
Types ¶
type Client ¶
type Client struct {
Client incus.InstanceServer
}
func (*Client) CreateAndWaitForInstance ¶ added in v0.6.0
func (*Client) CreateInstance ¶
func (c *Client) CreateInstance(ctx context.Context, machine *clusterv1.Machine, lxcMachine *infrav1.LXCMachine, cluster *clusterv1.Cluster, lxcCluster *infrav1.LXCCluster, cloudInit string) ([]string, error)
CreateInstance creates the LXC instance based on configuration from the machine.
func (*Client) CreateInstanceSnapshot ¶ added in v0.6.0
func (*Client) DeleteInstance ¶
DeleteInstance deletes the matching LXC instance, if any.
func (*Client) DeleteProfile ¶
DeleteProfile deletes an LXC profile if it exists.
func (*Client) ForceRemoveInstance ¶ added in v0.6.0
func (*Client) InitProfile ¶
InitProfile creates an LXC profile if it does not already exist.
func (*Client) LoadBalancerManagerForCluster ¶
func (c *Client) LoadBalancerManagerForCluster(cluster *clusterv1.Cluster, lxcCluster *infrav1.LXCCluster) LoadBalancerManager
LoadBalancerManagerForCluster returns the proper LoadBalancerManager based on the lxcCluster spec.
func (*Client) ParseActiveMachineAddresses ¶
func (c *Client) ParseActiveMachineAddresses(state *api.InstanceState) []string
ParseActiveMachineAddresses returns the main IP addresses of the instance. It filters for networks that have a host interface name (e.g. vethbbcd39c7), so that CNI addresses are ignored. It filters for addresses with global scope, so that IPv6 link-local addresses are ignored.
func (*Client) PublishImage ¶ added in v0.6.0
func (*Client) RunCommand ¶
func (c *Client) RunCommand(ctx context.Context, instanceName string, command []string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error
RunCommand on a specified instance, and allow retrieving the stdout and stderr. It returns an error if execution failed.
func (*Client) StopInstance ¶ added in v0.6.0
func (*Client) SupportsInstanceOCI ¶
SupportsInstanceOCI checks if the necessary API extensions for OCI instances are supported by the server.
If instance_oci is not supported, a terminalError is returned.
func (*Client) SupportsNetworkLoadBalancer ¶
SupportsNetworkLoadBalancer checks if the necessary API extensions for Network Load Balancers are supported by the server.
If network_load_balancer or network_load_balancer_health_check are not supported, a terminalError is returned.
type LoadBalancerManager ¶
type LoadBalancerManager interface {
// Create provisions the load balancer instance.
// Implementations can indicate non-retriable failures (e.g. because of Incus not having the required extensions).
// Callers must check these with incus.IsTerminalError() and treat them as terminal failures.
Create(context.Context) ([]string, error)
// Delete cleans up any load balancer resources.
Delete(context.Context) error
// Reconfigure updates the load balancer configuration based on the currently running control plane instances.
Reconfigure(context.Context) error
// Inspect returns a map[string]string of the current state of the load balancer infrastructure.
// It is mainly used by the E2E tests.
Inspect(context.Context) map[string]string
}
LoadBalancerManager can be used to interact with the cluster load balancer.
type Options ¶
type Options struct {
// Server URL and certificate.
ServerURL string `yaml:"server"`
ServerCrt string `yaml:"server-crt"`
InsecureSkipVerify bool `yaml:"insecure-skip-verify"`
// Client certificate and key.
ClientCrt string `yaml:"client-crt"`
ClientKey string `yaml:"client-key"`
// Project name
Project string `yaml:"project"`
}
func NewOptionsFromConfigFile ¶
func NewOptionsFromConfigFile(configFile string, forceRemoteName string, requireHTTPS bool) (Options, error)
NewOptionsFromConfigFile attempts to load client options from the local node configuration.
func NewOptionsFromSecret ¶
NewOptionsFromSecret parses a Kubernetes secret and derives Options for connecting to Incus.
The secret can be created like this:
```bash
# create a client certificate and key trusted by incus $ incus remote generate-certificate $ sudo incus config trust add-certificate ~/.config/incus/client.crt # generate kubernetes secret $ kubectl create secret generic incus-secret \ --from-literal=server="https://10.0.0.49:8443" \ --from-literal=server-crt="$(sudo cat /var/lib/incus/cluster.crt)" \ --from-literal=client-crt="$(cat ~/.config/incus/client.crt)" \ --from-literal=client-key="$(cat ~/.config/incus/client.key)" \ --from-literal=project="default" # or with insecure skip verify $ kubectl create secret generic lxd-secret \ --from-literal=server=https://10.0.1.2:8901 \ --from-literal=insecure-skip-verify=true \ --from-literal=client-crt="$(cat ~/.config/incus/client.crt)" \ --from-literal=client-key="$(cat ~/.config/incus/client.key)" \ --from-literal=project="default"
```
Source Files
¶
- client.go
- client_options.go
- consts.go
- error.go
- lxc_extensions.go
- lxc_get_instance_address.go
- lxc_hack_builder_instances.go
- lxc_instance_create.go
- lxc_instance_delete.go
- lxc_load_balancer.go
- lxc_load_balancer_external.go
- lxc_load_balancer_lxc.go
- lxc_load_balancer_network.go
- lxc_load_balancer_oci.go
- lxc_profile.go
- lxc_run_command.go
- lxc_template_files.go
- lxc_util.go