javascript icon indicating copy to clipboard operation
javascript copied to clipboard

proxy-url in kube config not used

Open jalkjaer opened this issue 2 years ago • 16 comments

Cluster config in kube config allows proxy-url setting (i.e. proxy-url: http://127.0.1.1:8080) but is not used in the js lib

** Client Version ** e.g. 0.13.6

** Server Version ** doesn't apply

To Reproduce Running the example from the main README.md with the current context pointing to a cluster that is configured with proxy-url, the example with throw "connect EHOSTUNREACH" when the cluster IP is not directly accessible.

Running the example with the env var HTTP_PROXY works as expected

Expected behavior The clientlib should respect the proxy-url setting

** Example Code**

const k8s = require('@kubernetes/client-node');

const kc = new k8s.KubeConfig();
kc.loadFromDefault();

const k8sApi = kc.makeApiClient(k8s.CoreV1Api);
k8sApi.listNamespacedPod('default').then((res) => {
    console.log(res.body);
}).catch(console.error);

Environment (please complete the following information):

  • OS: Linux
  • NodeJS Version 12.10.0

jalkjaer avatar Aug 01 '22 10:08 jalkjaer

Relevant pointers:

  • https://github.com/kubernetes/client-go/issues/351
  • https://github.com/kubernetes/kubernetes/pull/81443
  • https://github.com/kubernetes/kubernetes/blob/f02682c628c530219966a00ae002d799f0d813dc/staging/src/k8s.io/client-go/rest/config.go#L137-L139

This really points out the need for a clean spec for the kubeconfig file, since this never went through a KEP or anything else and just merged.

I'm happy to take a PR to add support for this, otherwise, we will get to it eventually.

brendandburns avatar Aug 08 '22 19:08 brendandburns

Full implementation, obviously, is going to take time. Is that possible to start applying some fixes related to this issue? For example, stop filtering 'proxy-url' property while loading cluster configuration from config here.

dgolovin avatar Aug 15 '22 20:08 dgolovin

I would like to try to provide a PR for this.

Could someone recommend a way to set up a test environment for this? Would it be correct to assume that if I have a Kubernetes cluster and do a kubectl proxy --port <number> and set the proxy URL to http://127.0.01:<number> in my kubeconfig that this is a valid way to test this? Or do I need to set up a nginx reverse proxy for this?

mstruebing avatar Aug 17 '22 11:08 mstruebing

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Feb 07 '23 23:02 k8s-triage-robot

Any update on this? I am running into the same issue

bradyburke avatar Feb 10 '23 22:02 bradyburke

/remove-lifecycle stale

bradyburke avatar Feb 22 '23 22:02 bradyburke

Any update on this issue?

bradyburke avatar Feb 22 '23 22:02 bradyburke

please assign me this issue.

himanshusharma27 avatar Apr 03 '23 04:04 himanshusharma27

/assign

SD007CSE avatar Apr 17 '23 05:04 SD007CSE

I am having an issue for kube test and kube run docs Screenshot 2023-05-10 at 3 31 58 AM

SD007CSE avatar May 10 '23 07:05 SD007CSE

@brendandburns Help me out

SD007CSE avatar May 10 '23 07:05 SD007CSE

I am having an issue for kube test and kube run docs Screenshot 2023-05-10 at 3 31 58 AM

Hello Mybe You Can Try import { BsModalModule } from 'ng2-bs3-modal'; Mybe This Will Help

j4acks0n avatar May 14 '23 14:05 j4acks0n

Any update on this issue? Hello, Mybe You Can Try This Multiple Solution Way 1.Export KubeConfig To Path Directory Yaml Or Way 2.Paste The Yaml to YourDirectory/.Kube/Config

j4acks0n avatar May 14 '23 14:05 j4acks0n

Actually in most of the .ts files which have "/api" it showing the the problem Module `'"./api"' has no exported member 'V1Secret'.ts(2305)``

SD007CSE avatar May 15 '23 11:05 SD007CSE

Hi Guys ! Until this is solved I did a simple hack to be able to use proxy-url. I've override the KubeConfig makeApiClient method to be able to override the "request" configuration. It's not super safe but runs

Here the code

    const kc = new k8s.KubeConfig();
    const originalMakeApiClient = kc.makeApiClient;
    kc.makeApiClient = function(api) {
        const client = originalMakeApiClient.call(kc, api);
        client.interceptors.push(async (config) => {
            config.proxy="http://host:port";
        });
        return client;
    };

geisbruch avatar May 21 '24 14:05 geisbruch