mirror of https://github.com/k3s-io/k3s
Use IPv6 in case is the first configured IP with dualstack
Signed-off-by: Roberto Bonafiglia <roberto.bonafiglia@suse.com>pull/8644/head
parent
0816812c99
commit
722fca3b82
|
@ -353,7 +353,7 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
|
||||||
|
|
||||||
// If the supervisor and externally-facing apiserver are not on the same port, tell the proxy where to find the apiserver.
|
// If the supervisor and externally-facing apiserver are not on the same port, tell the proxy where to find the apiserver.
|
||||||
if controlConfig.SupervisorPort != controlConfig.HTTPSPort {
|
if controlConfig.SupervisorPort != controlConfig.HTTPSPort {
|
||||||
_, isIPv6, _ := util.GetFirstString([]string{envInfo.NodeIP.String()})
|
isIPv6 := utilsnet.IsIPv6(net.ParseIP([]string{envInfo.NodeIP.String()}[0]))
|
||||||
if err := proxy.SetAPIServerPort(ctx, controlConfig.HTTPSPort, isIPv6); err != nil {
|
if err := proxy.SetAPIServerPort(ctx, controlConfig.HTTPSPort, isIPv6); err != nil {
|
||||||
return nil, errors.Wrapf(err, "failed to setup access to API Server port %d on at %s", controlConfig.HTTPSPort, proxy.SupervisorURL())
|
return nil, errors.Wrapf(err, "failed to setup access to API Server port %d on at %s", controlConfig.HTTPSPort, proxy.SupervisorURL())
|
||||||
}
|
}
|
||||||
|
|
|
@ -277,7 +277,7 @@ func createProxyAndValidateToken(ctx context.Context, cfg *cmds.Agent) (proxy.Pr
|
||||||
if err := os.MkdirAll(agentDir, 0700); err != nil {
|
if err := os.MkdirAll(agentDir, 0700); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
_, isIPv6, _ := util.GetFirstString([]string{cfg.NodeIP.String()})
|
isIPv6 := utilsnet.IsIPv6(net.ParseIP([]string{cfg.NodeIP.String()}[0]))
|
||||||
|
|
||||||
proxy, err := proxy.NewSupervisorProxy(ctx, !cfg.DisableLoadBalancer, agentDir, cfg.ServerURL, cfg.LBServerPort, isIPv6)
|
proxy, err := proxy.NewSupervisorProxy(ctx, !cfg.DisableLoadBalancer, agentDir, cfg.ServerURL, cfg.LBServerPort, isIPv6)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
package agent
|
package agent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -14,8 +15,8 @@ import (
|
||||||
"github.com/opencontainers/runc/libcontainer/userns"
|
"github.com/opencontainers/runc/libcontainer/userns"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
"k8s.io/apimachinery/pkg/util/net"
|
|
||||||
"k8s.io/kubernetes/pkg/kubeapiserver/authorizer/modes"
|
"k8s.io/kubernetes/pkg/kubeapiserver/authorizer/modes"
|
||||||
|
utilsnet "k8s.io/utils/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
const socketPrefix = "unix://"
|
const socketPrefix = "unix://"
|
||||||
|
@ -33,8 +34,8 @@ func createRootlessConfig(argsMap map[string]string, controllers map[string]bool
|
||||||
|
|
||||||
func kubeProxyArgs(cfg *config.Agent) map[string]string {
|
func kubeProxyArgs(cfg *config.Agent) map[string]string {
|
||||||
bindAddress := "127.0.0.1"
|
bindAddress := "127.0.0.1"
|
||||||
_, IPv6only, _ := util.GetFirstString([]string{cfg.NodeIP})
|
isIPv6 := utilsnet.IsIPv6(net.ParseIP([]string{cfg.NodeIP}[0]))
|
||||||
if IPv6only {
|
if isIPv6 {
|
||||||
bindAddress = "::1"
|
bindAddress = "::1"
|
||||||
}
|
}
|
||||||
argsMap := map[string]string{
|
argsMap := map[string]string{
|
||||||
|
@ -54,8 +55,8 @@ func kubeProxyArgs(cfg *config.Agent) map[string]string {
|
||||||
|
|
||||||
func kubeletArgs(cfg *config.Agent) map[string]string {
|
func kubeletArgs(cfg *config.Agent) map[string]string {
|
||||||
bindAddress := "127.0.0.1"
|
bindAddress := "127.0.0.1"
|
||||||
_, IPv6only, _ := util.GetFirstString([]string{cfg.NodeIP})
|
isIPv6 := utilsnet.IsIPv6(net.ParseIP([]string{cfg.NodeIP}[0]))
|
||||||
if IPv6only {
|
if isIPv6 {
|
||||||
bindAddress = "::1"
|
bindAddress = "::1"
|
||||||
}
|
}
|
||||||
argsMap := map[string]string{
|
argsMap := map[string]string{
|
||||||
|
@ -123,9 +124,11 @@ func kubeletArgs(cfg *config.Agent) map[string]string {
|
||||||
if cfg.NodeName != "" {
|
if cfg.NodeName != "" {
|
||||||
argsMap["hostname-override"] = cfg.NodeName
|
argsMap["hostname-override"] = cfg.NodeName
|
||||||
}
|
}
|
||||||
defaultIP, err := net.ChooseHostInterface()
|
if nodeIPs := util.JoinIPs(cfg.NodeIPs); nodeIPs != "" {
|
||||||
if err != nil || defaultIP.String() != cfg.NodeIP {
|
dualStack, err := utilsnet.IsDualStackIPs(cfg.NodeIPs)
|
||||||
argsMap["node-ip"] = cfg.NodeIP
|
if err == nil && !dualStack {
|
||||||
|
argsMap["node-ip"] = cfg.NodeIP
|
||||||
|
}
|
||||||
}
|
}
|
||||||
kubeletRoot, runtimeRoot, controllers := cgroups.CheckCgroups()
|
kubeletRoot, runtimeRoot, controllers := cgroups.CheckCgroups()
|
||||||
if !controllers["cpu"] {
|
if !controllers["cpu"] {
|
||||||
|
|
Loading…
Reference in New Issue