3

I want to execute a POST request with custom headers over HTTPS from a pod in our kubernetes cluster, which is running openjdk11-jre with alpine as base image (adoptopenjdk/openjdk11:jre-11.0.11_9-alpine to be exact).

With this image curl or wget are not available and nc doesn't support HTTPS. I already tried to achieve something with jrunscript which comes with the jre but was only able to send a GET with cat('https://example.com').

Of course one way would be to copy an executable or a compiled Java class into the pod, over which I could send the request but I'd prefer a one-liner that is ready to go.

2
  • So go through what is installed in your container (we cannot know this), and see if you can use anything for HTTPS. E.g. is openssl available? Then you can do openssl s_client. Etc. Otherwise you need some Java. Commented Nov 22, 2021 at 9:39
  • Our image just has a jar file copied into it. So it's just the plain Alpine image with a JRE (just added the versions). I currently didn't find any program that would fit but often people here find clever ways to utilize existing programs for some command line magic :) Commented Nov 22, 2021 at 12:16

1 Answer 1

2

I noticed that there is a busybox binary in the Alpine image which contains a stripped-down version of wget. Unfortunately it does not allow to send PUT or DELETE requests but for POST this worked:

wget -qO - --post-data '' --header 'MyHeader: 123' https://example.com/

Or alternatively if there is no wget link to busybox

busybox wget -qO - --post-data '' --header 'MyHeader: 123' https://example.com/

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.