Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Use droplet ID for node names in DO #16004

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/releases/1.29-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ This is a document to gather the release notes prior to the release.

## Openstack

## DigitalOcean

* Node names have changed from the droplet's private IP to the droplet's ID

# Breaking changes

## Other breaking changes
Expand Down
8 changes: 8 additions & 0 deletions k8s/crds/kops.k8s.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3932,6 +3932,10 @@ spec:
kubelet defaults. (DEPRECATED: This parameter should be set
via the config file specified by the Kubelet''s --config flag.'
type: boolean
providerID:
description: ProviderID specifies the unique ID of the instance
that an external provider can use to identify a specific node.
type: string
readOnlyPort:
description: ReadOnlyPort is the port used by the kubelet api
for read-only access (default 10255)
Expand Down Expand Up @@ -4370,6 +4374,10 @@ spec:
kubelet defaults. (DEPRECATED: This parameter should be set
via the config file specified by the Kubelet''s --config flag.'
type: boolean
providerID:
description: ProviderID specifies the unique ID of the instance
that an external provider can use to identify a specific node.
type: string
readOnlyPort:
description: ReadOnlyPort is the port used by the kubelet api
for read-only access (default 10255)
Expand Down
4 changes: 4 additions & 0 deletions k8s/crds/kops.k8s.io_instancegroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,10 @@ spec:
kubelet defaults. (DEPRECATED: This parameter should be set
via the config file specified by the Kubelet''s --config flag.'
type: boolean
providerID:
description: ProviderID specifies the unique ID of the instance
that an external provider can use to identify a specific node.
type: string
readOnlyPort:
description: ReadOnlyPort is the port used by the kubelet api
for read-only access (default 10255)
Expand Down
1 change: 1 addition & 0 deletions nodeup/pkg/model/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func buildKubeletComponentConfig(kubeletConfig *kops.KubeletConfigSpec) (*nodeta
componentConfig.ShutdownGracePeriodCriticalPods = *kubeletConfig.ShutdownGracePeriodCriticalPods
}
componentConfig.MemorySwap.SwapBehavior = kubeletConfig.MemorySwapBehavior
componentConfig.ProviderID = kubeletConfig.ProviderID

s := runtime.NewScheme()
if err := kubelet.AddToScheme(s); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ type KubeletConfigSpec struct {
// MemorySwapBehavior defines how swap is used by container workloads.
// Supported values: LimitedSwap, "UnlimitedSwap.
MemorySwapBehavior string `json:"memorySwapBehavior,omitempty"`
// ProviderID specifies the unique ID of the instance that an external provider can use to identify a specific node.
ProviderID string `json:"providerID,omitempty"`
}

// KubeProxyConfig defines the configuration for a proxy
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha2/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ type KubeletConfigSpec struct {
// MemorySwapBehavior defines how swap is used by container workloads.
// Supported values: LimitedSwap, "UnlimitedSwap.
MemorySwapBehavior string `json:"memorySwapBehavior,omitempty"`
// ProviderID specifies the unique ID of the instance that an external provider can use to identify a specific node.
ProviderID string `json:"providerID,omitempty"`
}

// KubeProxyConfig defines the configuration for a proxy
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha3/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ type KubeletConfigSpec struct {
// MemorySwapBehavior defines how swap is used by container workloads.
// Supported values: LimitedSwap, "UnlimitedSwap.
MemorySwapBehavior string `json:"memorySwapBehavior,omitempty"`
// ProviderID specifies the unique ID of the instance that an external provider can use to identify a specific node.
ProviderID string `json:"providerID,omitempty"`
}

// KubeProxyConfig defines the configuration for a proxy
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha3/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 1 addition & 9 deletions upup/pkg/fi/cloudup/do/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,12 @@ func (o digitalOceanVerifier) VerifyToken(ctx context.Context, rawRequest *http.

// The node challenge is important here though, verifying the caller has control of the IP address.

nodeName := ""
if len(addresses) == 0 {
// Name seems a better default than the first IP, but we have to match what other components are expecting
nodeName = droplet.Name
} else {
nodeName = addresses[0]
}

if len(challengeEndpoints) == 0 {
return nil, fmt.Errorf("cannot determine challenge endpoint for server %q", serverID)
}

result := &bootstrap.VerifyResult{
NodeName: nodeName,
NodeName: strconv.Itoa(droplet.ID),
CertificateNames: addresses,
ChallengeEndpoint: challengeEndpoints[0],
}
Expand Down
16 changes: 7 additions & 9 deletions upup/pkg/fi/nodeup/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"crypto/sha256"
"encoding/base64"
"errors"
"fmt"
"io"
"net"
Expand Down Expand Up @@ -426,6 +425,10 @@ func evaluateSpec(nodeupConfig *nodeup.Config, cloudProvider api.CloudProviderID

nodeupConfig.KubeletConfig.HostnameOverride = hostnameOverride

if cloudProvider == api.CloudProviderDO {
nodeupConfig.KubeletConfig.ProviderID = "digitalocean://" + hostnameOverride
}

if nodeupConfig.KubeProxy != nil {
nodeupConfig.KubeProxy.HostnameOverride = hostnameOverride
nodeupConfig.KubeProxy.BindAddress, err = evaluateBindAddress(nodeupConfig.KubeProxy.BindAddress)
Expand Down Expand Up @@ -460,17 +463,12 @@ func evaluateHostnameOverride(cloudProvider api.CloudProviderID) (string, error)
bareHostname := strings.Split(fullyQualified, ".")[0]
return bareHostname, nil
case api.CloudProviderDO:
vBytes, err := vfs.Context.ReadFile("metadata://digitalocean/interfaces/private/0/ipv4/address")
dropletIDBytes, err := vfs.Context.ReadFile("metadata://digitalocean/id")
if err != nil {
return "", fmt.Errorf("error reading droplet private IP from DigitalOcean metadata: %v", err)
}

hostname := string(vBytes)
if hostname == "" {
return "", errors.New("private IP for digitalocean droplet was empty")
return "", fmt.Errorf("error reading droplet ID from DigitalOcean metadata: %v", err)
}

return hostname, nil
return string(dropletIDBytes), nil
}

return "", nil
Expand Down
Loading