Skip to content

Conversation

zrggw
Copy link
Contributor

@zrggw zrggw commented Jul 25, 2025

modified ipsec user guide according to the review of PR #105

@kmesh-bot kmesh-bot requested review from jayesh9747 and nlgwcy July 25, 2025 08:35
@kmesh-bot
Copy link
Collaborator

Welcome @zrggw! It looks like this is your first PR to kmesh-net/website 🎉

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @zrggw, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a comprehensive user guide for integrating and utilizing IPsec within a Kmesh cluster. The guide details the necessary steps for enabling secure inter-node communication using IPsec, including key generation, configuration, verification, and key rotation, along with important operational considerations to ensure proper functioning.

Highlights

  • New IPsec User Guide: A new documentation page has been added, detailing the process of enabling and using IPsec for secure communication in a Kmesh cluster.
  • Key Generation and Configuration: The guide provides step-by-step instructions on generating IPsec pre-shared keys using kmeshctl secret and enabling IPsec via the kmesh.yaml configuration by setting --enable-ipsec=true.
  • Kmesh Management Scope: It clarifies that only pods or namespaces explicitly managed by Kmesh (e.g., via kubectl label namespace default istio.io/dataplane-mode=Kmesh) will participate in the IPsec encryption process.
  • Verification and Key Rotation: The document includes methods to verify IPsec encryption using tcpdump (by observing ESP packets) and explains how to replace pre-shared keys, noting the increment in IPsec SPI numbers upon rotation.
  • Important Operational Notes: Critical warnings are provided regarding potential conflicts with network mark values (0xe0, 0xd0) used by IPsec and issues that arise when address MASQ is applied to IPsec-encrypted packets, which can lead to packet loss.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a user guide for enabling IPsec in a Kmesh cluster. The guide is comprehensive, but I've identified several areas for improvement in terms of clarity, grammatical correctness, and formatting. My suggestions focus on making the instructions easier for users to understand and follow, particularly regarding the IPsec key requirements and formatting of code/command snippets. Addressing these points will significantly improve the quality of the documentation.


### How to enable IPsec in Kmesh

**Step 1: Generate an IPsec pre shared key for Kmesh before starting the Kmesh by kmeshctl. Currently, only the rfc4106 (gcm (AES)) algorithm is supported. key need 36 characters(32 character as algo key, 4 character as salt)**

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The description of the key requirements is confusing. It states that the key needs "36 characters", but the example commands generate a 72-character hexadecimal string (representing 36 bytes).

This should be clarified to prevent user error. The key is 36 bytes, which should be provided as a 72-character hex string. The text should also be grammatically corrected for better readability.

Suggested change
**Step 1: Generate an IPsec pre shared key for Kmesh before starting the Kmesh by kmeshctl. Currently, only the rfc4106 (gcm (AES)) algorithm is supported. key need 36 characters(32 character as algo key, 4 character as salt)**
**Step 1: Generate an IPsec pre-shared key for Kmesh using `kmeshctl` before starting Kmesh. Currently, only the `rfc4106` (gcm(AES)) algorithm is supported. The key must be 36 bytes (32 bytes for the algorithm key and 4 bytes for the salt), provided as a 72-character hexadecimal string.**

@@ -0,0 +1,78 @@
---
draft: true
linktitle: use IPsec in Kmesh cluster

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency and improved readability, titles should be capitalized. Consider using 'Use IPsec in Kmesh Cluster'.

Suggested change
linktitle: use IPsec in Kmesh cluster
linktitle: Use IPsec in Kmesh Cluster

docs:
parent: user guide
weight: 21
title: use IPsec in Kmesh cluster

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency and improved readability, titles should be capitalized. Consider using 'Use IPsec in Kmesh Cluster'.

Suggested change
title: use IPsec in Kmesh cluster
title: Use IPsec in Kmesh Cluster


### Use IPsec in Kmesh cluster

IPsec is a mature and widely used encryption method for inter node communication. This document explains how to enable IPsec for two Kmesh managed nodes in a Kmesh cluster to encrypt communication data between both parties.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This sentence can be improved for clarity and conciseness.

  • "inter node" should be hyphenated: "inter-node".
  • "between both parties" is redundant.

A clearer version would be more helpful for the user.

Suggested change
IPsec is a mature and widely used encryption method for inter node communication. This document explains how to enable IPsec for two Kmesh managed nodes in a Kmesh cluster to encrypt communication data between both parties.
IPsec is a mature and widely used encryption method for inter-node communication. This document explains how to enable IPsec to encrypt communication data between Kmesh-managed nodes.

```bash
kmeshctl secret --key=$(dd if=/dev/urandom count=36 bs=1 2>/dev/null | xxd -p -c 64)
```
If you want use custom key, you can use the following command

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a minor grammatical error here. It should be "If you want to use..." instead of "If you want use...".

Suggested change
If you want use custom key, you can use the following command
If you want to use a custom key, you can use the following command

Comment on lines 36 to 42
kmesh.yaml
...
args:
[
"./start_kmesh.sh --mode=dual-engine --enable-bypass=false --enable-ipsec=true",
]
...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This YAML snippet should be enclosed in a proper markdown code block for correct rendering and readability. The current use of tabs and inconsistent spacing can lead to poor formatting. I've reformatted it to use standard YAML syntax, which is clearer for users.

Suggested change
kmesh.yaml
...
args:
[
"./start_kmesh.sh --mode=dual-engine --enable-bypass=false --enable-ipsec=true",
]
...
...
args:
- "./start_kmesh.sh --mode=dual-engine --enable-bypass=false --enable-ipsec=true"
...

Comment on lines 54 to 60
root@master:~/kmesh# tcpdump -i any |grep ESP
...
14:19:24.143654 ? Out IP master > node1: ESP(spi=0x00000001,seq=0x3da88), length 80
14:19:24.143690 ? Out IP master > node1: ESP(spi=0x00000001,seq=0x3da89), length 80
14:19:24.143707 ? In IP node1 > master: ESP(spi=0x00000001,seq=0x3c037), length 80
14:19:24.143738 ? In IP node1 > master: ESP(spi=0x00000001,seq=0x3c038), length 172
...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For correct rendering and readability, this tcpdump output should be enclosed in a markdown code block.

Suggested change
root@master:~/kmesh# tcpdump -i any |grep ESP
...
14:19:24.143654 ? Out IP master > node1: ESP(spi=0x00000001,seq=0x3da88), length 80
14:19:24.143690 ? Out IP master > node1: ESP(spi=0x00000001,seq=0x3da89), length 80
14:19:24.143707 ? In IP node1 > master: ESP(spi=0x00000001,seq=0x3c037), length 80
14:19:24.143738 ? In IP node1 > master: ESP(spi=0x00000001,seq=0x3c038), length 172
...
root@master:~/kmesh# tcpdump -i any |grep ESP
...
14:19:24.143654 ? Out IP master > node1: ESP(spi=0x00000001,seq=0x3da88), length 80
14:19:24.143690 ? Out IP master > node1: ESP(spi=0x00000001,seq=0x3da89), length 80
14:19:24.143707 ? In IP node1 > master: ESP(spi=0x00000001,seq=0x3c037), length 80
14:19:24.143738 ? In IP node1 > master: ESP(spi=0x00000001,seq=0x3c038), length 172
...


**Step 5: Replace pre shared key**

After a period of time, the pre shared key of the cluster can be changed. After changing the pre shared key, the ESP SPI number of the IPsec used for communication between nodes will be increased by 1 compared to the previous version. You can be observed again through tcpdump. The initial IPSec SPI version number is 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This paragraph has some grammatical issues and awkward phrasing that could be improved for clarity:

  • "pre shared key" should be hyphenated: "pre-shared key".
  • "You can be observed again through tcpdump" is passive and awkward. "This can be observed..." is better.
  • "The initial IPSec SPI version number is 1" is slightly inaccurate. SPI is a Security Parameter Index, not a version number.

Here is a suggested revision:

Suggested change
After a period of time, the pre shared key of the cluster can be changed. After changing the pre shared key, the ESP SPI number of the IPsec used for communication between nodes will be increased by 1 compared to the previous version. You can be observed again through tcpdump. The initial IPSec SPI version number is 1
After a period of time, the pre-shared key of the cluster can be changed. After changing the pre-shared key, the ESP SPI (Security Parameter Index) for IPsec communication between nodes will be incremented. This can be observed again using `tcpdump`. The initial IPsec SPI is 1.

Comment on lines 66 to 72
root@master:~/kmesh# tcpdump -i any |grep ESP
...
14:26:33.782665 ? Out IP master > node1: ESP(spi=0x00000002,seq=0x1aaa1), length 80
14:26:33.782666 ? Out IP master > node1: ESP(spi=0x00000002,seq=0x1aaa2), length 80
14:26:33.782667 ? In IP node1 > master: ESP(spi=0x00000002,seq=0x183d2), length 80
14:26:33.782667 ? In IP node1 > master: ESP(spi=0x00000002,seq=0x183d3), length 80
...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For correct rendering and readability, this tcpdump output should be enclosed in a markdown code block.

Suggested change
root@master:~/kmesh# tcpdump -i any |grep ESP
...
14:26:33.782665 ? Out IP master > node1: ESP(spi=0x00000002,seq=0x1aaa1), length 80
14:26:33.782666 ? Out IP master > node1: ESP(spi=0x00000002,seq=0x1aaa2), length 80
14:26:33.782667 ? In IP node1 > master: ESP(spi=0x00000002,seq=0x183d2), length 80
14:26:33.782667 ? In IP node1 > master: ESP(spi=0x00000002,seq=0x183d3), length 80
...
root@master:~/kmesh# tcpdump -i any |grep ESP
...
14:26:33.782665 ? Out IP master > node1: ESP(spi=0x00000002,seq=0x1aaa1), length 80
14:26:33.782666 ? Out IP master > node1: ESP(spi=0x00000002,seq=0x1aaa2), length 80
14:26:33.782667 ? In IP node1 > master: ESP(spi=0x00000002,seq=0x183d2), length 80
14:26:33.782667 ? In IP node1 > master: ESP(spi=0x00000002,seq=0x183d3), length 80
...

Comment on lines 76 to 78
1、 IPsec encryption uses mark `0xe0` and `0xd0` as markers for IPsec encryption and decryption. Please ensure that no conflicting Makr is used on the host network, otherwise unknown behavior may occur

2、Please ensure that `address MASQ` is not used on packets encrypted with IPsec. After address MASQ, IPsec cannot accurately match encryption and decryption rules, which can result in packet loss

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This section has a few issues that affect clarity and correctness:

  1. The list numbering (1、, 2、) is non-standard for Markdown. It should be 1. and 2..
  2. There is a typo in the first point: "Makr" should be "Mark".
  3. The term address MASQ in the second point should be clarified for users who may not be familiar with it.
  4. The phrasing could be improved for better readability.

Here is a suggested revision:

Suggested change
1 IPsec encryption uses mark `0xe0` and `0xd0` as markers for IPsec encryption and decryption. Please ensure that no conflicting Makr is used on the host network, otherwise unknown behavior may occur
2Please ensure that `address MASQ` is not used on packets encrypted with IPsec. After address MASQ, IPsec cannot accurately match encryption and decryption rules, which can result in packet loss
1. IPsec encryption uses `fwmark` `0xe0` and `0xd0` for encryption and decryption. Please ensure that no conflicting marks are used on the host network, as this may cause unexpected behavior.
2. Please ensure that address masquerading (`MASQ`) is not used on packets that have been encrypted with IPsec. Applying `MASQ` after encryption can prevent IPsec from correctly matching decryption rules, resulting in packet loss.

...
args:
[
"./start_kmesh.sh --mode=dual-engine --enable-bypass=false --enable-ipsec=true",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We need to add a triger for the IPSec to control its enable or disable. To above restarting kmesh-daemon everytime when enable or disable IPsec

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, this is a point that can be enhanced.

Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address some comments

Copy link

netlify bot commented Jul 28, 2025

Deploy Preview for kmesh-net ready!

Name Link
🔨 Latest commit f06c1c5
🔍 Latest deploy log https://app.netlify.com/projects/kmesh-net/deploys/68abc49a3fed92000841990a
😎 Deploy Preview https://deploy-preview-210--kmesh-net.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@zrggw
Copy link
Contributor Author

zrggw commented Jul 28, 2025

I have revised ipsec user guide.

@zrggw
Copy link
Contributor Author

zrggw commented Jul 28, 2025

@hzxuzhonghu
Copy link
Member

/lgtm

@kmesh-bot kmesh-bot removed the lgtm label Aug 25, 2025
Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@kmesh-bot kmesh-bot added the lgtm label Aug 25, 2025
@hzxuzhonghu
Copy link
Member

/approve

@kmesh-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzxuzhonghu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hzxuzhonghu
Copy link
Member

The dir does not exists now, can you please rebase

@zrggw
Copy link
Contributor Author

zrggw commented Aug 25, 2025

I will change the file location and replace the kmeshctl-secret.md file.

@zrggw zrggw closed this Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants