Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Proxy in Webhook client #88

Closed
jan-mrm opened this issue Jul 26, 2024 · 14 comments · Fixed by #89
Closed

Support Proxy in Webhook client #88

jan-mrm opened this issue Jul 26, 2024 · 14 comments · Fixed by #89
Assignees

Comments

@jan-mrm
Copy link

jan-mrm commented Jul 26, 2024

Hey, I was wondering if the webhook client should already honor the HTTPS_PROXY environment variable or not?
I set

env:
  - name: "HTTPS_PROXY"
    value: "http://someProxy:somePort"
args:
  - "-webhook.url=https://myWebhook"
  - "-webhook.template-file=/files/webhook.json"
  - "-webhook.contentType=application/json"
  - "-webhook.method=POST"
  - "-webhook.timeout=30s"

and it does seem to be used, since if I do not set the NO_PROXY correctly the pod cannot start.

But the webhook requests seem to not go to the configured proxy.

Can a proxy be configured for the webhook client already, if so how?

Else this would be a feature request if possible :)

@maksim-paskal
Copy link
Owner

@jan-mrm, thanks for raising this issue. It's a quick fix. The webhook uses a custom HTTP client, and proxy support is not included. I will enable this.

@maksim-paskal
Copy link
Owner

@jan-mrm please test my change (you need Linux amd64 node), I don't have any proxy for test my change.

image: paskalmaksim/aks-node-termination-handler:dev
imagePullPolicy: Always
env:
- name: "HTTPS_PROXY"
  value: "http://someProxy:somePort"
args:
  - "-webhook.url=https://myWebhook"
  - "-webhook.template-file=/files/webhook.json"
  - "-webhook.contentType=application/json"
  - "-webhook.method=POST"
  - "-webhook.timeout=30s"

If test will be OK - I will release this change.

@jan-mrm
Copy link
Author

jan-mrm commented Jul 28, 2024

@maksim-paskal thank you, I'm able to test it tomorrow and will report back

@jan-mrm
Copy link
Author

jan-mrm commented Jul 29, 2024

@maksim-paskal works like a charm for me 🙂 appreciate that 👍

@jan-mrm
Copy link
Author

jan-mrm commented Jul 29, 2024

not sure if that change might be some sort of "breaking" for users since they do not expect the proxy to be used at the moment? just a thought, but it would be known in the release notes, so it should be good.

@maksim-paskal
Copy link
Owner

@jan-mrm thanks for quick response, one question about your usage of proxy. For context, this tool can make two type of http request:

  1. Azure Metadata Service http://169.254.169.254
  2. (optiontal) Webhooks

You need PROXY only for webhooks or also for Azure Metadata Service?

@jan-mrm
Copy link
Author

jan-mrm commented Jul 29, 2024

@jan-mrm thanks for quick response, one question about your usage of proxy. For context, this tool can make two type of http request:

  1. Azure Metadata Service http://169.254.169.254
  2. (optiontal) Webhooks

You need PROXY only for webhooks or also for Azure Metadata Service?

I'd only need it for the Webhook request. In my case the Azure Metadata Service would not need to go through the proxy (I would even put it into the NO_PROXY if the proxy would be used for that request)

@maksim-paskal
Copy link
Owner

Ok, I will use proxy settings (default NO_PROXY) only for Webhooks requests. You are right, I think this change will not break any user experience.

I make some changes, to enable proxy only for webhooks. Can you test it again? You need to restart your pods

kubectl -n kube-system delete pods -lapp=aks-node-termination-handler

@jan-mrm
Copy link
Author

jan-mrm commented Jul 29, 2024

Ok, I will use proxy settings (default NO_PROXY) only for Webhooks requests. You are right, I think this change will not break any user experience.

I make some changes, to enable proxy only for webhooks. Can you test it again? You need to restart your pods

kubectl -n kube-system delete pods -lapp=aks-node-termination-handler

still works for me.

But one additional hint: I do have to set an env var NO_PROXY (which is ok, just an fyi) since the proxy is also used for cluster requests

{"error":"error in startReadingEvents: error in getting azure resource name: error in Clientset.CoreV1().Nodes().Get: Get "https://CLUSTERIP:443/api/v1/nodes/MYNODE\": AuthorizedOnly","file":"github.com/maksim-paskal/aks-node-termination-handler/cmd/main.go:86","func":"main.main","level":"fatal","msg":"","time":"SOMETIME"}

@jan-mrm
Copy link
Author

jan-mrm commented Jul 29, 2024

but having to set a NO_PROXY env var was already the case in the current release, its not newly introduced by the Webhook Proxy change 🙂

@maksim-paskal
Copy link
Owner

@jan-mrm Yeap, thanks. Fixed - please try:

image: paskalmaksim/aks-node-termination-handler:dev
imagePullPolicy: Always
args:
- "-webhook.url=https://myWebhook"
- "-webhook.template-file=/files/webhook.json"
- "-webhook.contentType=application/json"
- "-webhook.method=POST"
- "-webhook.timeout=30s"
- "-webhook.http-proxy=http://someProxy:1234"

I add new flag -webhook.http-proxy that will control http proxy only for webhooks, you can use also env WEBHOOK_HTTP_PROXY if you want to set this proxy with env

@jan-mrm
Copy link
Author

jan-mrm commented Jul 29, 2024

@maksim-paskal lgtm 👍

@maksim-paskal
Copy link
Owner

@jan-mrm changes was released. Please use README To use an HTTP proxy for making webhook requests.

@jan-mrm
Copy link
Author

jan-mrm commented Jul 29, 2024

@maksim-paskal thank you for implementing it so quickly 🙂👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants