Skip to content

Commit 196896f

Browse files
Eytan AvisrorEytan Avisror
authored andcommitted
remove discovery via metadata
Signed-off-by: Eytan Avisror <[email protected]>
1 parent 6112e11 commit 196896f

File tree

2 files changed

+5
-27
lines changed

2 files changed

+5
-27
lines changed

controllers/providers/aws/aws.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ const (
6868
ARNPrefix = "arn:aws:"
6969
LaunchConfigurationNotFoundErrorMessage = "Launch configuration name not found"
7070
defaultPolicyArn = "arn:aws:iam::aws:policy/AmazonEKSFargatePodExecutionRolePolicy"
71-
72-
MetadataMACAddressPath = "latest/meta-data/mac"
73-
MetadataInterfaceCidrPathFmt = "latest/meta-data/network/interfaces/macs/%v/vpc-ipv4-cidr-blocks"
7471
)
7572

7673
var (

controllers/providers/aws/eks.go

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ limitations under the License.
1616
package aws
1717

1818
import (
19-
"fmt"
2019
"strings"
2120

2221
"github.com/aws/aws-sdk-go/aws"
@@ -215,28 +214,10 @@ func (w *AwsWorker) DescribeFargateProfile() (*eks.FargateProfile, error) {
215214
}
216215

217216
func (w *AwsWorker) GetDNSClusterIP(cluster *eks.Cluster) string {
218-
if cluster != nil {
219-
serviceCidr := aws.StringValue(cluster.KubernetesNetworkConfig.ServiceIpv4Cidr)
220-
// addresses assigned from either the 10.100.0.0/16 or 172.20.0.0/16 CIDR blocks
221-
return strings.ReplaceAll(serviceCidr, "0/16", "10")
222-
} else {
223-
// if cluster information is not available get instance's ipv4 cidr from metadata
224-
macAddress, err := w.Ec2Metadata.GetMetadata(MetadataMACAddressPath)
225-
if err != nil {
226-
return ""
227-
}
228-
229-
cidrMetadataPath := fmt.Sprintf(MetadataInterfaceCidrPathFmt, macAddress)
230-
ipv4Cidr, err := w.Ec2Metadata.GetMetadata(cidrMetadataPath)
231-
if err != nil {
232-
return ""
233-
}
234-
235-
// if instance ipv4 cidr starts with 10. service IP is 172.20.0.10, otherwise its 10.100.0.10
236-
if strings.HasPrefix(ipv4Cidr, "10.") {
237-
return "172.20.0.10"
238-
}
239-
240-
return "10.100.0.10"
217+
if cluster == nil {
218+
return ""
241219
}
220+
serviceCidr := aws.StringValue(cluster.KubernetesNetworkConfig.ServiceIpv4Cidr)
221+
// addresses assigned from either the 10.100.0.0/16 or 172.20.0.0/16 CIDR blocks
222+
return strings.ReplaceAll(serviceCidr, "0/16", "10")
242223
}

0 commit comments

Comments
 (0)