mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
agent(netpol): Explicitly enable IPv4 when necessary
Before this change, kube-router was always assuming that IPv4 is enabled, which is not the case in IPv6-only clusters. To enable network policies in IPv6-only, we need to explicitly let kube-router know when to disable IPv4. Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
This commit is contained in:
parent
c9badb4fd7
commit
c0045f415b
@ -55,7 +55,7 @@ func Run(ctx context.Context, nodeConfig *config.Node) error {
|
||||
|
||||
krConfig := options.NewKubeRouterConfig()
|
||||
krConfig.ClusterIPCIDR = util.JoinIPNets(nodeConfig.AgentConfig.ServiceCIDRs)
|
||||
krConfig.EnableIPv4 = true
|
||||
krConfig.EnableIPv4 = nodeConfig.AgentConfig.EnableIPv4
|
||||
krConfig.EnableIPv6 = nodeConfig.AgentConfig.EnableIPv6
|
||||
krConfig.NodePortRange = strings.ReplaceAll(nodeConfig.AgentConfig.ServiceNodePortRange.String(), "-", ":")
|
||||
krConfig.HostnameOverride = nodeConfig.AgentConfig.NodeName
|
||||
|
@ -59,15 +59,19 @@ func run(ctx context.Context, cfg cmds.Agent, proxy proxy.Proxy) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to validate node-ip")
|
||||
}
|
||||
serviceIPv4 := utilsnet.IsIPv4CIDR(nodeConfig.AgentConfig.ServiceCIDR)
|
||||
clusterIPv4 := utilsnet.IsIPv4CIDR(nodeConfig.AgentConfig.ClusterCIDR)
|
||||
serviceIPv6 := utilsnet.IsIPv6CIDR(nodeConfig.AgentConfig.ServiceCIDR)
|
||||
clusterIPv6 := utilsnet.IsIPv6CIDR(nodeConfig.AgentConfig.ClusterCIDR)
|
||||
|
||||
enableIPv4 := dualCluster || dualService || dualNode || serviceIPv4 || clusterIPv4
|
||||
enableIPv6 := dualCluster || dualService || dualNode || serviceIPv6 || clusterIPv6
|
||||
conntrackConfig, err := getConntrackConfig(nodeConfig)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to validate kube-proxy conntrack configuration")
|
||||
}
|
||||
syssetup.Configure(enableIPv6, conntrackConfig)
|
||||
nodeConfig.AgentConfig.EnableIPv4 = enableIPv4
|
||||
nodeConfig.AgentConfig.EnableIPv6 = enableIPv6
|
||||
|
||||
if err := setupCriCtlConfig(cfg, nodeConfig); err != nil {
|
||||
|
@ -106,6 +106,7 @@ type Agent struct {
|
||||
Rootless bool
|
||||
ProtectKernelDefaults bool
|
||||
DisableServiceLB bool
|
||||
EnableIPv4 bool
|
||||
EnableIPv6 bool
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user