netbird

package
v0.8.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// BootstrapSecretType is the type for CAPI bootstrap secrets
	BootstrapSecretType = "cluster.x-k8s.io/secret"

	// PatchedAnnotation marks secrets that have been patched
	PatchedAnnotation = "netbird.exalsius.ai/join-url-patched"

	// PatchedAnnotationValue is the value for the patched annotation
	PatchedAnnotationValue = "true"

	// NetBirdCleanupFinalizer is added to RemoteMachines that have NetBird installed
	NetBirdCleanupFinalizer = "netbird.exalsius.ai/cleanup"

	// ClusterNameLabel is the label for cluster name
	ClusterNameLabel = "cluster.x-k8s.io/cluster-name"

	// K0sTokenPath is the path to the k0s token file in cloud-init
	K0sTokenPath = "/etc/k0s.token"
)

Variables

This section is empty.

Functions

func CleanupNetBirdResources

func CleanupNetBirdResources(ctx context.Context, c client.Client, nbClient *NetBirdClient, colony *infrav1.Colony) error

CleanupNetBirdResources cleans up NetBird resources when a Colony is deleted.

func DeletePatchedBootstrapSecretsForCluster added in v0.4.6

func DeletePatchedBootstrapSecretsForCluster(
	ctx context.Context,
	c client.Client,
	colony *infrav1.Colony,
	clusterName string,
) error

DeletePatchedBootstrapSecretsForCluster deletes all patched bootstrap secrets for a specific cluster This is used during cluster cleanup to ensure secrets are removed before ClusterDeployment deletion

func GetSetupKeyFromSecret

func GetSetupKeyFromSecret(ctx context.Context, c client.Client, colony *infrav1.Colony) (string, error)

GetSetupKeyFromSecret retrieves the NetBird setup key from a Secret. It uses the auto-generated secret name from status, or constructs the expected name.

func PatchBootstrapSecretsForCluster

func PatchBootstrapSecretsForCluster(
	ctx context.Context,
	c client.Client,
	colony *infrav1.Colony,
	clusterName string,
) error

PatchBootstrapSecretsForCluster patches all bootstrap secrets for a specific cluster to replace URLs with the appropriate endpoint (LoadBalancer external or internal DNS).

func ReconcileNetBird

func ReconcileNetBird(ctx context.Context, c client.Client, colony *infrav1.Colony, scheme *runtime.Scheme) error

ReconcileNetBird reconciles NetBird integration for a Colony.

func SecretToColonyMapper

func SecretToColonyMapper(c client.Client) func(context.Context, client.Object) []ctrl.Request

SecretToColonyMapper maps a Secret to Colony reconcile requests This is used in the controller's Watch configuration

func WatchAndPatchBootstrapSecrets

func WatchAndPatchBootstrapSecrets(
	ctx context.Context,
	c client.Client,
	colony *infrav1.Colony,
) error

WatchAndPatchBootstrapSecrets watches for new bootstrap secrets and patches them This can be called from the Colony reconciler after control plane exposure

Types

type Group added in v0.4.3

type Group struct {
	ID    string        `json:"id"`
	Name  string        `json:"name"`
	Peers []PeerMinimum `json:"peers,omitempty"`
}

Group represents a NetBird group

type GroupCreateRequest added in v0.4.3

type GroupCreateRequest struct {
	Name string `json:"name"`
}

GroupCreateRequest represents a request to create a group

type GroupRef added in v0.4.3

type GroupRef struct {
	ID             string `json:"id"`
	Name           string `json:"name"`
	PeersCount     int    `json:"peers_count"`
	ResourcesCount int    `json:"resources_count"`
}

GroupRef represents a group reference in API responses

type GroupRequest added in v0.4.3

type GroupRequest struct {
	Name  string    `json:"name"`
	Peers *[]string `json:"peers,omitempty"`
}

GroupRequest represents a request to update a group

type NetBirdClient added in v0.4.3

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

NetBirdClient is an HTTP client for the NetBird Management API

func GetNetBirdClientFromSecrets

func GetNetBirdClientFromSecrets(ctx context.Context, c client.Client, colony *infrav1.Colony) (*NetBirdClient, error)

GetNetBirdClientFromSecrets retrieves the NetBird API key from a Secret and creates a NetBird client.

func NewNetBirdClient added in v0.4.3

func NewNetBirdClient(baseURL, apiKey string) *NetBirdClient

NewNetBirdClient creates a new NetBird HTTP client

func (*NetBirdClient) CreateGroup added in v0.4.3

func (c *NetBirdClient) CreateGroup(ctx context.Context, name string) (Group, error)

CreateGroup creates a new group

func (*NetBirdClient) CreateNetwork added in v0.4.3

func (c *NetBirdClient) CreateNetwork(ctx context.Context, name, description string) (Network, error)

CreateNetwork creates a new network

func (*NetBirdClient) CreateNetworkResource added in v0.4.3

func (c *NetBirdClient) CreateNetworkResource(ctx context.Context, networkID string, request NetworkResourceRequest) (NetworkResource, error)

CreateNetworkResource creates a new network resource

func (*NetBirdClient) CreateNetworkRouter added in v0.4.3

func (c *NetBirdClient) CreateNetworkRouter(ctx context.Context, networkID string, request NetworkRouterRequest) (NetworkRouter, error)

CreateNetworkRouter creates a new network router

func (*NetBirdClient) CreatePolicy added in v0.4.3

func (c *NetBirdClient) CreatePolicy(ctx context.Context, request PolicyRequest) (Policy, error)

CreatePolicy creates a new policy

func (*NetBirdClient) CreateSetupKey added in v0.4.3

func (c *NetBirdClient) CreateSetupKey(ctx context.Context, request SetupKeyRequest) (SetupKey, error)

CreateSetupKey creates a new setup key

func (*NetBirdClient) DeleteGroup added in v0.4.3

func (c *NetBirdClient) DeleteGroup(ctx context.Context, groupID string) error

DeleteGroup deletes a group

func (*NetBirdClient) DeleteNetwork added in v0.4.5

func (c *NetBirdClient) DeleteNetwork(ctx context.Context, networkID string) error

DeleteNetwork deletes a network

func (*NetBirdClient) DeleteNetworkResource added in v0.4.3

func (c *NetBirdClient) DeleteNetworkResource(ctx context.Context, networkID, resourceID string) error

DeleteNetworkResource deletes a network resource

func (*NetBirdClient) DeleteNetworkRouter added in v0.4.3

func (c *NetBirdClient) DeleteNetworkRouter(ctx context.Context, networkID, routerID string) error

DeleteNetworkRouter deletes a network router

func (*NetBirdClient) DeletePeer added in v0.4.5

func (c *NetBirdClient) DeletePeer(ctx context.Context, peerID string) error

DeletePeer deletes a peer

func (*NetBirdClient) DeletePolicy added in v0.4.3

func (c *NetBirdClient) DeletePolicy(ctx context.Context, policyID string) error

DeletePolicy deletes a policy

func (*NetBirdClient) DeleteSetupKey added in v0.4.3

func (c *NetBirdClient) DeleteSetupKey(ctx context.Context, keyID string) error

DeleteSetupKey deletes a setup key

func (*NetBirdClient) GetGroup added in v0.4.3

func (c *NetBirdClient) GetGroup(ctx context.Context, groupID string) (Group, error)

GetGroup gets a group by ID

func (*NetBirdClient) GetNetwork added in v0.4.3

func (c *NetBirdClient) GetNetwork(ctx context.Context, networkID string) (Network, error)

GetNetwork gets a network by ID

func (*NetBirdClient) GetNetworkResource added in v0.4.3

func (c *NetBirdClient) GetNetworkResource(ctx context.Context, networkID, resourceID string) (NetworkResource, error)

GetNetworkResource gets a network resource by ID

func (*NetBirdClient) ListGroups added in v0.4.3

func (c *NetBirdClient) ListGroups(ctx context.Context) ([]Group, error)

ListGroups lists all groups

func (*NetBirdClient) ListNetworkResources added in v0.4.3

func (c *NetBirdClient) ListNetworkResources(ctx context.Context, networkID string) ([]NetworkResource, error)

ListNetworkResources lists all resources for a network

func (*NetBirdClient) ListNetworkRouters added in v0.4.3

func (c *NetBirdClient) ListNetworkRouters(ctx context.Context, networkID string) ([]NetworkRouter, error)

ListNetworkRouters lists all routers for a network

func (*NetBirdClient) ListNetworks added in v0.4.3

func (c *NetBirdClient) ListNetworks(ctx context.Context) ([]Network, error)

ListNetworks lists all networks

func (*NetBirdClient) ListPeers added in v0.4.3

func (c *NetBirdClient) ListPeers(ctx context.Context) ([]Peer, error)

ListPeers lists all peers

func (*NetBirdClient) ListPolicies added in v0.4.3

func (c *NetBirdClient) ListPolicies(ctx context.Context) ([]Policy, error)

ListPolicies lists all policies

func (*NetBirdClient) ListSetupKeys added in v0.4.3

func (c *NetBirdClient) ListSetupKeys(ctx context.Context) ([]SetupKey, error)

ListSetupKeys lists all setup keys

func (*NetBirdClient) UpdateGroup added in v0.4.3

func (c *NetBirdClient) UpdateGroup(ctx context.Context, groupID, name string, peerIDs []string) (Group, error)

UpdateGroup updates a group

func (*NetBirdClient) UpdateNetworkResource added in v0.4.3

func (c *NetBirdClient) UpdateNetworkResource(ctx context.Context, networkID, resourceID string, request NetworkResourceRequest) (NetworkResource, error)

UpdateNetworkResource updates a network resource

func (*NetBirdClient) UpdateNetworkRouter added in v0.4.3

func (c *NetBirdClient) UpdateNetworkRouter(ctx context.Context, networkID, routerID string, request NetworkRouterRequest) (NetworkRouter, error)

UpdateNetworkRouter updates a network router

func (*NetBirdClient) UpdatePolicy added in v0.4.3

func (c *NetBirdClient) UpdatePolicy(ctx context.Context, policyID string, request PolicyRequest) (Policy, error)

UpdatePolicy updates a policy

type Network added in v0.4.3

type Network struct {
	ID          string  `json:"id"`
	Name        string  `json:"name"`
	Description *string `json:"description,omitempty"`
}

Network represents a NetBird network

type NetworkRequest added in v0.4.3

type NetworkRequest struct {
	Name        string  `json:"name"`
	Description *string `json:"description,omitempty"`
}

NetworkRequest represents a request to create a network

type NetworkResource added in v0.4.3

type NetworkResource struct {
	ID          string     `json:"id"`
	Name        string     `json:"name"`
	Address     string     `json:"address"`
	Enabled     bool       `json:"enabled"`
	Groups      []GroupRef `json:"groups,omitempty"`
	Description *string    `json:"description,omitempty"`
	Type        *string    `json:"type,omitempty"`
}

NetworkResource represents a NetBird network resource (API response)

type NetworkResourceRequest added in v0.4.3

type NetworkResourceRequest struct {
	Name        string   `json:"name"`
	Address     string   `json:"address"`
	Enabled     bool     `json:"enabled"`
	Groups      []string `json:"groups,omitempty"`
	Description *string  `json:"description,omitempty"`
}

NetworkResourceRequest represents a request to create or update a network resource

type NetworkRouter added in v0.4.3

type NetworkRouter struct {
	ID         string    `json:"id"`
	Enabled    bool      `json:"enabled"`
	Masquerade bool      `json:"masquerade"`
	Metric     int       `json:"metric"`
	PeerGroups *[]string `json:"peer_groups,omitempty"`
	Peer       *string   `json:"peer,omitempty"`
}

NetworkRouter represents a NetBird network router

type NetworkRouterRequest added in v0.4.3

type NetworkRouterRequest struct {
	Enabled    bool      `json:"enabled"`
	Masquerade bool      `json:"masquerade"`
	Metric     int       `json:"metric"`
	PeerGroups *[]string `json:"peer_groups,omitempty"`
	Peer       *string   `json:"peer,omitempty"`
}

NetworkRouterRequest represents a request to create or update a network router

type Peer added in v0.4.3

type Peer struct {
	ID       string     `json:"id"`
	Hostname string     `json:"hostname"`
	IP       string     `json:"ip"`
	Groups   []GroupRef `json:"groups,omitempty"`
}

Peer represents a NetBird peer

type PeerMinimum added in v0.4.3

type PeerMinimum struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

PeerMinimum represents a minimal peer object in API responses

type Policy added in v0.4.3

type Policy struct {
	ID          *string      `json:"id,omitempty"`
	Name        string       `json:"name"`
	Description *string      `json:"description,omitempty"`
	Enabled     bool         `json:"enabled"`
	Rules       []PolicyRule `json:"rules"`
}

Policy represents a NetBird policy (API response)

type PolicyRequest added in v0.4.3

type PolicyRequest struct {
	Name        string              `json:"name"`
	Description *string             `json:"description,omitempty"`
	Enabled     bool                `json:"enabled"`
	Rules       []PolicyRuleRequest `json:"rules"`
}

PolicyRequest represents a request to create or update a policy

type PolicyRule added in v0.4.3

type PolicyRule struct {
	ID            *string     `json:"id,omitempty"`
	Name          string      `json:"name"`
	Description   *string     `json:"description,omitempty"`
	Enabled       bool        `json:"enabled"`
	Action        string      `json:"action"`
	Protocol      string      `json:"protocol"`
	Sources       *[]GroupRef `json:"sources,omitempty"`
	Destinations  *[]GroupRef `json:"destinations,omitempty"`
	Bidirectional bool        `json:"bidirectional"`
}

PolicyRule represents a rule within a policy (API response)

type PolicyRuleRequest added in v0.4.3

type PolicyRuleRequest struct {
	Name          string    `json:"name"`
	Description   *string   `json:"description,omitempty"`
	Enabled       bool      `json:"enabled"`
	Action        string    `json:"action"`
	Protocol      string    `json:"protocol"`
	Sources       *[]string `json:"sources,omitempty"`
	Destinations  *[]string `json:"destinations,omitempty"`
	Bidirectional bool      `json:"bidirectional"`
}

PolicyRuleRequest represents a rule for create/update requests

type SetupKey added in v0.4.3

type SetupKey struct {
	ID         string   `json:"id"`
	Key        string   `json:"key"`
	Name       string   `json:"name"`
	Type       string   `json:"type"`
	Expires    string   `json:"expires"`
	Valid      bool     `json:"valid"`
	Revoked    bool     `json:"revoked"`
	UsedTimes  int      `json:"used_times"`
	LastUsed   string   `json:"last_used"`
	State      string   `json:"state"`
	AutoGroups []string `json:"auto_groups,omitempty"`
	UpdatedAt  string   `json:"updated_at"`
	UsageLimit int      `json:"usage_limit"`
	Ephemeral  bool     `json:"ephemeral"`
}

SetupKey represents a NetBird setup key (API response)

type SetupKeyRequest added in v0.4.3

type SetupKeyRequest struct {
	AutoGroups []string `json:"auto_groups,omitempty"`
	Ephemeral  *bool    `json:"ephemeral,omitempty"`
	Name       string   `json:"name"`
	Type       string   `json:"type"`
	ExpiresIn  int64    `json:"expires_in"`
	UsageLimit int      `json:"usage_limit"`
}

SetupKeyRequest represents a request to create a setup key

Jump to

Keyboard shortcuts

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