Skip to content

proxy-url in kube config not used #853

Closed

Description

@jalkjaer

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

Activity

  1. brendandburns commented on Aug 8, 2022

    @brendandburns
    Contributor

    Relevant pointers:

    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.

  2. added
    good first issue
    on Aug 8, 2022
  3. dgolovin commented on Aug 15, 2022

    @dgolovin

    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.

  4. mstruebing commented on Aug 17, 2022

    @mstruebing
    Member

    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?

  5. k8s-triage-robot commented on Feb 7, 2023

    @k8s-triage-robot

    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

  6. added
    lifecycle/stale
    on Feb 7, 2023
  7. bradyburke commented on Feb 10, 2023

    @bradyburke

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

  8. bradyburke commented on Feb 22, 2023

    @bradyburke

    /remove-lifecycle stale

  9. removed
    lifecycle/stale
    on Feb 22, 2023
  10. bradyburke commented on Feb 22, 2023

    @bradyburke

    Any update on this issue?

  11. himanshusharma27 commented on Apr 3, 2023

    @himanshusharma27

    please assign me this issue.

  12. SD007CSE commented on Apr 17, 2023

    @SD007CSE

    /assign

  13. SD007CSE commented on May 10, 2023

    @SD007CSE

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

  14. SD007CSE commented on May 10, 2023

    @SD007CSE

    @brendandburns Help me out

  15. j4acks0n commented on May 14, 2023

    @j4acks0n

    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

  16. j4acks0n commented on May 14, 2023

    @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

  17. SD007CSE commented on May 15, 2023

    @SD007CSE

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

  18. geisbruch commented on May 21, 2024

    @geisbruch

    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;
        };
  19. kc1r74p commented on Aug 18, 2024

    @kc1r74p

    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;
        };

    Thanks for your initial workaround.
    Still had issues when using k8s.Log(kc); as it seems not to apply to all requests.

    Solved it for me using:

        const originalApply = kc.applyToRequest;
        kc.applyToRequest = function(options) {
            originalApply.call(kc, options);
            // process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
            options.proxy = 'http://proxy:port';
        };

    Works for normal api calls and log.
    In case someone also wants to use a socks proxy, currently can only recommend a workaround via:
    hpts -s socksProxy:socksPort -p 8888 using http-proxy-to-socks.

    Best would be a migration away from request to got or some client which has better proxy support.

  20. krmodelski commented on Dec 4, 2024

    @krmodelski
    Contributor

    /assign

  21. cjihrig commented on Dec 20, 2024

    @cjihrig
    Contributor

    This landed on both release lines in #2091 and #2111.

    /close

  22. k8s-ci-robot commented on Dec 20, 2024

    @k8s-ci-robot
    Contributor

    @cjihrig: Closing this issue.

    Details

    In response to this:

    This landed on both release lines in #2091 and #2111.

    /close

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

good first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions