1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00

Merge pull request #1729 from marquiz/devel/topology-ipv6

topology-updater: properly handle IPv6 from NODE_ADDRESS
This commit is contained in:
Kubernetes Prow Robot 2024-06-04 04:41:23 -07:00 committed by GitHub
commit 72c0bdb4c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -19,8 +19,10 @@ package main
import ( import (
"flag" "flag"
"fmt" "fmt"
"net"
"os" "os"
"path" "path"
"strings"
"time" "time"
"k8s.io/klog/v2" "k8s.io/klog/v2"
@ -91,6 +93,10 @@ func parseArgs(flags *flag.FlagSet, osArgs ...string) (*topology.Args, *resource
"please either define the NODE_ADDRESS environment variable or specify endpoint with the -kubelet-config-uri flag\n", kubeletSecurePort) "please either define the NODE_ADDRESS environment variable or specify endpoint with the -kubelet-config-uri flag\n", kubeletSecurePort)
os.Exit(1) os.Exit(1)
} }
if isIPv6(nodeAddress) {
// With IPv6 we need to wrap the IP address in brackets as we append :port below
nodeAddress = "[" + nodeAddress + "]"
}
resourcemonitorArgs.KubeletConfigURI = fmt.Sprintf("https://%s:%d/configz", nodeAddress, kubeletSecurePort) resourcemonitorArgs.KubeletConfigURI = fmt.Sprintf("https://%s:%d/configz", nodeAddress, kubeletSecurePort)
} }
@ -128,3 +134,8 @@ func initFlags(flagset *flag.FlagSet) (*topology.Args, *resourcemonitor.Args) {
return args, resourcemonitorArgs return args, resourcemonitorArgs
} }
func isIPv6(addr string) bool {
ip := net.ParseIP(addr)
return ip != nil && strings.Count(ip.String(), ":") >= 2
}