INNER CODE UNIT · Go

getPrimaryIP

aws/amazon-vpc-cni-k8s · cmd/aws-vpc-cni/main.go:191

func getPrimaryIP(ipv4 bool) (string, error) {
	var hostIP string
	var err error
	imdsKey := "local-ipv4"
	if !ipv4 {
		imdsKey = "ipv6"
	}

	hostIP, err = cniutils.GetNodeMetadata(imdsKey)
	if err != nil {
		if ipv4 {
			log.WithError(err).Fatalf("failed to retrieve local-ipv4 address in imds metadata")
		} else {
			log.WithError(err).Debugf("failed to retrieve ipv6 address in imds metadata")
		}
		return "", err
	}
	return hostIP, nil

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…