godaddy / kubernetes-client

Simplified Kubernetes API client for Node.js.
MIT License
961 stars 192 forks source link

how to fix "Error: getaddrinfo ENOTFOUND https" when using in-cluster-auth #677

Closed rubenrajkowski-nbcuni closed 3 years ago

rubenrajkowski-nbcuni commented 3 years ago

I've tried updating protocol=http, and port=80 and get similar Error: getaddrinfo ENOTFOUND http

.zshrc file

export KUBERNETES_SERVICE_HOST="https://{ACCOUNT_ID}.us-west-2.eks.amazonaws.com"
export KUBERNETES_SERVICE_PORT="443"

example used

https://github.com/godaddy/kubernetes-client/blob/de189a65fcf7cc5c3d711c7508e8beacbea4d444/examples/in-cluster-auth.js

code example:

const listK8Pods = async() => {
  try{
    const pods = await client.api.v1.pods.get();
    return pods.body.items.forEach((item) => {
      logger.accessLog.info('POD: '+item.metadata);
      return item.metadata;
    });
  }catch(err){
    throw err;
  }
};
console.log('list pods: '+ listK8Pods());
rubenrajkowski-nbcuni commented 3 years ago

Closing out this issue. I realized i need to use minikube or telepresence to connect to a remote cluster. thanks!