services

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTooManyIPs         = errors.New("too many IPs in this ACL, will exceed rules per firewall limit")
	ErrTooManyNBFirewalls = errors.New("too many firewalls attached to a nodebalancer")
	ErrInvalidFWConfig    = errors.New("specify either an allowList or a denyList for a firewall")
)
View Source
var (
	Mu sync.RWMutex
	// VpcIDs map stores vpc id's for given vpc labels
	VpcIDs = make(map[string]int, 0)
	// SubnetIDs map stores subnet id's for given subnet labels
	SubnetIDs = make(map[string]int, 0)
)

Functions

func CreateFirewallOptsForSvc

func CreateFirewallOptsForSvc(label string, tags []string, svc *v1.Service) (*linodego.FirewallCreateOptions, error)

func GetAllVPCIDs

func GetAllVPCIDs() []int

GetAllVPCIDs returns vpc ids stored in map

func GetNodeBalancerBackendIPv4SubnetID

func GetNodeBalancerBackendIPv4SubnetID(client client.Client) (int, error)

GetNodeBalancerBackendIPv4SubnetID returns the subnet ID for the NodeBalancer backend IPv4 subnet. It uses the first VPC name from Options.VPCNames to find the VPC ID and then retrieves the subnet ID for the NodeBalancer backend IPv4 subnet name specified in Options.NodeBalancerBackendIPv4SubnetName.

func GetSubnetID

func GetSubnetID(ctx context.Context, client client.Client, vpcID int, subnetName string) (int, error)

GetSubnetID returns the subnet ID of given subnet label

func GetVPCID

func GetVPCID(ctx context.Context, client client.Client, vpcName string) (int, error)

GetVPCID returns the VPC id of given VPC label

func GetVPCIPAddresses

func GetVPCIPAddresses(ctx context.Context, client client.Client, vpcName string) ([]linodego.VPCIP, error)

GetVPCIPAddresses returns vpc ip's for given VPC label

func GetVPCIPv6Addresses

func GetVPCIPv6Addresses(ctx context.Context, client client.Client, vpcName string) ([]linodego.VPCIP, error)

func ValidateAndSetVPCSubnetFlags

func ValidateAndSetVPCSubnetFlags(client client.Client) error

ValidateAndSetVPCSubnetFlags validates the VPC and subnet flags and sets the vpcNames and subnetNames options. It retrieves the VPC names and subnet names from the Linode API based on the provided flags. If subnet IDs are provided, it resolves the subnet names based on the first VPC ID.

Types

type Instances

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

func NewInstances

func NewInstances(client client.Client) *Instances

NewInstances creates a new Instances cache with a specified TTL for the nodeCache.

func (*Instances) InstanceExists

func (i *Instances) InstanceExists(ctx context.Context, node *v1.Node) (bool, error)

func (*Instances) InstanceMetadata

func (i *Instances) InstanceMetadata(ctx context.Context, node *v1.Node) (*cloudprovider.InstanceMetadata, error)

func (*Instances) InstanceShutdown

func (i *Instances) InstanceShutdown(ctx context.Context, node *v1.Node) (bool, error)

func (*Instances) ListAllInstances

func (i *Instances) ListAllInstances(ctx context.Context) ([]linodego.Instance, error)

ListAllInstances returns all instances in nodeCache

func (*Instances) LookupLinode

func (i *Instances) LookupLinode(ctx context.Context, node *v1.Node) (*linodego.Instance, error)

LookupLinode looks up a Linode instance by its ProviderID or NodeName.

type LinodeClient

type LinodeClient struct {
	Client client.Client
}

func (*LinodeClient) CreateFirewall

func (l *LinodeClient) CreateFirewall(ctx context.Context, opts linodego.FirewallCreateOptions) (fw *linodego.Firewall, err error)

func (*LinodeClient) DeleteFirewall

func (l *LinodeClient) DeleteFirewall(ctx context.Context, firewall *linodego.Firewall) error

func (*LinodeClient) DeleteNodeBalancerFirewall

func (l *LinodeClient) DeleteNodeBalancerFirewall(
	ctx context.Context,
	service *v1.Service,
	nb *linodego.NodeBalancer,
) error

func (*LinodeClient) UpdateNodeBalancerFirewall

func (l *LinodeClient) UpdateNodeBalancerFirewall(
	ctx context.Context,
	loadBalancerName string,
	loadBalancerTags []string,
	service *v1.Service,
	nb *linodego.NodeBalancer,
) error

UpdateNodeBalancerFirewall reconciles the firewall attached to the nodebalancer

This function does the following

  1. If a firewallID annotation is present, it checks if the nodebalancer has a firewall attached, and if it matches the annotationID a. If the IDs match, nothing to do here. b. If they don't match, the nb is attached to the new firewall and removed from the old one.
  2. If a firewallACL annotation is present, a. it checks if the nodebalancer has a firewall attached, if a fw exists, it updates rules b. if a fw does not exist, it creates one
  3. If neither of these annotations are present, a. AND if no firewalls are attached to the nodebalancer, nothing to do. b. if the NB has ONE firewall attached, remove it from nb, and clean up if nothing else is attached to it c. If there are more than one fw attached to it, then its a problem, return an err
  4. If both these annotations are present, the firewallID takes precedence, and the ACL annotation is ignored.

IF a user creates a fw ID externally, and then switches to using a ACL, the CCM will take over the fw that's attached to the nodebalancer.

Jump to

Keyboard shortcuts

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