<p>For internal purpose, I'm building a dashboard application.
In this dashboard I need to display some info about Kubernetes (running pods, clusters, etc).</p>

<p>I'm trying to call my Kubernetes API from my web app (from browser).
Url of API is <code>http://localhost:8001/api/v1/</code></p>

<p>I'm getting error on fetch data (CORS origin not allowed).</p>

<p>I've search on internet for hours trying to find solution but nothing is working.
I know there is other stack post giving some solution but I'm not sure how to apply it.
For ex. : <a href="https://stackoverflow.com/questions/34117640/enabling-cors-in-kubernetes-api">Enabling CORS in Kubernetes API</a></p>

<p>Any of you know how to allow CORS origin on Kubernetes API (Docker for windows)?</p>

<p>Note: I'm using <code>kubectl proxy</code></p>

G. Frx
<p>You can edit kubernetes API server yaml file, to get CORS working.</p>

<p>Add line <strong>--cors-allowed-origins=["http://*"]</strong> argument to <strong>/etc/default/kube-apiserver</strong> or <strong>/etc/kubernetes/manifests/kube-apiserver.yaml</strong> file, it depends where your kube-apiserver configuration file is located. </p>

<pre><code>spec:
containers:
- command:
  - kube-apiserver
  - --cors-allowed-origins=["http://*"]
</code></pre>

<p>Restart kube-apiserver.</p>

<p>Then add annotation to service configuration to <code>dns.alpha.kubernetes.io/external: "http://localhost:8001/api/v1/"</code> in your service configuration file and apply changes.</p>
