aws: Retrieve instance info only when max pods is not set

This commit is contained in:
Ciprian Hacman 2024-01-04 12:37:31 +02:00
parent a8305d2a17
commit f0376b7b2f
1 changed files with 15 additions and 17 deletions

View File

@ -619,7 +619,8 @@ func (b *KubeletBuilder) buildKubeletConfigSpec() (*kops.KubeletConfigSpec, erro
c.ClientCAFile = filepath.Join(b.PathSrvKubernetes(), "ca.crt")
if b.NodeupConfig.Networking.AmazonVPC != nil {
// Respect any MaxPods value the user sets explicitly.
if b.NodeupConfig.Networking.AmazonVPC != nil && c.MaxPods == nil {
sess := session.Must(session.NewSession())
metadata := ec2metadata.New(sess)
@ -637,25 +638,22 @@ func (b *KubeletBuilder) buildKubeletConfigSpec() (*kops.KubeletConfigSpec, erro
return nil, err
}
// Respect any MaxPods value the user sets explicitly.
if c.MaxPods == nil {
// Default maximum pods per node defined by KubeletConfiguration
maxPods := 110
// Default maximum pods per node defined by KubeletConfiguration
maxPods := 110
// AWS VPC CNI plugin-specific maximum pod calculation based on:
// https://github.com/aws/amazon-vpc-cni-k8s/blob/v1.9.3/README.md#setup
enis := instanceType.InstanceENIs
ips := instanceType.InstanceIPsPerENI
if enis > 0 && ips > 0 {
instanceMaxPods := enis*(ips-1) + 2
if instanceMaxPods < maxPods {
maxPods = instanceMaxPods
}
// AWS VPC CNI plugin-specific maximum pod calculation based on:
// https://github.com/aws/amazon-vpc-cni-k8s/blob/v1.9.3/README.md#setup
enis := instanceType.InstanceENIs
ips := instanceType.InstanceIPsPerENI
if enis > 0 && ips > 0 {
instanceMaxPods := enis*(ips-1) + 2
if instanceMaxPods < maxPods {
maxPods = instanceMaxPods
}
// Write back values that could have changed
c.MaxPods = fi.PtrTo(int32(maxPods))
}
// Write back values that could have changed
c.MaxPods = fi.PtrTo(int32(maxPods))
}
if c.VolumePluginDirectory == "" {