snaputil

package
v0.0.0-...-664ceaa Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListControlPlaneNodeIPs

func ListControlPlaneNodeIPs(ctx context.Context, s snap.Snap) ([]string, error)

ListControlPlaneNodeIPs returns the internal IPs of the control plane nodes of the MicroK8s cluster.

func MaybePatchCalicoAutoDetectionMethod

func MaybePatchCalicoAutoDetectionMethod(ctx context.Context, s snap.Snap, canReachHost string, apply bool) error

MaybePatchCalicoAutoDetectionMethod attempts to update the calico cni.yaml to update the value of the IP_AUTODETECTION_METHOD option.

The default value is "first-found", which works well for single-node clusters. However, after adding a new node, we want to change this to `can-reach=canReachHost` to mitigate issues with multiple NICs.

If canReachHost is an IPv6 address, IP6_AUTODETECTION_METHOD is updated instead.

Optionally, the new manifest may be applied using the microk8s-kubectl.wrapper script.

func MaybeUpdateDqliteBindAddress

func MaybeUpdateDqliteBindAddress(ctx context.Context, snap snap.Snap, hostPort string, remoteIP string, findMatchingBindAddress func(string) (string, error)) error

MaybeUpdateDqliteBindAddress checks if the node is part of a dqlite cluster and updates it if necessary. It ensures the node's hostPort is included in the cluster configuration.

func UpdateDqliteIP

func UpdateDqliteIP(ctx context.Context, s snap.Snap, host string) error

UpdateDqliteIP sets the local dqlite cluster node to bind to a new IP address.

Types

type DqliteCluster

type DqliteCluster []DqliteClusterNode

DqliteCluster is the format of the dqlite cluster.yaml file.

func GetDqliteCluster

func GetDqliteCluster(s snap.Snap) (DqliteCluster, error)

GetDqliteCluster a list of all currently known dqlite cluster nodes.

func WaitForDqliteCluster

func WaitForDqliteCluster(ctx context.Context, s snap.Snap, f func(DqliteCluster) (bool, error)) (DqliteCluster, error)

WaitForDqliteCluster queries the dqlite cluster nodes repeatedly until f(cluster) becomes true.

type DqliteClusterNode

type DqliteClusterNode struct {
	// Address is the address of the node in the cluster.
	Address string `yaml:"Address"`
	// ID is the unique identifier of the node in the cluster.
	ID uint64 `yaml:"ID,omitempty"`
	// NodeRole is the role of the node in the cluster.
	// 0 -- Voter
	// 1 -- StandBy
	// 2 -- Spare
	NodeRole int `yaml:"Role,omitempty"`
}

DqliteClusterNode is a node in the dqlite cluster.

Jump to

Keyboard shortcuts

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