I have successfully completed this tutorial:
https://cloud.google.com/kubernetes-engine/docs/tutorials/private-cluster-bastion
Now that I have a bastion host running that connects to a private kubernetes cluster, I am looking for a way to use a java client to list the jobs that are running inside the cluster.
I understand that in order to connect to the bastion host SSH must be used, for example locally this is achieved via the command:
gcloud beta compute ssh INSTANCE_NAME
--tunnel-through-iap
--project=PROJECT_ID
--zone=COMPUTE_ZONE
-- -4 -L8888:localhost:8888 -N -q -f
Now I did a bit of research and found the following java SSH client:
However when trying to connect I need to input the host, port and username, as is shown in the following tutorial:
https://www.baeldung.com/java-ssh-connection
The thing is that I know tinyproxy is listening on port 8888 in the bastion host but I have no idea what the ip address of the bastion host would be. I also ignore which username should be used to establish the connection.
I have tried the following to get the ip address:
hostname -I
however when using this IP address I get the following exception:
java.net.ConnectException: Operation timed out (Connection timed out)
at com.jcraft.jsch.Util.createSocket(Util.java:349)
at com.jcraft.jsch.Session.connect(Session.java:215)
at com.jcraft.jsch.Session.connect(Session.java:183)
at bastion.host.Main.main(Main.java:11)
Caused by: java.net.ConnectException: Operation timed out (Connection timed out)
at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.base/java.net.Socket.connect(Socket.java:609)
at java.base/java.net.Socket.connect(Socket.java:558)
at java.base/java.net.Socket.<init>(Socket.java:454)
at java.base/java.net.Socket.<init>(Socket.java:231)
at com.jcraft.jsch.Util.createSocket(Util.java:343)
... 3 more
Is there a way to connect a java client with a tinyproxy instance running on GCP. The ultimate goal would be to be able to send kubectl commands from the java application, that is, to manipulate the control plane of the cluster behind the bastion host to create jobs and list the existing jobs.