1
0
mirror of https://github.com/rancher/rke.git synced 2025-07-14 07:36:05 +00:00

Merge pull request #3136 from kinarashah/fix

[v1.3] changes around hostname-override for aws cloud provider
This commit is contained in:
Kinara Shah 2023-01-12 09:22:27 -08:00 committed by GitHub
commit 0dc41477c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 11 deletions

View File

@ -157,6 +157,7 @@ var (
}
DefaultClusterProportionalAutoscalerLinearParams = v3.LinearAutoscalerParams{CoresPerReplica: 128, NodesPerReplica: 4, Min: 1, PreventSinglePointFailure: true}
DefaultMonitoringAddonReplicas = int32(1)
defaultUseInstanceMetadataHostname = false
)
type ExternalFlags struct {
@ -263,6 +264,10 @@ func (c *Cluster) setClusterDefaults(ctx context.Context, flags ExternalFlags) e
c.ForceDeployCerts = true
}
if c.CloudProvider.Name == k8s.AWSCloudProvider && c.CloudProvider.UseInstanceMetadataHostname == nil {
c.CloudProvider.UseInstanceMetadataHostname = &defaultUseInstanceMetadataHostname
}
// enable cri-dockerd for k8s >= 1.24
err = c.setCRIDockerd()
if err != nil {

View File

@ -463,6 +463,7 @@ func (c *Cluster) BuildKubeletProcess(host *hosts.Host, serviceOptions v3.Kubern
"cluster-dns": c.ClusterDNSServer,
"cluster-domain": c.ClusterDomain,
"fail-swap-on": strconv.FormatBool(kubelet.FailSwapOn),
// overrides kubernetes.io/hostname label on node, rke uses it to find node (services/node_util.go)
"hostname-override": host.HostnameOverride,
"kubeconfig": pki.GetConfigPath(pki.KubeNodeCertName),
"pod-infra-container-image": kubelet.InfraContainerImage,
@ -490,9 +491,6 @@ func (c *Cluster) BuildKubeletProcess(host *hosts.Host, serviceOptions v3.Kubern
if host.IsWindows() { // compatible with Windows
CommandArgs["cloud-config"] = path.Join(host.PrefixPath, cloudConfigFileName)
}
if c.CloudProvider.Name == k8s.AWSCloudProvider {
delete(CommandArgs, "hostname-override")
}
}
if c.IsKubeletGenerateServingCertificateEnabled() {
@ -690,7 +688,8 @@ func (c *Cluster) BuildKubeProxyProcess(host *hosts.Host, serviceOptions v3.Kube
} else {
CommandArgs["bind-address"] = host.Address
}
if c.CloudProvider.Name == k8s.AWSCloudProvider {
if c.CloudProvider.Name == k8s.AWSCloudProvider && c.CloudProvider.UseInstanceMetadataHostname != nil && *c.CloudProvider.UseInstanceMetadataHostname {
// rke-tools will inject hostname-override from ec2 instance metadata to match with the spec.nodeName set by cloud provider https://github.com/rancher/rke-tools/blob/3eab4f07aa97a8aeeaaef55b1b7bbc82e2a3374a/entrypoint.sh#L17
delete(CommandArgs, "hostname-override")
}
}

View File

@ -2,7 +2,7 @@
// +build !ignore_autogenerated
/*
Copyright 2022 Rancher Labs, Inc.
Copyright 2023 Rancher Labs, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -554,6 +554,8 @@ type PortCheck struct {
type CloudProvider struct {
// Name of the Cloud Provider
Name string `yaml:"name" json:"name,omitempty"`
// Only configured for AWS currently, add for other providers as needed
UseInstanceMetadataHostname *bool ` yaml:"useInstanceMetadataHostname,omitempty" json:"useInstanceMetadataHostname,omitempty"`
// AWSCloudProvider
AWSCloudProvider *AWSCloudProvider `yaml:"awsCloudProvider,omitempty" json:"awsCloudProvider,omitempty"`
// AzureCloudProvider

View File

@ -2,7 +2,7 @@
// +build !ignore_autogenerated
/*
Copyright 2022 Rancher Labs, Inc.
Copyright 2023 Rancher Labs, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -400,6 +400,11 @@ func (in *CanalNetworkProvider) DeepCopy() *CanalNetworkProvider {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CloudProvider) DeepCopyInto(out *CloudProvider) {
*out = *in
if in.UseInstanceMetadataHostname != nil {
in, out := &in.UseInstanceMetadataHostname, &out.UseInstanceMetadataHostname
*out = new(bool)
**out = **in
}
if in.AWSCloudProvider != nil {
in, out := &in.AWSCloudProvider, &out.AWSCloudProvider
*out = new(AWSCloudProvider)