Skip to content

Commit ee2b49f

Browse files
yk-mt12claude
andcommitted
docs: Add allowedUnsafeSysctls configuration example for AL2023
Add comprehensive documentation showing how to configure allowedUnsafeSysctls using NodeConfig in EC2NodeClass userData for AL2023 AMI family. This documentation includes: - Security warning about using unsafe sysctls - Use case examples (high-performance networking, connection handling) - EC2NodeClass configuration example with allowedUnsafeSysctls - Reference to Kubernetes documentation for Pod usage This addresses the gap in documentation for configuring unsafe sysctls, which is not available in spec.kubelet but can be configured through UserData using the NodeConfig format. Related issue: #2099 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 840d752 commit ee2b49f

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

website/content/en/preview/concepts/nodeclasses.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,47 @@ spec:
298298
Note that when using the `Custom` AMIFamily you will need to specify fields **both** in `spec.kubelet` and `spec.userData`.
299299
{{% /alert %}}
300300

301+
#### Configuring Unsafe Sysctls
302+
303+
Similarly, you can configure `allowedUnsafeSysctls` for AL2023 using the NodeConfig format in UserData:
304+
305+
{{% alert title="Warning" color="warning" %}}
306+
Unsafe sysctls are disabled by default because they can potentially affect the stability and security of the node or other pods on the same node. Only enable unsafe sysctls if you understand the implications and have a specific use case that requires them. Make sure to test thoroughly in non-production environments first.
307+
{{% /alert %}}
308+
309+
**Use Case:** Some applications require specific kernel parameter modifications to achieve optimal performance or functionality. For example:
310+
- High-performance networking applications may need to adjust `net.core.somaxconn` to handle more simultaneous connections
311+
- Applications handling many short-lived connections may benefit from `net.ipv4.tcp_tw_reuse` to reuse TIME-WAIT sockets faster
312+
313+
**Node Configuration Example:**
314+
315+
```yaml
316+
apiVersion: karpenter.k8s.aws/v1
317+
kind: EC2NodeClass
318+
metadata:
319+
name: unsafe-sysctls
320+
spec:
321+
amiSelectorTerms:
322+
- alias: al2023@latest
323+
userData: |
324+
apiVersion: node.eks.aws/v1alpha1
325+
kind: NodeConfig
326+
spec:
327+
kubelet:
328+
config:
329+
allowedUnsafeSysctls:
330+
- net.core.somaxconn
331+
- net.ipv4.tcp_tw_reuse
332+
```
333+
334+
**Using Sysctls in Pods:**
335+
336+
Once the node is configured with `allowedUnsafeSysctls`, you can use the sysctls in your Pod specifications via the `securityContext.sysctls` field. For detailed information on how to configure sysctls in your Pods, see the [Kubernetes documentation on sysctls](https://kubernetes.io/docs/tasks/administer-cluster/sysctl-cluster/).
337+
338+
{{% alert title="Note" color="primary" %}}
339+
The sysctls specified in the Pod must be included in the node's `allowedUnsafeSysctls` list. If you try to use a sysctl that is not allowed, the Pod will fail to start with an error.
340+
{{% /alert %}}
341+
301342
#### Pods Per Core
302343

303344
An alternative way to dynamically set the maximum density of pods on a node is to use the `.spec.kubelet.podsPerCore` value. Karpenter will calculate the pod density during scheduling by multiplying this value by the number of logical cores (vCPUs) on an instance type. This value will also be passed through to the `--pods-per-core` value on kubelet startup to configure the number of allocatable pods the kubelet can assign to the node instance.

0 commit comments

Comments
 (0)