mirror of
https://github.com/k3s-io/k3s.git
synced 2026-05-28 04:34:19 -04:00
server: Allow to enable network policies with IPv6-only
After previous changes, network policies are working on IPv6-only installations. Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
This commit is contained in:
parent
c0045f415b
commit
5f2a4d4209
2 changed files with 11 additions and 16 deletions
|
|
@ -80,17 +80,19 @@ func Run(ctx context.Context, nodeConfig *config.Node) error {
|
|||
iptablesCmdHandlers := make(map[v1core.IPFamily]utils.IPTablesHandler, 2)
|
||||
ipSetHandlers := make(map[v1core.IPFamily]utils.IPSetHandler, 2)
|
||||
|
||||
iptHandler, err := iptables.NewWithProtocol(iptables.ProtocolIPv4)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create iptables handler")
|
||||
}
|
||||
iptablesCmdHandlers[v1core.IPv4Protocol] = iptHandler
|
||||
if nodeConfig.AgentConfig.EnableIPv4 {
|
||||
iptHandler, err := iptables.NewWithProtocol(iptables.ProtocolIPv4)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create iptables handler")
|
||||
}
|
||||
iptablesCmdHandlers[v1core.IPv4Protocol] = iptHandler
|
||||
|
||||
ipset, err := utils.NewIPSet(false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create ipset handler")
|
||||
ipset, err := utils.NewIPSet(false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create ipset handler")
|
||||
}
|
||||
ipSetHandlers[v1core.IPv4Protocol] = ipset
|
||||
}
|
||||
ipSetHandlers[v1core.IPv4Protocol] = ipset
|
||||
|
||||
if nodeConfig.AgentConfig.EnableIPv6 {
|
||||
ipt6Handler, err := iptables.NewWithProtocol(iptables.ProtocolIPv6)
|
||||
|
|
|
|||
|
|
@ -528,13 +528,6 @@ func validateNetworkConfiguration(serverConfig server.Config) error {
|
|||
return errors.New("dual-stack cluster-dns is not supported")
|
||||
}
|
||||
|
||||
IPv6OnlyService, _ := util.IsIPv6OnlyCIDRs(serverConfig.ControlConfig.ServiceIPRanges)
|
||||
if IPv6OnlyService {
|
||||
if serverConfig.ControlConfig.DisableNPC == false {
|
||||
return errors.New("network policy enforcement is not compatible with IPv6 only operation; server must be restarted with --disable-network-policy")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue