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

Remove deprecated aws cloud-provider helpers functions #6626

Open
brandond opened this issue Aug 22, 2024 · 1 comment
Open

Remove deprecated aws cloud-provider helpers functions #6626

brandond opened this issue Aug 22, 2024 · 1 comment
Assignees

Comments

@brandond
Copy link
Member

brandond commented Aug 22, 2024

The code that sets the correct hostname based on the response from the IMDS is no longer used, due to removal of the in-tree AWS cloud provider in Kubernetes 1.27 and newer.

  • if clx.String("node-name") == "" && cfg.CloudProviderName == "aws" {
    fqdn := hostnameFromMetadataEndpoint(context.Background())
    if fqdn == "" {
    hostFQDN, err := hostnameFQDN()
    if err != nil {
    return nil, err
    }
    fqdn = hostFQDN
    }
    if err := clx.Set("node-name", fqdn); err != nil {
    return nil, err
    }
  • rke2/pkg/rke2/rke2_linux.go

    Lines 504 to 533 in 6f1feb7

    func hostnameFromMetadataEndpoint(ctx context.Context) string {
    ctx, cancel := context.WithTimeout(ctx, time.Second)
    defer cancel()
    req, err := http.NewRequestWithContext(ctx, http.MethodGet, "http://169.254.169.254/latest/meta-data/local-hostname", nil)
    if err != nil {
    logrus.Debugf("Failed to create request for metadata endpoint: %v", err)
    return ""
    }
    resp, err := http.DefaultClient.Do(req)
    if err != nil {
    logrus.Debugf("Failed to get local-hostname from metadata endpoint: %v", err)
    return ""
    }
    defer resp.Body.Close()
    if resp.StatusCode != http.StatusOK {
    logrus.Debugf("Metadata endpoint returned unacceptable status code %d", resp.StatusCode)
    return ""
    }
    b, err := ioutil.ReadAll(resp.Body)
    if err != nil {
    logrus.Debugf("Failed to read response body from metadata endpoint: %v", err)
    return ""
    }
    return strings.TrimSpace(string(b))
    }

Attempts to use this code by starting RKE2 with cloud-provider-name: aws will cause the kubelet to fail to start:

E0822 22:35:03.230900     143 run.go:74] "command failed" err="failed to run Kubelet: unknown cloud provider \"aws\""

We should remove this dead code.

@brandond
Copy link
Member Author

Didn't make it into October, moving out to next month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants