Skip to content

Commit

Permalink
docs(tproxy): improve tproxy instructions
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Dyszkiewicz <[email protected]>
  • Loading branch information
jakubdyszkiewicz committed Nov 14, 2023
1 parent 051a9a0 commit a93877d
Showing 1 changed file with 47 additions and 13 deletions.
60 changes: 47 additions & 13 deletions app/_src/production/dp-config/transparent-proxying.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,45 @@ Prerequisites:
{{site.mesh_product_name}} comes with [`kumactl` executable](/docs/{{ page.version }}/explore/cli) which can help us to prepare the host. Due to the wide variety of Linux setup options, these steps may vary and may need to be adjusted for the specifics of the particular deployment.
The host that will run the `kuma-dp` process in transparent proxying mode needs to be prepared with the following steps executed as `root`:

1. Create a new dedicated user on the machine.
1. Use proper version of iptables

{{site.mesh_product_name}} [is not yet compatible](https://github.com/kumahq/kuma/issues/8293) with `nf_tables`. You can check the version of iptables with the following command

Check notice on line 41 in app/_src/production/dp-config/transparent-proxying.md

View workflow job for this annotation

GitHub Actions / vale

[vale] app/_src/production/dp-config/transparent-proxying.md#L41

[Google.Contractions] Use 'isn't' instead of 'is not'.
Raw output
{"message": "[Google.Contractions] Use 'isn't' instead of 'is not'.", "location": {"path": "app/_src/production/dp-config/transparent-proxying.md", "range": {"start": {"line": 41, "column": 33}}}, "severity": "INFO"}

Check warning on line 41 in app/_src/production/dp-config/transparent-proxying.md

View workflow job for this annotation

GitHub Actions / vale

[vale] app/_src/production/dp-config/transparent-proxying.md#L41

[Google.WordList] Use 'select' instead of 'check'.
Raw output
{"message": "[Google.WordList] Use 'select' instead of 'check'.", "location": {"path": "app/_src/production/dp-config/transparent-proxying.md", "range": {"start": {"line": 41, "column": 126}}}, "severity": "WARNING"}
```sh
$ iptables --version
iptables v1.8.7 (nf_tables)
```

On the recent versions of Ubuntu, you need to change default `iptables`.

```sh
$ update-alternatives --set iptables /usr/sbin/iptables-legacy
$ update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
$ iptables --version
iptables v1.8.7 (legacy)
```

2. Create a new dedicated user on the machine.

```sh
useradd -u 5678 -U kuma-dp
```

2. Redirect all the relevant inbound, outbound and DNS traffic to the {{site.mesh_product_name}} data plane proxy.
3. Redirect all the relevant inbound, outbound and DNS traffic to the {{site.mesh_product_name}} data plane proxy.

```sh
kumactl install transparent-proxy \
--kuma-dp-user kuma-dp \
--skip-resolv-conf \
--redirect-dns
--redirect-dns \
--exclude-inbound-ports 22
```

{% warning %}
Please note that this command **will change** the host `iptables` rules.

We exclude port 22, so we can SSH to the machine without `kuma-dp` running.

Check warning on line 74 in app/_src/production/dp-config/transparent-proxying.md

View workflow job for this annotation

GitHub Actions / vale

[vale] app/_src/production/dp-config/transparent-proxying.md#L74

[Google.We] Try to avoid using first-person plural like 'We'.
Raw output
{"message": "[Google.We] Try to avoid using first-person plural like 'We'.", "location": {"path": "app/_src/production/dp-config/transparent-proxying.md", "range": {"start": {"line": 74, "column": 1}}}, "severity": "WARNING"}

Check warning on line 74 in app/_src/production/dp-config/transparent-proxying.md

View workflow job for this annotation

GitHub Actions / vale

[vale] app/_src/production/dp-config/transparent-proxying.md#L74

[Google.We] Try to avoid using first-person plural like 'we'.
Raw output
{"message": "[Google.We] Try to avoid using first-person plural like 'we'.", "location": {"path": "app/_src/production/dp-config/transparent-proxying.md", "range": {"start": {"line": 74, "column": 24}}}, "severity": "WARNING"}
{% endwarning %}

The changes will persist over restarts, so this command is needed only once. Reverting to the original state of the host can be done by issuing `kumactl uninstall transparent-proxy`.
The changes will not persist over restarts. You need to either add this command to your start scripts or use firewalld.

Check notice on line 77 in app/_src/production/dp-config/transparent-proxying.md

View workflow job for this annotation

GitHub Actions / vale

[vale] app/_src/production/dp-config/transparent-proxying.md#L77

[Google.Contractions] Use 'won't' instead of 'will not'.
Raw output
{"message": "[Google.Contractions] Use 'won't' instead of 'will not'.", "location": {"path": "app/_src/production/dp-config/transparent-proxying.md", "range": {"start": {"line": 77, "column": 13}}}, "severity": "INFO"}

Check warning on line 77 in app/_src/production/dp-config/transparent-proxying.md

View workflow job for this annotation

GitHub Actions / vale

[vale] app/_src/production/dp-config/transparent-proxying.md#L77

[Google.Will] Avoid using 'will'.
Raw output
{"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "app/_src/production/dp-config/transparent-proxying.md", "range": {"start": {"line": 77, "column": 13}}}, "severity": "WARNING"}

Check failure on line 77 in app/_src/production/dp-config/transparent-proxying.md

View workflow job for this annotation

GitHub Actions / vale

[vale] app/_src/production/dp-config/transparent-proxying.md#L77

[Vale.Spelling] Did you really mean 'firewalld'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'firewalld'?", "location": {"path": "app/_src/production/dp-config/transparent-proxying.md", "range": {"start": {"line": 77, "column": 110}}}, "severity": "ERROR"}

### Data plane proxy resource

Expand All @@ -64,11 +83,11 @@ In transparent proxying mode, the `Dataplane` resource should omit the `networki
```yaml
type: Dataplane
mesh: default
name: {{ name }}
name: {% raw %}{{ name }}{% endraw %}
networking:
address: {{ address }}
address: {% raw %}{{ address }}{% endraw %}
inbound:
- port: {{ port }}
- port: {% raw %}{{ port }}{% endraw %}
tags:
kuma.io/service: demo-client
transparentProxying:
Expand All @@ -82,6 +101,7 @@ The ports illustrated above are the default ones that `kumactl install transpare

{% warning %}
It is important that the `kuma-dp` process runs with the same system user that was passed to `kumactl install transparent-proxy --kuma-dp-user`.
The service itself should run with any other user than `kuma-dp`. Otherwise, it won't be able to leverage transparent proxying.
{% endwarning %}
When systemd is used, this can be done with an entry `User=kuma-dp` in the `[Service]` section of the service file.
Expand Down Expand Up @@ -109,8 +129,22 @@ If you run `firewalld` to manage firewalls and wrap iptables, add the `--store-f
### Upgrades
Before upgrading to the next version of {{site.mesh_product_name}}, make sure to run `kumactl uninstall transparent-proxy` and only then replace the `kumactl` binary.
This will ensure smooth upgrade and no leftovers from the previous installations.
Before upgrading to the next version of {{site.mesh_product_name}}, it's best to clean existing `iptables` rules and only then replace the `kumactl` binary.

You can clean the rules either by restarting the host or by running following commands
```sh
iptables -t nat -F
iptables -t nat -X
iptables -t raw -F
iptables -t raw -X
ip6tables -t nat -F
ip6tables -t nat -X
ip6tables -t raw -F
ip6tables -t raw -X
```
Be aware that the command above with remove all iptables rules, not only created by {{site.mesh_product_name}}.

Check warning on line 145 in app/_src/production/dp-config/transparent-proxying.md

View workflow job for this annotation

GitHub Actions / vale

[vale] app/_src/production/dp-config/transparent-proxying.md#L145

[Google.WordList] Use 'preceding' instead of 'above'.
Raw output
{"message": "[Google.WordList] Use 'preceding' instead of 'above'.", "location": {"path": "app/_src/production/dp-config/transparent-proxying.md", "range": {"start": {"line": 145, "column": 27}}}, "severity": "WARNING"}

In the future release, `kumactl` [will ship](https://github.com/kumahq/kuma/issues/8071) with `uninstall` command.

Check warning on line 147 in app/_src/production/dp-config/transparent-proxying.md

View workflow job for this annotation

GitHub Actions / vale

[vale] app/_src/production/dp-config/transparent-proxying.md#L147

[Google.Will] Avoid using 'will'.
Raw output
{"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "app/_src/production/dp-config/transparent-proxying.md", "range": {"start": {"line": 147, "column": 35}}}, "severity": "WARNING"}

## Configuration

Expand Down Expand Up @@ -188,11 +222,11 @@ spec:
```yaml
type: Dataplane
mesh: default
name: {{ name }}
name: {% raw %}{{ name }}{% endraw %}
networking:
address: {{ address }}
address: {% raw %}{{ address }}{% endraw %}
inbound:
- port: {{ port }}
- port: {% raw %}{{ port }}{% endraw %}
tags:
kuma.io/service: demo-client
transparentProxying:
Expand Down

0 comments on commit a93877d

Please sign in to comment.