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

[v1.4] Forward port changes around hostname-override #3140

Merged
merged 2 commits into from Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions cluster/defaults.go
Expand Up @@ -163,6 +163,7 @@ var (
}
DefaultClusterProportionalAutoscalerLinearParams = v3.LinearAutoscalerParams{CoresPerReplica: 128, NodesPerReplica: 4, Min: 1, PreventSinglePointFailure: true}
DefaultMonitoringAddonReplicas = int32(1)
defaultUseInstanceMetadataHostname = false
)

type ExternalFlags struct {
Expand Down Expand Up @@ -269,6 +270,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 {
Expand Down
17 changes: 8 additions & 9 deletions cluster/plan.go
Expand Up @@ -462,11 +462,12 @@ func (c *Cluster) BuildKubeletProcess(host *hosts.Host, serviceOptions v3.Kubern
kubelet := &c.Services.Kubelet
Command := c.getRKEToolsEntryPoint(host.OS(), "kubelet")
CommandArgs := map[string]string{
"client-ca-file": pki.GetCertPath(pki.CACertName),
"cloud-provider": c.CloudProvider.Name,
"cluster-dns": c.ClusterDNSServer,
"cluster-domain": c.ClusterDomain,
"fail-swap-on": strconv.FormatBool(kubelet.FailSwapOn),
"client-ca-file": pki.GetCertPath(pki.CACertName),
"cloud-provider": c.CloudProvider.Name,
"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,
Expand Down Expand Up @@ -494,9 +495,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() {
Expand Down Expand Up @@ -694,7 +692,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")
}
}
Expand Down
4 changes: 2 additions & 2 deletions data/bindata.go

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions data/data.json
Expand Up @@ -17896,7 +17896,7 @@
"type": "array"
}
},
"version": "v1.25.5+k3s1"
"version": "v1.25.5+k3s2"
}
]
},
Expand Down Expand Up @@ -25139,7 +25139,7 @@
"version": "0.1.1100"
},
"rancher-vsphere-cpi": {
"repo": "rancher-charts",
"repo": "rancher-rke2-charts",
"version": "1.4.001"
},
"rancher-vsphere-csi": {
Expand Down Expand Up @@ -25386,7 +25386,7 @@
"version": "0.1.1100"
},
"rancher-vsphere-cpi": {
"repo": "rancher-charts",
"repo": "rancher-rke2-charts",
"version": "1.4.001"
},
"rancher-vsphere-csi": {
Expand Down Expand Up @@ -26136,7 +26136,7 @@
"version": "0.1.1100"
},
"rancher-vsphere-cpi": {
"repo": "rancher-charts",
"repo": "rancher-rke2-charts",
"version": "1.4.001"
},
"rancher-vsphere-csi": {
Expand Down Expand Up @@ -26386,7 +26386,7 @@
"version": "0.1.1100"
},
"rancher-vsphere-cpi": {
"repo": "rancher-charts",
"repo": "rancher-rke2-charts",
"version": "1.4.100"
},
"rancher-vsphere-csi": {
Expand Down Expand Up @@ -26636,7 +26636,7 @@
"version": "0.1.1100"
},
"rancher-vsphere-cpi": {
"repo": "rancher-charts",
"repo": "rancher-rke2-charts",
"version": "1.4.100"
},
"rancher-vsphere-csi": {
Expand Down
2 changes: 2 additions & 0 deletions types/rke_types.go
Expand Up @@ -557,6 +557,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
Expand Down
5 changes: 5 additions & 0 deletions types/zz_generated_deepcopy.go

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