# Setting custom sysctl variables in AWX Pods

**URL:** <https://forum.ansible.com/t/setting-custom-sysctl-variables-in-awx-pods/4630>\
**Category:** Get Help\
**Tags:** kubernetes, awx-operator, awx\
**Created:** [March 29, 2024, 12:01pm UTC](https://forum.ansible.com/t/setting-custom-sysctl-variables-in-awx-pods/4630 "2024-03-29T12:01:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leon](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/leon/32/2546_2.png) [@Leon](https://forum.ansible.com/u/Leon)\
**Post date:** [March 29, 2024, 12:01pm UTC](https://forum.ansible.com/t/setting-custom-sysctl-variables-in-awx-pods/4630/1 "2024-03-29T12:01:15Z")

</div>

Hello All,

Is it possible to set sysctl variables with security context to postgresql pod?  
With kubernetes itself support it.

> **[Using sysctls in a Kubernetes Cluster](https://kubernetes.io/docs/tasks/administer-cluster/sysctl-cluster/#enabling-unsafe-sysctls)**
>
> FEATURE STATE: Kubernetes v1.21 \[stable\] This document describes how to configure and use kernel parameters within a Kubernetes cluster using the sysctl interface.
> Note:Starting from Kubernetes version 1.23, the kubelet supports the use of either /...

```auto
postgres_security_context_settings:

```

Thanks

---

<div class="post-metadata">

**Author:** ![kurokobo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kurokobo/32/182_2.png) [@kurokobo](https://forum.ansible.com/u/kurokobo)\
**Post date:** [March 29, 2024, 12:15pm UTC](https://forum.ansible.com/t/setting-custom-sysctl-variables-in-awx-pods/4630/2 "2024-03-29T12:15:36Z")

</div>

Hi, you have already found `postgres_security_context_settings`, which is the answer. Use that parameter to add any `securityContext`.

---

<div class="post-metadata">

**Author:** ![Leon](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/leon/32/2546_2.png) [@Leon](https://forum.ansible.com/u/Leon)\
**Post date:** [March 29, 2024, 1:03pm UTC](https://forum.ansible.com/t/setting-custom-sysctl-variables-in-awx-pods/4630/3 "2024-03-29T13:03:45Z")

</div>

Thank you very much for the answer @kurokobo !

I changed my spec as this;

```yaml
  # Security context
  postgres_security_context_settings:
    sysctls:
      - name: net.core.somaxconn
        value: "3072"

```

Yet i still get default value.

```bash
% kubectl exec awx-acc-postgres-15-0 -- sysctl net.core.somaxconn
net.core.somaxconn = 4096

```

PS: I restart the statefulsets also.

---

<div class="post-metadata">

**Author:** ![Leon](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/leon/32/2546_2.png) [@Leon](https://forum.ansible.com/u/Leon)\
**Post date:** [March 29, 2024, 1:59pm UTC](https://forum.ansible.com/t/setting-custom-sysctl-variables-in-awx-pods/4630/4 "2024-03-29T13:59:12Z")

</div>

I think its about my node settings. I will check further. Would like to inform.

```auto
% kubectl rollout restart deployment
deployment.apps/awx-acc-task restarted
Warning: would violate PodSecurity "baseline:v1.24": forbidden sysctls (net.core.somaxconn)
deployment.apps/awx-acc-web restarted
deployment.apps/awx-operator-controller-manager restarted

```

---

<div class="post-metadata">

**Author:** ![kurokobo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kurokobo/32/182_2.png) [@kurokobo](https://forum.ansible.com/u/kurokobo)\
**Post date:** [March 29, 2024, 2:12pm UTC](https://forum.ansible.com/t/setting-custom-sysctl-variables-in-awx-pods/4630/5 "2024-03-29T14:12:34Z")

</div>

Yes, many keys in sysctl are `unsafe` and usually need to be explicitly allowed by `allowedUnsafeSysctls` to be modified on a per-pod basis.  
I don’t know which distribution you are using but there should be a way to specify `allowedUnsafeSysctls` e.g. args for kubelet, KubeletConfig, PodSecurityPolicy, etc.
