> For the complete documentation index, see [llms.txt](https://platform9.com/kb/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://platform9.com/kb/pmk/how-to/how-to-allow-unsafe-sysctls-on-a-pmk-cluster.md).

# How to Allow Unsafe Sysctls on a PMK Cluster

## Problem

How to Allow Unsafe Sysctls on a PMK Cluster?

## Environment

* Platform9 Managed Kubernetes - All Versions
* Kubelet

## Procedure

* Depending on whether the change is needed to be done on a single node or all nodes part of the cluster, refer to

[How To Change Configuration for Kubelet Service on a Single Worker or Master Node in a PMK Cluster](https://platform9.com/kb/kubernetes/single-node-change-config-kubelet-service)

OR

[How To Change Configuration for Kubelet Service on All Worker or Master Nodes in a PMK Cluster](https://platform9.com/kb/kubernetes/change-configuration-for-kubelet-service#procedure)

* Stop the *pf9-hostagent* & *pf9-nodeletd* services on **ALL** the worker/master nodes depending on which configmap is being edited.

{% tabs %}
{% tab title="Bash" %}

```bash
sudo systemctl stop pf9-{hostagent,nodeletd}
```

{% endtab %}
{% endtabs %}

* Edit the ConfigMap as needed and save it. Here as an example, we are editing it *master-default-kubelet-config* ConfigMap for the single master node cluster.

{% tabs %}
{% tab title="Example" %}

```bash
# kubectl get configmap master-default-kubelet-config  -n kube-system -o yaml
...
    allowedUnsafeSysctls:
    - "kernel.msg*"
    - "net.core.somaxconn"
```

{% endtab %}
{% endtabs %}

* Start the *pf9-hostagent* service **ALL** the worker/master nodes where it was initially stopped.

{% tabs %}
{% tab title="Bash" %}

```bash
sudo systemctl start pf9-hostagent
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="On Master node post-Kubelet restart (it initially always logs the default values, then loads the new config)" %}

```bash
# less /var/log/pf9/kubelet/kubelet.INFO | grep -i unsafe
I0209 01:40:12.118508   10415 flags.go:59] FLAG: --allowed-unsafe-sysctls="[]"
...
I0209 01:40:12.161606   10415 controller.go:267] kubelet config controller: ensuring filesystem is set up correctly
I0209 01:40:12.161624   10415 fsstore.go:59] kubelet config controller: initializing config checkpoints directory "/var/opt/pf9/kube/kubelet-config/dynamic-config/store"
I0209 01:40:12.163696   10415 fsstore.go:116] kubelet config controller: loading Kubelet configuration checkpoint for source /api/v1/namespaces/kube-system/configmaps/master-default-kubelet-config, UID: ae560d51-931a-4a1c-ae90-0ea9fee5d5b7, ResourceVersion: 1187451
```

{% endtab %}
{% endtabs %}

* Deployed a pod with security context.

{% tabs %}
{% tab title="Pod Spec" %}

```bash
# cat pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  securityContext:
    sysctls:
    - name: kernel.shm_rmid_forced
      value: "0"
    - name: net.core.somaxconn
      value: "1024"
    - name: kernel.msgmax
      value: "65536"
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
```

{% endtab %}
{% endtabs %}

* Pod has been created and is in running state.

{% tabs %}
{% tab title="Example" %}

```bash
# kubectl get pods
NAME    READY   STATUS    RESTARTS   AGE
nginx   1/1     Running   0          67s
```

{% endtab %}
{% endtabs %}

* If we deploy the same pod on a different cluster which does not have the Kubelet setting for *allowedUnsafeSysctls* added.

{% tabs %}
{% tab title="Example" %}

```bash
# kubectl get pods
NAME    READY   STATUS            RESTARTS   AGE
nginx   0/1     SysctlForbidden   0          13s

# kubectl describe pod nginx
Events:
  Type     Reason           Age        From                     Message
  ----     ------           ----       ----                     -------
  Normal   Scheduled        <unknown>                           Successfully assigned default/nginx to 10.128.146.164
  Warning  SysctlForbidden  27s        kubelet, 10.128.146.164  forbidden sysctl: "net.core.somaxconn" not whitelisted
```

{% endtab %}
{% endtabs %}

## Additional Information

[Using sysctls in a Kubernetes Cluster](https://kubernetes.io/docs/tasks/administer-cluster/sysctl-cluster/)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://platform9.com/kb/pmk/how-to/how-to-allow-unsafe-sysctls-on-a-pmk-cluster.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
