mirror of https://github.com/k3s-io/k3s
Fixed etcd URL in case of IPv6 address
Signed-off-by: Roberto Bonafiglia <roberto.bonafiglia@suse.com>pull/5385/head
parent
21fed356e6
commit
44253bcfd4
|
@ -45,6 +45,7 @@ import (
|
|||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
utilnet "k8s.io/apimachinery/pkg/util/net"
|
||||
"k8s.io/client-go/util/retry"
|
||||
utilsnet "k8s.io/utils/net"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -744,11 +745,17 @@ func (e *ETCD) migrateFromSQLite(ctx context.Context) error {
|
|||
|
||||
// peerURL returns the peer access address for the local node
|
||||
func (e *ETCD) peerURL() string {
|
||||
if utilsnet.IsIPv6String(e.address) {
|
||||
return fmt.Sprintf("https://[%s]:2380", e.address)
|
||||
}
|
||||
return fmt.Sprintf("https://%s:2380", e.address)
|
||||
}
|
||||
|
||||
// clientURL returns the client access address for the local node
|
||||
func (e *ETCD) clientURL() string {
|
||||
if utilsnet.IsIPv6String(e.address) {
|
||||
return fmt.Sprintf("https://[%s]:2379", e.address)
|
||||
}
|
||||
return fmt.Sprintf("https://%s:2379", e.address)
|
||||
}
|
||||
|
||||
|
@ -756,7 +763,11 @@ func (e *ETCD) clientURL() string {
|
|||
func (e *ETCD) metricsURL(expose bool) string {
|
||||
address := "http://127.0.0.1:2381"
|
||||
if expose {
|
||||
address = fmt.Sprintf("http://%s:2381,%s", e.address, address)
|
||||
if utilsnet.IsIPv6String(e.address) {
|
||||
address = fmt.Sprintf("https://[%s]:2381,%s", e.address, address)
|
||||
} else {
|
||||
address = fmt.Sprintf("https://%s:2381,%s", e.address, address)
|
||||
}
|
||||
}
|
||||
return address
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue