<p>I am trying to programmatically connect to my AWS EKS cluster using the official <a href="https://github.com/kubernetes-client/javascript" rel="nofollow noreferrer">k8s JavaScript Client</a>. I wanted to try and use <code>loadFromOptions()</code>, instead of <code>loadFromDefault()</code>. So, from the <code>README.md</code> of the library repo, I was able to come up with the following</p>
<pre class="lang-js prettyprint-override"><code>const k8s = require('@kubernetes/client-node');
const kc = new k8s.KubeConfig();

const cluster = {
    name: 'NAME',
    server: 'SERVER',
};
const user = {
    name: 'NAME',
    exec: {
        apiVersion: 'client.authentication.k8s.io/v1alpha1',
        args: [
            '--region',
            'us-east-1',
            'eks',
            'get-token',
            '--cluster-name',
            'NAME',
        ],
        command: 'aws',
        env: [
            {
                name: 'AWS_PROFILE',
                value: 'NAME'
            }
        ]
    }
}
const context = {
    name: 'NAME',
    user: user.name,
    cluster: cluster.name,
};

kc.loadFromOptions({
    clusters: [cluster],
    users: [user],
    contexts: [context],
    currentContext: context.name,
});

const k8sApi = kc.makeApiClient(k8s.CoreV1Api);

k8sApi.listNamespacedPod('default').then((res) =&gt; {
    console.log(res.body);
});
</code></pre>
<p>But unfortunately, I am hit with this error, where am I going wrong?</p>
<p><a href="https://i.stack.imgur.com/KS07V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KS07V.png" alt="error" /></a></p>

Tharun K
<p>The error message is complaining that it does not know the cluster's certificate issuer.<br />
Your <code>cluster</code> object needs one of the following properties to specify the certificate authority:</p>
<ul>
<li><code>caFile</code>: Filename containing the certificate authority</li>
<li><code>caData</code>: Base64-encoded contents of the certificate authority file</li>
</ul>
<p>According to <a href="https://docs.aws.amazon.com/eks/latest/userguide/create-kubeconfig.html" rel="nofollow noreferrer">the AWS documentation</a>, you should be able to retrieve the certificate authority as &quot;the <code>certificateAuthority.data</code> that was created for your cluster&quot;.</p>
