Documentation ¶
Index ¶
- Constants
- func Filter[T any](arr []T, fs ...func(T) bool) []T
- func ForceNewIp(current, target *armnetwork.PublicIPAddress) (bool, string, any)
- func ForceNewNat(current, target *armnetwork.NatGateway) (bool, string, any)
- func ForceNewSubnet(_, _ *armnetwork.Subnet) (bool, string, any)
- func GetIdFromTemplate(template, subscription, rgName, name string) string
- func GetIdFromTemplateWithParent(template, subscription, rgName, parent, name string) string
- func GetObject[T any](wb shared.Whiteboard, key string) T
- func Join[K comparable, V any](m1, m2 map[K]V) map[K]V
- func ResourceGroupIdFromTemplate(subscription, name string) string
- func ToMap[T comparable, Y comparable](arr []T, f func(T) Y) map[Y]T
- type Access
- type AvailabilitySetConfig
- type AzureResourceKind
- type AzureResourceMetadata
- type FlowContext
- func (fctx *FlowContext) Delete(ctx context.Context) error
- func (fctx *FlowContext) DeleteLoadBalancers(ctx context.Context) error
- func (fctx *FlowContext) DeleteResourceGroup(ctx context.Context) error
- func (fctx *FlowContext) DeleteSubnetsInForeignGroup(ctx context.Context) error
- func (fctx *FlowContext) EnsureAvailabilitySet(ctx context.Context) error
- func (fctx *FlowContext) EnsureManagedIdentity(ctx context.Context) (err error)
- func (fctx *FlowContext) EnsureNatGateways(ctx context.Context) error
- func (fctx *FlowContext) EnsurePublicIps(ctx context.Context) error
- func (fctx *FlowContext) EnsureResourceGroup(ctx context.Context) error
- func (fctx *FlowContext) EnsureRouteTable(ctx context.Context) error
- func (fctx *FlowContext) EnsureSecurityGroup(ctx context.Context) error
- func (fctx *FlowContext) EnsureSubnets(ctx context.Context) error
- func (fctx *FlowContext) EnsureVirtualNetwork(ctx context.Context) error
- func (fctx *FlowContext) GetEgressIpCidrs() []string
- func (fctx *FlowContext) GetInfrastructureState() *runtime.RawExtension
- func (fctx *FlowContext) GetInfrastructureStatus(_ context.Context) (*v1alpha1.InfrastructureStatus, error)
- func (fctx *FlowContext) Reconcile(ctx context.Context) error
- type InfrastructureAdapter
- func (ia *InfrastructureAdapter) AvailabilitySetConfig() *AvailabilitySetConfig
- func (ia *InfrastructureAdapter) HasShootPrefix(name *string) bool
- func (ia *InfrastructureAdapter) IpConfigs() []PublicIPConfig
- func (ia *InfrastructureAdapter) IsOwnSubnetName(name *string) bool
- func (ia *InfrastructureAdapter) ManagedIpConfigs() map[string]PublicIPConfig
- func (ia *InfrastructureAdapter) NatGatewayConfigs() map[string]NatGatewayConfig
- func (ia *InfrastructureAdapter) Region() string
- func (ia *InfrastructureAdapter) ResourceGroup() ResourceGroupConfig
- func (ia *InfrastructureAdapter) ResourceGroupName() string
- func (ia *InfrastructureAdapter) RouteTableConfig() RouteTableConfig
- func (ia *InfrastructureAdapter) SecurityGroupConfig() SecurityGroupConfig
- func (ia *InfrastructureAdapter) TechnicalName() string
- func (ia *InfrastructureAdapter) VirtualNetworkConfig() VirtualNetworkConfig
- func (ia *InfrastructureAdapter) Zones() []ZoneConfig
- type Inventory
- type NatGatewayConfig
- type Opts
- type PublicIPConfig
- type ResourceGroupConfig
- type RouteTableConfig
- type SecurityGroupConfig
- type SpecMismatchError
- type SubnetConfig
- type TerminalConditionError
- type VirtualNetworkConfig
- type ZoneConfig
Constants ¶
const ( // ChildKeyIDs is the prefix key for all ids. ChildKeyIDs = "ids" // ChildKeyInventory is the prefix key for for the inventory struct. ChildKeyInventory = "inventory" // CreatedResourcesExistKey is a marker for the Terraform migration case. If the TF state is not empty // we inject this marker into the state to block the deletion without having first a successful reconciliation. CreatedResourcesExistKey = "resources_exist" // KeyManagedIdentityClientId is a key for the MI's client ID. KeyManagedIdentityClientId = "managed_identity_client_id" // KeyManagedIdentityId is a key for the MI's identity ID. KeyManagedIdentityId = "managed_identity_id" )
const ( // TemplateAvailabilitySet the template for the ID of an availability set. TemplateAvailabilitySet = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/availabilitySets/%s" // TemplateNatGateway the template for the id of a NAT Gateway. TemplateNatGateway = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/natGateways/%s" // TemplatePublicIP the template for the id of a public IP. TemplatePublicIP = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/publicIPAddresses/%s" // TemplateResourceGroup is the template for the id of a resource group. TemplateResourceGroup = "/subscriptions/%s/resourceGroups/%s" // TemplateRouteTable is the template for the id of a route table. TemplateRouteTable = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/routeTables/%s" // TemplateSecurityGroup is the template for the id of a security group. TemplateSecurityGroup = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s" // TemplateVirtualNetwork is the template for the id of a virtual network. TemplateVirtualNetwork = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualNetworks/%s" // TemplateSubnet is the template for the id of a subnet. TemplateSubnet = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualNetworks/%s/subnets/%s" )
const (
// KeyPublicIPAddresses is the key used to store public IP addresses in the FlowContext's whiteboard.
KeyPublicIPAddresses = "PublicIpAddresses"
)
Variables ¶
This section is empty.
Functions ¶
func ForceNewIp ¶
ForceNewIp checks if the resource can be reconciled. If not, returns the name of the field and value that couldn't be updated.
func ForceNewNat ¶
ForceNewNat checks if the resource can be reconciled. If not, returns the name of the field and value that couldn't be updated.
func ForceNewSubnet ¶
ForceNewSubnet checks if the resource can be reconciled. If not, returns the name of the field and value that couldn't be updated.
func GetIdFromTemplate ¶
GetIdFromTemplate returns the ID of a resource based on the target template.
func GetIdFromTemplateWithParent ¶
GetIdFromTemplateWithParent returns the ID of a resource based on the target template.
func GetObject ¶
func GetObject[T any](wb shared.Whiteboard, key string) T
GetObject returns the object and attempts to cast it to the specified type.
func Join ¶
func Join[K comparable, V any](m1, m2 map[K]V) map[K]V
Join merges maps by appending m2 to m1.
func ResourceGroupIdFromTemplate ¶
ResourceGroupIdFromTemplate returns the id of a resource group.
func ToMap ¶
func ToMap[T comparable, Y comparable](arr []T, f func(T) Y) map[Y]T
ToMap converts an array into a map. The key is provided by applying "f" to the array objects and the value are the objects.
Types ¶
type Access ¶
type Access interface { // DeletePublicIP deletes a public IP after disassociating it from the NAT Gateway if necessary. DeletePublicIP(ctx context.Context, rgName, pipName string) error // DisassociatePublicIP from the NAT Gateway it is attached. DisassociatePublicIP(ctx context.Context, rgName, natName, pipId string) error // DeleteNatGateway deletes a NAT Gateway after disassociating from all subnets attached to it. DeleteNatGateway(ctx context.Context, rgName, natName string) error // DisassociateNatGateway disassociates the NAT Gateway from attached subnets. DisassociateNatGateway(ctx context.Context, rgName, natName string) error }
Access provides additional methods that are build on top of the azure client primitives.
type AvailabilitySetConfig ¶
type AvailabilitySetConfig struct { AzureResourceMetadata // countFaultDomains is the fault domain count for the AV set. CountFaultDomains *int32 // countFaultDomains is the update domain count for the AV set. CountUpdateDomains *int32 Location string }
AvailabilitySetConfig contains the configuration for the shoot's availability set.
type AzureResourceKind ¶
type AzureResourceKind string
AzureResourceKind is a string describing the resource type.
const ( // KindAvailabilitySet is the kind for an availability set. KindAvailabilitySet AzureResourceKind = "Microsoft.Compute/availabilitySets" // KindNatGateway is the kind for a NAT Gateway. KindNatGateway AzureResourceKind = "Microsoft.Network/natGateways" // KindPublicIP is the kind for a public ip. KindPublicIP AzureResourceKind = "Microsoft.Network/publicIPAddresses" // KindResourceGroup is the kind for a resource group. KindResourceGroup AzureResourceKind = "Microsoft.Resources/resourceGroups" // KindRouteTable is the kind for a route table. KindRouteTable AzureResourceKind = "Microsoft.Network/routeTables" // KindSecurityGroup is the kind for a security group. KindSecurityGroup AzureResourceKind = "Microsoft.Network/networkSecurityGroups" // KindSubnet is the kind for a subnet KindSubnet AzureResourceKind = "Microsoft.Network/virtualNetworks/subnets" // KindVirtualNetwork is the kind for a virtual network. KindVirtualNetwork AzureResourceKind = "Microsoft.Network/virtualNetworks" )
func (AzureResourceKind) String ¶
func (a AzureResourceKind) String() string
type AzureResourceMetadata ¶
type AzureResourceMetadata struct { ResourceGroup string Name string Parent string Kind AzureResourceKind }
AzureResourceMetadata is able to uniquely identify a resource.
type FlowContext ¶
type FlowContext struct { *shared.BasicFlowContext // contains filtered or unexported fields }
FlowContext is the reconciler for all managed resources
func NewFlowContext ¶
func NewFlowContext(opts Opts) (*FlowContext, error)
NewFlowContext creates a new FlowContext.
func (*FlowContext) Delete ¶
func (fctx *FlowContext) Delete(ctx context.Context) error
Delete deletes all resources managed by the reconciler
func (*FlowContext) DeleteLoadBalancers ¶ added in v1.45.0
func (fctx *FlowContext) DeleteLoadBalancers(ctx context.Context) error
DeleteLoadBalancers deletes all load balancers in shoots resource group This is a prerequisite for the deletion of the subnets in foreign resource group because internal load balancers might have a Frontend IP configuration referencing the foreign subnet which therefore can not be deleted. Since the Frontend IP configuration by its own can not be deleted, we remove the whole (all) load balancers.
func (*FlowContext) DeleteResourceGroup ¶
func (fctx *FlowContext) DeleteResourceGroup(ctx context.Context) error
DeleteResourceGroup deletes the shoot's resource group.
func (*FlowContext) DeleteSubnetsInForeignGroup ¶
func (fctx *FlowContext) DeleteSubnetsInForeignGroup(ctx context.Context) error
DeleteSubnetsInForeignGroup deletes all managed subnets in a foreign resource group
func (*FlowContext) EnsureAvailabilitySet ¶
func (fctx *FlowContext) EnsureAvailabilitySet(ctx context.Context) error
EnsureAvailabilitySet creates or updates an KindAvailabilitySet
func (*FlowContext) EnsureManagedIdentity ¶
func (fctx *FlowContext) EnsureManagedIdentity(ctx context.Context) (err error)
EnsureManagedIdentity reconciles the managed identity specificed in the config.
func (*FlowContext) EnsureNatGateways ¶
func (fctx *FlowContext) EnsureNatGateways(ctx context.Context) error
EnsureNatGateways reconciles all the NAT Gateways for the shoot.
func (*FlowContext) EnsurePublicIps ¶
func (fctx *FlowContext) EnsurePublicIps(ctx context.Context) error
EnsurePublicIps reconciles the public IPs for the shoot.
func (*FlowContext) EnsureResourceGroup ¶
func (fctx *FlowContext) EnsureResourceGroup(ctx context.Context) error
EnsureResourceGroup creates or updates the shoot's resource group.
func (*FlowContext) EnsureRouteTable ¶
func (fctx *FlowContext) EnsureRouteTable(ctx context.Context) error
EnsureRouteTable creates or updates the route table
func (*FlowContext) EnsureSecurityGroup ¶
func (fctx *FlowContext) EnsureSecurityGroup(ctx context.Context) error
EnsureSecurityGroup creates or updates a KindSecurityGroup
func (*FlowContext) EnsureSubnets ¶
func (fctx *FlowContext) EnsureSubnets(ctx context.Context) error
EnsureSubnets creates or updates subnets.
func (*FlowContext) EnsureVirtualNetwork ¶
func (fctx *FlowContext) EnsureVirtualNetwork(ctx context.Context) error
EnsureVirtualNetwork reconciles the shoot's virtual network. At the end of the step the VNet should be created or in the case of user-provided vnet verify that it exists.
func (*FlowContext) GetEgressIpCidrs ¶ added in v1.45.0
func (fctx *FlowContext) GetEgressIpCidrs() []string
GetEgressIpCidrs retrieves the CIDRs of the IP ranges used for egress from the FlowContext
func (*FlowContext) GetInfrastructureState ¶
func (fctx *FlowContext) GetInfrastructureState() *runtime.RawExtension
GetInfrastructureState returns tha shoot's infrastructure state.
func (*FlowContext) GetInfrastructureStatus ¶
func (fctx *FlowContext) GetInfrastructureStatus(_ context.Context) (*v1alpha1.InfrastructureStatus, error)
GetInfrastructureStatus returns the infrastructure status.
type InfrastructureAdapter ¶
type InfrastructureAdapter struct {
// contains filtered or unexported fields
}
InfrastructureAdapter contains information about the infrastructure resources that are either static, or otherwise inferable based on the shoot configuration. It acts as an intermediate step to make the configuration easier to process for the ensurer step.
func NewInfrastructureAdapter ¶
func NewInfrastructureAdapter( infra *extensionsv1alpha1.Infrastructure, config *azure.InfrastructureConfig, status *azure.InfrastructureStatus, profile *azure.CloudProfileConfig, cluster *extensionscontroller.Cluster, ) (*InfrastructureAdapter, error)
NewInfrastructureAdapter returns a new instance of the InfrastructureAdapter.
func (*InfrastructureAdapter) AvailabilitySetConfig ¶
func (ia *InfrastructureAdapter) AvailabilitySetConfig() *AvailabilitySetConfig
AvailabilitySetConfig returns the configuration for the shoot's availability set.
func (*InfrastructureAdapter) HasShootPrefix ¶
func (ia *InfrastructureAdapter) HasShootPrefix(name *string) bool
HasShootPrefix returns true if the target resource's name is prefixed with the shoot's canonical name.
func (*InfrastructureAdapter) IpConfigs ¶
func (ia *InfrastructureAdapter) IpConfigs() []PublicIPConfig
IpConfigs is the configuration for the desired public IPs.
func (*InfrastructureAdapter) IsOwnSubnetName ¶ added in v1.47.2
func (ia *InfrastructureAdapter) IsOwnSubnetName(name *string) bool
IsOwnSubnetName returns a bool indicating whether the subnet with the given name was created by the reconciliation of the current shoot.
This is needed to distinguish between subnets by unfortunately named shoots (i.e. the current shoot's name is a prefix to another's) that deploy in the same vnet.
func (*InfrastructureAdapter) ManagedIpConfigs ¶
func (ia *InfrastructureAdapter) ManagedIpConfigs() map[string]PublicIPConfig
ManagedIpConfigs returns a filtered list of only the public IPs that are managed by gardener.
func (*InfrastructureAdapter) NatGatewayConfigs ¶
func (ia *InfrastructureAdapter) NatGatewayConfigs() map[string]NatGatewayConfig
NatGatewayConfigs is the configuration for the desired NAT Gateways.
func (*InfrastructureAdapter) Region ¶
func (ia *InfrastructureAdapter) Region() string
Region is the region of the shoot.
func (*InfrastructureAdapter) ResourceGroup ¶
func (ia *InfrastructureAdapter) ResourceGroup() ResourceGroupConfig
ResourceGroup returns the configuration for the shoot's resource group.
func (*InfrastructureAdapter) ResourceGroupName ¶
func (ia *InfrastructureAdapter) ResourceGroupName() string
ResourceGroupName returns the shoot's resource group's name.
func (*InfrastructureAdapter) RouteTableConfig ¶
func (ia *InfrastructureAdapter) RouteTableConfig() RouteTableConfig
RouteTableConfig returns configuration for the shoot's route table.
func (*InfrastructureAdapter) SecurityGroupConfig ¶
func (ia *InfrastructureAdapter) SecurityGroupConfig() SecurityGroupConfig
SecurityGroupConfig returns the configuration for our desired security group.
func (*InfrastructureAdapter) TechnicalName ¶
func (ia *InfrastructureAdapter) TechnicalName() string
TechnicalName the cluster's "base" name. Used as a name or as a prefix by other resources.
func (*InfrastructureAdapter) VirtualNetworkConfig ¶
func (ia *InfrastructureAdapter) VirtualNetworkConfig() VirtualNetworkConfig
VirtualNetworkConfig returns the virtual network configuration.
func (*InfrastructureAdapter) Zones ¶
func (ia *InfrastructureAdapter) Zones() []ZoneConfig
Zones returns the target specification for the zones that need to be reconciled.
type Inventory ¶
type Inventory struct {
shared.Whiteboard
}
Inventory is responsible for managing a list of all infrastructure created objects.
func NewSimpleInventory ¶
func NewSimpleInventory(wb shared.Whiteboard) *Inventory
NewSimpleInventory returns a new instance of Inventory.
func (*Inventory) ByKind ¶
func (i *Inventory) ByKind(kind AzureResourceKind) []string
ByKind returns a list of all the IDs of stored objects of a particular kind.
func (*Inventory) Delete ¶
Delete deletes the item with ID==id from the inventory and any children it may have. That means that it deletes any ID prefixed by id, since azure IDs are hierarchical.
func (*Inventory) Get ¶
func (i *Inventory) Get(id string) *arm.ResourceID
Get gets the item from the inventory.
func (*Inventory) ToList ¶
func (i *Inventory) ToList() []v1alpha1.AzureResource
ToList returns a list of v1alpha1 API objects that correspond to the current inventory list.
type NatGatewayConfig ¶
type NatGatewayConfig struct { AzureResourceMetadata Location string Zone *string IdleTimeout *int32 PublicIPList []PublicIPConfig }
NatGatewayConfig contains configuration for a NAT Gateway.
func (*NatGatewayConfig) ToProvider ¶
func (nat *NatGatewayConfig) ToProvider(base *armnetwork.NatGateway) *armnetwork.NatGateway
ToProvider translates the config into the actual providerAccess object.
type Opts ¶ added in v1.44.0
type Opts struct { Client k8sclient.Client Factory client.Factory Auth *internal.ClientAuth Logger logr.Logger Infra *extensionsv1alpha1.Infrastructure Cluster *controller.Cluster State *azure.InfrastructureState }
Opts contains the options to initialize a FlowContext.
type PublicIPConfig ¶
type PublicIPConfig struct { AzureResourceMetadata Zones []string Location string Managed bool }
PublicIPConfig contains configuration for a public IP resource.
func (*PublicIPConfig) ToProvider ¶
func (ip *PublicIPConfig) ToProvider(base *armnetwork.PublicIPAddress) *armnetwork.PublicIPAddress
ToProvider translates the config into the actual providerAccess object.
type ResourceGroupConfig ¶
type ResourceGroupConfig struct { AzureResourceMetadata Location string }
ResourceGroupConfig contains the configuration for a resource group.
type RouteTableConfig ¶
type RouteTableConfig struct { AzureResourceMetadata Location string }
RouteTableConfig is the desired configuration for a route table.
func (*RouteTableConfig) ToProvider ¶
func (r *RouteTableConfig) ToProvider(base *armnetwork.RouteTable) *armnetwork.RouteTable
ToProvider translates the config into the actual providerAccess object.
type SecurityGroupConfig ¶
type SecurityGroupConfig struct { AzureResourceMetadata Location string }
SecurityGroupConfig is the desired configuration for a security group.
func (*SecurityGroupConfig) ToProvider ¶
func (r *SecurityGroupConfig) ToProvider(base *armnetwork.SecurityGroup) *armnetwork.SecurityGroup
ToProvider translates the config into the actual providerAccess object.
type SpecMismatchError ¶
type SpecMismatchError struct { // AzureResourceMetadata describe uniquely an Azure resource AzureResourceMetadata // Field is the name of field that could not be reconciled. Field string // Expected is the value of the field that was expected. Expected any // Found is the actual value of Field. Found any // Info contains additional information or instruction to the user. Info *string }
SpecMismatchError is an error to indicate that the reconciliation cannot proceed or the operation requested is not supported.
func NewSpecMismatchError ¶
func NewSpecMismatchError(identifier AzureResourceMetadata, offender string, expected, found any, info *string) *SpecMismatchError
NewSpecMismatchError creates a TerminalSpecMismatch error.
func (*SpecMismatchError) Error ¶
func (t *SpecMismatchError) Error() string
type SubnetConfig ¶
type SubnetConfig struct { AzureResourceMetadata // contains filtered or unexported fields }
SubnetConfig is the specification for a subnet
func (*SubnetConfig) ToProvider ¶
func (s *SubnetConfig) ToProvider(base *armnetwork.Subnet) *armnetwork.Subnet
ToProvider translates the config into the actual providerAccess object.
type TerminalConditionError ¶
type TerminalConditionError struct { AzureResourceMetadata // contains filtered or unexported fields }
TerminalConditionError is an error to mark cases where the reconciliation cannot continue.
func NewTerminalConditionError ¶
func NewTerminalConditionError(identifier AzureResourceMetadata, err error) *TerminalConditionError
NewTerminalConditionError creates a TerminalConditionError.
func (*TerminalConditionError) Error ¶
func (t *TerminalConditionError) Error() string
func (*TerminalConditionError) Unwrap ¶
func (t *TerminalConditionError) Unwrap() error
type VirtualNetworkConfig ¶
type VirtualNetworkConfig struct { AzureResourceMetadata // Managed is true if the vnet is managed by gardener. Managed bool // Location is a reference to the region. Location string // Cidr is the vnet's CIDR. CIDR *string // DDoSPlanID is the ID reference of the DDoS protection plan. DDoSPlanID *string }
VirtualNetworkConfig contains configuration for the virtual network
func (*VirtualNetworkConfig) ToProvider ¶
func (v *VirtualNetworkConfig) ToProvider(base *armnetwork.VirtualNetwork) *armnetwork.VirtualNetwork
ToProvider translates the config into the actual providerAccess object.
type ZoneConfig ¶
type ZoneConfig struct { Subnet SubnetConfig NatGateway *NatGatewayConfig Migrated bool }
ZoneConfig is the specification for a zone.