<p>I have a server deployment with Horizontal scaling. The deployment will have 3-5 pods at any given time based on the load.
I use volume mapping to pass configuration data to the deployed server pods. I have to call a reload function in my server app for it to work with the updated configuration without restarting the pod.</p>
<p>I use a separate .net web API app to change the config file in volume mapping (as it gets updated often).
I am trying to use the Kubernetes client to list all my application pods and then execute a refresh command.
I got an error with the refresh command, so I checked with the &quot;ls&quot; command but got the same issue.</p>
<p>I have also provided the account with rbac permissions to list the pods and execute in the pods.</p>
<p>Below are the permission rules I added.</p>
<pre><code>- apiGroups: [&quot;&quot;]
  resources: [&quot;pods&quot;]
  verbs: [&quot;get&quot;, &quot;list&quot;, &quot;watch&quot;]
- apiGroups: [&quot;&quot;]
  resources: [&quot;pods/exec&quot;]
  verbs: [&quot;create&quot;]
</code></pre>
<p>Here is the sample code.</p>
<pre><code>
 V1PodList list = _client.CoreV1.ListNamespacedPod(&quot;development&quot;, labelSelector:app=MyAppSelector&quot;);
 foreach (V1Pod item in list.Items)
 {
    var webSocket = await client.WebSocketNamespacedPodExecAsync(item.Metadata.Name, &quot;default&quot;, &quot;ls&quot;,
        item.Spec.Containers[0].Name).ConfigureAwait(false);
    var demux = new StreamDemuxer(webSocket);
    demux.Start();
    var buff = new byte[4096];
    var stream = demux.GetStream(1, 1);
    var read = stream.Read(buff, 0, 4096);
    var str = System.Text.Encoding.Default.GetString(buff);
    Console.WriteLine(str);
}
</code></pre>
<p>Below issue occurs at the line &quot;var webSocket = await client.WebSocketNamespacedPodExecAsync&quot;</p>
<p><code>Unhandled exception. System.Net.WebSockets.WebSocketException (0x80004005): The server returned status code '403' when status code '101' was expected.</code></p>
<p>I want the client.WebSocketNamespacedPodExecAsync method to execute the reload command in my sever pods.</p>
<p>Can you help me regarding this or guide me if I am doing anything wrong?
Also suggest me if any other alternatie approaches are available for this scenario.</p>

Navin Vinayagam
<p>If you update a configmap which is mounted as a volume in a pod, then within a minute or two, that change is reflected within the pod's file system.</p>
<p>Can you not have a background thread in the application that watches for a change in the mounted configuration that will then call the reload method when it sees a change? Then you don't need to mess around with another utility that has to connect to all instances of the service and call a reload endpoint.</p>
