-
Notifications
You must be signed in to change notification settings - Fork 45
ipsec: modified ipsec user guide #210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: bitcoffee <[email protected]>
Signed-off-by: aicee <[email protected]>
Welcome @zrggw! It looks like this is your first PR to kmesh-net/website 🎉 |
There was a problem hiding this 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 thekmesh.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 whenaddress 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
-
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. ↩
There was a problem hiding this 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)** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
**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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs: | ||
parent: user guide | ||
weight: 21 | ||
title: use IPsec in Kmesh cluster |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
### 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kmesh.yaml | ||
... | ||
args: | ||
[ | ||
"./start_kmesh.sh --mode=dual-engine --enable-bypass=false --enable-ipsec=true", | ||
] | ||
... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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" | |
... |
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 | ||
... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For correct rendering and readability, this tcpdump
output should be enclosed in a markdown code block.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
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. |
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 | ||
... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For correct rendering and readability, this tcpdump
output should be enclosed in a markdown code block.
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 | |
... |
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section has a few issues that affect clarity and correctness:
- The list numbering (
1、
,2、
) is non-standard for Markdown. It should be1.
and2.
. - There is a typo in the first point: "Makr" should be "Mark".
- The term
address MASQ
in the second point should be clarified for users who may not be familiar with it. - The phrasing could be improved for better readability.
Here is a suggested revision:
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 | |
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", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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
Signed-off-by: aicee <[email protected]>
✅ Deploy Preview for kmesh-net ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
I have revised ipsec user guide. |
Signed-off-by: aicee <[email protected]>
/lgtm |
Signed-off-by: aicee <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve |
[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 |
The dir does not exists now, can you please rebase |
I will change the file location and replace the kmeshctl-secret.md file. |
modified ipsec user guide according to the review of PR #105