Skip to content

Commit 7f7898a

Browse files
committed
nftables monitor disable flag
1 parent 5201cd5 commit 7f7898a

File tree

12 files changed

+40
-11
lines changed

12 files changed

+40
-11
lines changed

.github/workflows/integration.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
branches:
77
- master
88
- release
9+
- frc/nftmonitor
910
repository_dispatch:
1011
types:
1112
- test-command
@@ -32,7 +33,7 @@ jobs:
3233
# The ref of the commit to checkout (do not use the merge commit if repository dispatch)
3334
if [ "${{ github.event_name }}" == "repository_dispatch" ]; then
3435
echo "master=false" >> $GITHUB_OUTPUT
35-
echo "architectures=linux/amd64" >> $GITHUB_OUTPUT
36+
echo "architectures=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
3637
echo "commit-ref=${{ github.event.client_payload.pull_request.head.sha }}" >> $GITHUB_OUTPUT
3738
echo "pr-number=${{ github.event.client_payload.github.payload.issue.number }}" >> $GITHUB_OUTPUT
3839
elif [ "${{ steps.get_version.outputs.VERSION }}" != "" ]; then
@@ -45,7 +46,7 @@ jobs:
4546
echo "commit-ref=${{ github.sha }}" >> $GITHUB_OUTPUT
4647
else
4748
echo "master=false" >> $GITHUB_OUTPUT
48-
echo "architectures=linux/amd64" >> $GITHUB_OUTPUT
49+
echo "architectures=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
4950
echo "commit-ref=${{ github.sha }}" >> $GITHUB_OUTPUT
5051
fi
5152

cmd/fabric/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func run(cmd *cobra.Command, _ []string) error {
160160
return fmt.Errorf("unable to create firewall configuration reconciler: %w", err)
161161
}
162162

163-
if err := fwcr.SetupWithManager(cmd.Context(), mgr); err != nil {
163+
if err := fwcr.SetupWithManager(cmd.Context(), mgr, options.EnableNftMonitor); err != nil {
164164
return fmt.Errorf("unable to setup firewall configuration reconciler: %w", err)
165165
}
166166

cmd/gateway/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func run(cmd *cobra.Command, _ []string) error {
201201
return fmt.Errorf("unable to create firewall configuration reconciler: %w", err)
202202
}
203203

204-
if err := fwcr.SetupWithManager(cmd.Context(), mgr); err != nil {
204+
if err := fwcr.SetupWithManager(cmd.Context(), mgr, true); err != nil {
205205
return fmt.Errorf("unable to setup firewall configuration reconciler: %w", err)
206206
}
207207

deployments/liqo/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
| networking.enabled | bool | `true` | Use the default Liqo networking module. |
8282
| networking.fabric.config.fullMasquerade | bool | `false` | Enabe/Disable the full masquerade mode for the fabric pod. It means that all traffic will be masquerade using the first external cidr IP, instead of using the pod IP. Full masquerade is useful when the cluster nodeports uses a PodCIDR IP to masqerade the incoming traffic. IMPORTANT: Please consider that enabling this feature will masquerade the source IP of traffic towards a remote cluster, making impossible for a pod that receives the traffic to know the original source IP. |
8383
| networking.fabric.config.gatewayMasqueradeBypass | bool | `false` | Enable/Disable the masquerade bypass for the gateway pods. It means that the packets from gateway pods will not be masqueraded from the host where the pod is scheduled. This is useful in scenarios where CNIs masquerade the traffic from pod to nodes. For example this is required when using the Azure CNI or Kindnet. |
84+
| networking.fabric.config.nftablesMonitor | bool | `true` | Enable/Disable the nftables monitor for the fabric pod. It means that the fabric pod will monitor the nftables rules and will restore them in case of changes. In some cases (like K3S), this monitor can cause a huge amount of CPU usage. If you are experiencing high CPU usage, you can disable this feature. |
8485
| networking.fabric.image.name | string | `"ghcr.io/liqotech/fabric"` | Image repository for the fabric pod. |
8586
| networking.fabric.image.version | string | `""` | Custom version for the fabric image. If not specified, the global tag is used. |
8687
| networking.fabric.pod.annotations | object | `{}` | Annotations for the fabric pod. |

deployments/liqo/templates/liqo-fabric-daemonset.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ spec:
4848
{{- if .Values.requirements.kernel.disabled }}
4949
- --disable-kernel-version-check
5050
{{- end }}
51+
- --enable-nft-monitor={{ .Values.networking.fabric.config.nftablesMonitor }}
5152
{{- if .Values.common.extraArgs }}
5253
{{- toYaml .Values.common.extraArgs | nindent 10 }}
5354
{{- end }}

deployments/liqo/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ networking:
130130
# This is useful in scenarios where CNIs masquerade the traffic from pod to nodes.
131131
# For example this is required when using the Azure CNI or Kindnet.
132132
gatewayMasqueradeBypass: false
133+
# -- Enable/Disable the nftables monitor for the fabric pod.
134+
# It means that the fabric pod will monitor the nftables rules and will restore them in case of changes.
135+
# In some cases (like K3S), this monitor can cause a huge amount of CPU usage.
136+
# If you are experiencing high CPU usage, you can disable this feature.
137+
nftablesMonitor: true
133138

134139
authentication:
135140
# -- Enable/Disable the authentication module.

docs/contributing/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,4 @@ When executing the unit tests from the *liqo-test* container, it is possible to
137137
--accept-multiclient ./path/to/test/directory
138138
```
139139

140-
4. From the host, connect to *localhost:2345* with your remote debugging client of choice (e.g. [GoLand](https://www.jetbrains.com/help/go/attach-to-running-go-processes-with-debugger.html#step-3-create-the-remote-run-debug-configuration-on-the-client-computer)), and enjoy!
140+
4. From the host, connect to *localhost:2345* with your remote debugging client of choice, and enjoy!

docs/installation/install.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,12 @@ By default, the K3s installer stores the kubeconfig to access your cluster in th
303303
Make sure to properly refer to it when using *liqoctl* (e.g., setting the `KUBECONFIG` variable), and that the current user has permissions to read it.
304304
```
305305
306+
```{warning}
307+
- Due to an issue with K3s certificates, the `kubectl exec' command doesn't work properly when used on a pod scheduled on a virtual node.
308+
- Due to an issue with the [nftables golang library](https://github.com/google/nftables) and the pod running in *host network* in K3s, the firewall monitoring feature is disabled by default.
309+
This means that the firewall rules on the node will not be monitored and enforced by Liqo. If these rules are deleted or changed, Liqo won't restore them.
310+
```
311+
306312
**Installation**
307313
308314
Liqo can be installed on a K3s cluster with the following command:

pkg/fabric/flags.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ const (
4040
// FlagNameDisableARP is the flag to enable ARP.
4141
FlagNameDisableARP FlagName = "disable-arp"
4242

43+
// FlagNameEnableNftMonitor is the flag to enable the nftables monitor.
44+
FlagNameEnableNftMonitor FlagName = "enable-nft-monitor"
45+
4346
// FlagNameDisableKernelVersionCheck is the flag to enable the kernel version check.
4447
FlagNameDisableKernelVersionCheck FlagName = "disable-kernel-version-check"
4548
// FlagNameMinimumKernelVersion is the minimum kernel version required to run the wireguard interface.
@@ -63,6 +66,7 @@ func InitFlags(flagset *pflag.FlagSet, opts *Options) {
6366
flagset.StringVar(&opts.ProbeAddr, FlagNameProbeAddr.String(), ":8081", "Address for the health probe endpoint")
6467

6568
flagset.BoolVar(&opts.DisableARP, FlagNameDisableARP.String(), false, "Disable ARP")
69+
flagset.BoolVar(&opts.EnableNftMonitor, FlagNameEnableNftMonitor.String(), true, "Enable nftables monitor")
6670

6771
flagset.BoolVar(&opts.DisableKernelVersionCheck, FlagNameDisableKernelVersionCheck.String(), false, "Disable the kernel version check")
6872
flagset.Var(&opts.MinimumKernelVersion, string(FlagNameMinimumKernelVersion), "Minimum kernel version required to run the wireguard interface")

pkg/fabric/options.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ type Options struct {
2626
MetricsAddress string
2727
ProbeAddr string
2828

29-
DisableARP bool
29+
DisableARP bool
30+
EnableNftMonitor bool
3031

3132
DisableKernelVersionCheck bool
3233
MinimumKernelVersion kernelversion.KernelVersion

0 commit comments

Comments
 (0)