<p>I am working on a requirement wherein we want to update a specific kernel parameter &quot;net.ipv4.tcp_retries2&quot; to &quot;5&quot; in the Kubernetes POD.</p>
<p><strong>We are using AKS cluster v1.21.7</strong></p>
<p>I tried using securityContext to set the above sysctl parameters but it failed</p>
<pre><code>  template:
    metadata:
      labels:
        app.kubernetes.io/name: weather-forecast-api
        app.kubernetes.io/instance: RELEASE-NAME
    spec:
      serviceAccountName: RELEASE-NAME-weather-forecast-api
      securityContext:
        sysctls:
        - name: net.ipv4.tcp_retries2
          value: &quot;5&quot;
</code></pre>
<p>When I applied the above changes in the AKS, the pod failed to run and gave the error</p>
<blockquote>
<p>forbidden sysctl: &quot;net.ipv4.tcp_retries2&quot; not whitelisted</p>
</blockquote>
<p>I know we can modify kernel-level settings at the Kubelet level on a bare-bone Kubernetes cluster but in my case, it is a managed cluster from Azure.</p>

<p>Use an init container to set:</p>
<pre><code>...
template:
  metadata:
    labels:
      app.kubernetes.io/name: weather-forecast-api
      app.kubernetes.io/instance: RELEASE-NAME
  spec:
    serviceAccountName: RELEASE-NAME-weather-forecast-api
    initContainers:
    - name: sysctl
      image: busybox
      securityContext:
        privileged: true
      command: [&quot;sh&quot;, &quot;-c&quot;, &quot;sysctl -w net.ipv4.tcp_retries2=3&quot;]
    ...
</code></pre>
