|
|
@@ -120,6 +120,7 @@ var (
|
|
|
topologyLabel string
|
|
|
port int
|
|
|
serviceCIDRsRaw []string
|
|
|
+ internalCIDRsRaw []string
|
|
|
subnet string
|
|
|
resyncPeriod time.Duration
|
|
|
iptablesForwardRule bool
|
|
|
@@ -152,6 +153,7 @@ func init() {
|
|
|
cmd.Flags().StringVar(&topologyLabel, "topology-label", k8s.RegionLabelKey, "Kubernetes node label used to group nodes into logical locations.")
|
|
|
cmd.Flags().IntVar(&port, "port", mesh.DefaultKiloPort, "The port over which WireGuard peers should communicate.")
|
|
|
cmd.Flags().StringSliceVar(&serviceCIDRsRaw, "service-cidr", nil, "The service CIDR for the Kubernetes cluster. Can be provided optionally to avoid masquerading packets sent to service IPs. Can be specified multiple times.")
|
|
|
+ cmd.Flags().StringSliceVar(&internalCIDRsRaw, "internal-cidr", nil, "CIDRs to consider for internal IP auto-detection. If specified, only IPs within these CIDRs will be used. Can be specified multiple times.")
|
|
|
cmd.Flags().StringVar(&subnet, "subnet", mesh.DefaultKiloSubnet.String(), "CIDR from which to allocate addresses for WireGuard interfaces.")
|
|
|
cmd.Flags().DurationVar(&resyncPeriod, "resync-period", 30*time.Second, "How often should the Kilo controllers reconcile?")
|
|
|
cmd.Flags().BoolVar(&iptablesForwardRule, "iptables-forward-rules", false, "Add default accept rules to the FORWARD chain in iptables. Warning: this may break firewalls with a deny all policy and is potentially insecure!")
|
|
|
@@ -266,7 +268,16 @@ func runRoot(_ *cobra.Command, _ []string) error {
|
|
|
serviceCIDRs = append(serviceCIDRs, s)
|
|
|
}
|
|
|
|
|
|
- m, err := mesh.New(b, enc, gr, hostname, port, s, local, cni, cniPath, iface, cleanUp, cleanUpIface, createIface, mtu, resyncPeriod, prioritisePrivateAddr, iptablesForwardRule, serviceCIDRs, log.With(logger, "component", "kilo"), registry)
|
|
|
+ var internalCIDRs []*net.IPNet
|
|
|
+ for _, internalCIDR := range internalCIDRsRaw {
|
|
|
+ _, s, err := net.ParseCIDR(internalCIDR)
|
|
|
+ if err != nil {
|
|
|
+ return fmt.Errorf("failed to parse %q as CIDR: %v", internalCIDR, err)
|
|
|
+ }
|
|
|
+ internalCIDRs = append(internalCIDRs, s)
|
|
|
+ }
|
|
|
+
|
|
|
+ m, err := mesh.New(b, enc, gr, hostname, port, s, local, cni, cniPath, iface, cleanUp, cleanUpIface, createIface, mtu, resyncPeriod, prioritisePrivateAddr, iptablesForwardRule, internalCIDRs, serviceCIDRs, log.With(logger, "component", "kilo"), registry)
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("failed to create Kilo mesh: %v", err)
|
|
|
}
|