Skip to content

Commit

Permalink
Merge branch 'main' into e2e-test-kubeadm-full-etcd
Browse files Browse the repository at this point in the history
  • Loading branch information
prajwalvathreya authored Aug 23, 2024
2 parents 7e7a7af + 8cfd121 commit bd6cebb
Show file tree
Hide file tree
Showing 29 changed files with 1,310 additions and 1,609 deletions.
2 changes: 2 additions & 0 deletions api/v1alpha2/linodefirewall_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type LinodeFirewallSpec struct {
// +optional
InboundRules []FirewallRule `json:"inboundRules,omitempty"`

// InboundPolicy determines if traffic by default should be ACCEPTed or DROPped. Defaults to ACCEPT if not defined.
// +kubebuilder:validation:Enum=ACCEPT;DROP
// +kubebuilder:default=ACCEPT
// +optional
Expand All @@ -49,6 +50,7 @@ type LinodeFirewallSpec struct {
// +optional
OutboundRules []FirewallRule `json:"outboundRules,omitempty"`

// OutboundPolicy determines if traffic by default should be ACCEPTed or DROPped. Defaults to ACCEPT if not defined.
// +kubebuilder:validation:Enum=ACCEPT;DROP
// +kubebuilder:default=ACCEPT
// +optional
Expand Down
1 change: 0 additions & 1 deletion api/v1alpha2/linodemachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ type LinodeMachineSpec struct {
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
Tags []string `json:"tags,omitempty"`
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
// +kubebuilder:deprecatedversion:warning="Firewalls should be referenced via FirewallRef"
FirewallID int `json:"firewallID,omitempty"`
// OSDisk is configuration for the root disk that includes the OS,
// if not specified this defaults to whatever space is not taken up by the DataDisks
Expand Down
1 change: 1 addition & 0 deletions clients/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type LinodeVPCClient interface {
type LinodeNodeBalancerClient interface {
CreateNodeBalancer(ctx context.Context, opts linodego.NodeBalancerCreateOptions) (*linodego.NodeBalancer, error)
GetNodeBalancer(ctx context.Context, nodebalancerID int) (*linodego.NodeBalancer, error)
ListNodeBalancerNodes(ctx context.Context, nodebalancerID int, configID int, opts *linodego.ListOptions) ([]linodego.NodeBalancerNode, error)
GetNodeBalancerConfig(ctx context.Context, nodebalancerID int, configID int) (*linodego.NodeBalancerConfig, error)
CreateNodeBalancerConfig(ctx context.Context, nodebalancerID int, opts linodego.NodeBalancerConfigCreateOptions) (*linodego.NodeBalancerConfig, error)
DeleteNodeBalancerNode(ctx context.Context, nodebalancerID int, configID int, nodeID int) error
Expand Down
49 changes: 35 additions & 14 deletions cloud/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ import (

// ClusterScopeParams defines the input parameters used to create a new Scope.
type ClusterScopeParams struct {
Client K8sClient
Cluster *clusterv1.Cluster
LinodeCluster *infrav1alpha2.LinodeCluster
Client K8sClient
Cluster *clusterv1.Cluster
LinodeCluster *infrav1alpha2.LinodeCluster
LinodeMachineList infrav1alpha2.LinodeMachineList
}

func validateClusterScopeParams(params ClusterScopeParams) error {
Expand All @@ -50,7 +51,7 @@ func validateClusterScopeParams(params ClusterScopeParams) error {

// NewClusterScope creates a new Scope from the supplied parameters.
// This is meant to be called for each reconcile iteration.
func NewClusterScope(ctx context.Context, linodeClientConfig ClientConfig, params ClusterScopeParams) (*ClusterScope, error) {
func NewClusterScope(ctx context.Context, linodeClientConfig, dnsClientConfig ClientConfig, params ClusterScopeParams) (*ClusterScope, error) {
if err := validateClusterScopeParams(params); err != nil {
return nil, err
}
Expand All @@ -63,6 +64,11 @@ func NewClusterScope(ctx context.Context, linodeClientConfig ClientConfig, param
return nil, fmt.Errorf("credentials from secret ref: %w", err)
}
linodeClientConfig.Token = string(apiToken)
dnsToken, err := getCredentialDataFromRef(ctx, params.Client, *params.LinodeCluster.Spec.CredentialsRef, params.LinodeCluster.GetNamespace(), "dnsToken")
if err != nil || len(dnsToken) == 0 {
dnsToken = apiToken
}
dnsClientConfig.Token = string(dnsToken)
}
linodeClient, err := CreateLinodeClient(linodeClientConfig)
if err != nil {
Expand All @@ -74,22 +80,37 @@ func NewClusterScope(ctx context.Context, linodeClientConfig ClientConfig, param
return nil, fmt.Errorf("failed to init patch helper: %w", err)
}

akamDomainsClient, err := setUpEdgeDNSInterface()
if err != nil {
return nil, fmt.Errorf("failed to create akamai dns client: %w", err)
}
linodeDomainsClient, err := CreateLinodeClient(dnsClientConfig, WithRetryCount(0))
if err != nil {
return nil, fmt.Errorf("failed to create linode client: %w", err)
}

return &ClusterScope{
Client: params.Client,
Cluster: params.Cluster,
LinodeClient: linodeClient,
LinodeCluster: params.LinodeCluster,
PatchHelper: helper,
Client: params.Client,
Cluster: params.Cluster,
LinodeClient: linodeClient,
LinodeDomainsClient: linodeDomainsClient,
AkamaiDomainsClient: akamDomainsClient,
LinodeCluster: params.LinodeCluster,
LinodeMachines: params.LinodeMachineList,
PatchHelper: helper,
}, nil
}

// ClusterScope defines the basic context for an actuator to operate upon.
type ClusterScope struct {
Client K8sClient
PatchHelper *patch.Helper
LinodeClient LinodeClient
Cluster *clusterv1.Cluster
LinodeCluster *infrav1alpha2.LinodeCluster
Client K8sClient
PatchHelper *patch.Helper
LinodeClient LinodeClient
Cluster *clusterv1.Cluster
LinodeCluster *infrav1alpha2.LinodeCluster
LinodeMachines infrav1alpha2.LinodeMachineList
AkamaiDomainsClient AkamClient
LinodeDomainsClient LinodeClient
}

// PatchObject persists the cluster configuration and status.
Expand Down
Loading

0 comments on commit bd6cebb

Please sign in to comment.