Documentation
¶
Index ¶
- Constants
- func CleanupNetBirdResources(ctx context.Context, c client.Client, nbClient *NetBirdClient, ...) error
- func GetSetupKeyFromSecret(ctx context.Context, c client.Client, colony *infrav1.Colony) (string, error)
- func PatchBootstrapSecretsForCluster(ctx context.Context, c client.Client, colony *infrav1.Colony, ...) error
- func ReconcileNetBird(ctx context.Context, c client.Client, colony *infrav1.Colony, ...) error
- func SecretToColonyMapper(c client.Client) func(context.Context, client.Object) []ctrl.Request
- func WatchAndPatchBootstrapSecrets(ctx context.Context, c client.Client, colony *infrav1.Colony) error
- type Group
- type GroupCreateRequest
- type GroupRef
- type GroupRequest
- type NetBirdClient
- func (c *NetBirdClient) CreateGroup(ctx context.Context, name string) (Group, error)
- func (c *NetBirdClient) CreateNetwork(ctx context.Context, name, description string) (Network, error)
- func (c *NetBirdClient) CreateNetworkResource(ctx context.Context, networkID string, request NetworkResourceRequest) (NetworkResource, error)
- func (c *NetBirdClient) CreateNetworkRouter(ctx context.Context, networkID string, request NetworkRouterRequest) (NetworkRouter, error)
- func (c *NetBirdClient) CreatePolicy(ctx context.Context, request PolicyRequest) (Policy, error)
- func (c *NetBirdClient) CreateSetupKey(ctx context.Context, request SetupKeyRequest) (SetupKey, error)
- func (c *NetBirdClient) DeleteGroup(ctx context.Context, groupID string) error
- func (c *NetBirdClient) DeleteNetworkResource(ctx context.Context, networkID, resourceID string) error
- func (c *NetBirdClient) DeleteNetworkRouter(ctx context.Context, networkID, routerID string) error
- func (c *NetBirdClient) DeletePolicy(ctx context.Context, policyID string) error
- func (c *NetBirdClient) DeleteSetupKey(ctx context.Context, keyID string) error
- func (c *NetBirdClient) GetGroup(ctx context.Context, groupID string) (Group, error)
- func (c *NetBirdClient) GetNetwork(ctx context.Context, networkID string) (Network, error)
- func (c *NetBirdClient) GetNetworkResource(ctx context.Context, networkID, resourceID string) (NetworkResource, error)
- func (c *NetBirdClient) ListGroups(ctx context.Context) ([]Group, error)
- func (c *NetBirdClient) ListNetworkResources(ctx context.Context, networkID string) ([]NetworkResource, error)
- func (c *NetBirdClient) ListNetworkRouters(ctx context.Context, networkID string) ([]NetworkRouter, error)
- func (c *NetBirdClient) ListNetworks(ctx context.Context) ([]Network, error)
- func (c *NetBirdClient) ListPeers(ctx context.Context) ([]Peer, error)
- func (c *NetBirdClient) ListPolicies(ctx context.Context) ([]Policy, error)
- func (c *NetBirdClient) ListSetupKeys(ctx context.Context) ([]SetupKey, error)
- func (c *NetBirdClient) UpdateGroup(ctx context.Context, groupID, name string, peerIDs []string) (Group, error)
- func (c *NetBirdClient) UpdateNetworkResource(ctx context.Context, networkID, resourceID string, ...) (NetworkResource, error)
- func (c *NetBirdClient) UpdateNetworkRouter(ctx context.Context, networkID, routerID string, request NetworkRouterRequest) (NetworkRouter, error)
- func (c *NetBirdClient) UpdatePolicy(ctx context.Context, policyID string, request PolicyRequest) (Policy, error)
- type Network
- type NetworkRequest
- type NetworkResource
- type NetworkResourceRequest
- type NetworkRouter
- type NetworkRouterRequest
- type Peer
- type PeerMinimum
- type Policy
- type PolicyRequest
- type PolicyRule
- type PolicyRuleRequest
- type SetupKey
- type SetupKeyRequest
Constants ¶
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" // 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 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 ¶
SecretToColonyMapper maps a Secret to Colony reconcile requests This is used in the controller's Watch configuration
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
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
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) 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) 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) GetNetwork ¶ added in v0.4.3
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
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