Skip to content

Commit

Permalink
Merge branch 'scaleway:master' into nox-fix-node-label-filter
Browse files Browse the repository at this point in the history
  • Loading branch information
nox-404 authored Feb 2, 2024
2 parents 8385a53 + 1f92fd3 commit 89a89e4
Show file tree
Hide file tree
Showing 5 changed files with 2,205 additions and 1,003 deletions.
8 changes: 4 additions & 4 deletions docs/loadbalancer-annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The default value is `5`.

### `service.beta.kubernetes.io/scw-loadbalancer-health-check-http-uri`
This is the annotation to set the URI that is used by the `http` health check.
It is possible to set the uri per port, like `80:/;443,8443:/healthz`.
It is possible to set the uri per port, like `80:/;443,8443:mydomain.tld/healthz`.
NB: Required when setting service.beta.kubernetes.io/scw-loadbalancer-health-check-type to `http` or `https`.

### `service.beta.kubernetes.io/scw-loadbalancer-health-check-http-method`
Expand Down Expand Up @@ -128,8 +128,8 @@ This is the annotation that modifes what occurs when a backend server is marked
The default value is `on_marked_down_action_none` and the possible values are `on_marked_down_action_none` and `shutdown_sessions`.

### `service.beta.kubernetes.io/scw-loadbalancer-force-internal-ip`
This is the annotation that force the usage of InternalIP inside the loadbalancer.
Normally, the cloud controller manager use ExternalIP to be nodes region-free (or public InternalIP in case of Baremetal).
**This field is DEPRECATED**. This annotation is deprecated and will be removed in a future release.
It used to make the CCM use internal IPs instead of public ones for Public only clusters.

### `service.beta.kubernetes.io/scw-loadbalancer-use-hostname`
This is the annotation that force the use of the LB hostname instead of the public IP.
Expand All @@ -153,7 +153,7 @@ Expected format: `"Key1=Val1,Key2=Val2"`

### `service.beta.kubernetes.io/scw-loadbalancer-redispatch-attempt-count`
This is the annotation to activate redispatch on another backend server in case of failure
The default value is 0, which disable the redispatch.
The default value is 0, which disable the redispatch. Only a value of 0 or 1 are allowed.

### `service.beta.kubernetes.io/scw-loadbalancer-max-retries`
This is the annotation to configure the number of retry on connection failure
Expand Down
23 changes: 13 additions & 10 deletions scaleway/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (i *instances) NodeAddresses(ctx context.Context, name types.NodeName) ([]v
if err != nil {
return nil, err
}
return i.instanceAddresses(server), nil
return i.instanceAddresses(server)
}

// NodeAddressesByProviderID returns the addresses of the specified instance.
Expand All @@ -68,7 +68,7 @@ func (i *instances) NodeAddressesByProviderID(ctx context.Context, providerID st
if err != nil {
return nil, err
}
return i.instanceAddresses(instanceServer), nil
return i.instanceAddresses(instanceServer)
}

// InstanceID returns the cloud provider ID of the node with the specified NodeName.
Expand Down Expand Up @@ -161,7 +161,7 @@ func (i *instances) GetZoneByNodeName(ctx context.Context, nodeName types.NodeNa
// ===========================

// instanceAddresses extracts NodeAdress from the server
func (i *instances) instanceAddresses(server *scwinstance.Server) []v1.NodeAddress {
func (i *instances) instanceAddresses(server *scwinstance.Server) ([]v1.NodeAddress, error) {
addresses := []v1.NodeAddress{
{Type: v1.NodeHostName, Address: server.Hostname},
}
Expand Down Expand Up @@ -194,13 +194,11 @@ func (i *instances) instanceAddresses(server *scwinstance.Server) []v1.NodeAddre
Region: region,
})
if err != nil {
klog.Errorf("unable to query ipam for node %s: %v", server.Name, err)
return addresses
return addresses, fmt.Errorf("unable to query ipam for node %s: %v", server.Name, err)
}

if len(ips.IPs) == 0 {
klog.Errorf("no private network ip for node %s", server.Name)
return addresses
return addresses, fmt.Errorf("no private network ip for node %s", server.Name)
}

for _, nicIP := range ips.IPs {
Expand All @@ -210,7 +208,7 @@ func (i *instances) instanceAddresses(server *scwinstance.Server) []v1.NodeAddre
)
}

return addresses
return addresses, nil
}

// fallback to legacy private ip
Expand All @@ -222,7 +220,7 @@ func (i *instances) instanceAddresses(server *scwinstance.Server) []v1.NodeAddre
)
}

return addresses
return addresses, nil
}

func instanceZone(instanceServer *scwinstance.Server) (cloudprovider.Zone, error) {
Expand Down Expand Up @@ -369,10 +367,15 @@ func (i *instances) InstanceMetadata(ctx context.Context, node *v1.Node) (*cloud
return nil, err
}

addresses, err := i.instanceAddresses(instance)
if err != nil {
return nil, err
}

return &cloudprovider.InstanceMetadata{
ProviderID: BuildProviderID(InstanceTypeInstance, instance.Zone.String(), instance.ID),
InstanceType: instance.CommercialType,
NodeAddresses: i.instanceAddresses(instance),
NodeAddresses: addresses,
Region: region.String(),
Zone: instance.Zone.String(),
}, nil
Expand Down
Loading

0 comments on commit 89a89e4

Please sign in to comment.