Skip to content

Instantly share code, notes, and snippets.

@rajathithan
Last active September 26, 2021 13:36
Show Gist options
  • Save rajathithan/4faf04f94c40772a997e7c774a6fdb9e to your computer and use it in GitHub Desktop.
Save rajathithan/4faf04f94c40772a997e7c774a6fdb9e to your computer and use it in GitHub Desktop.
cloudbuild-private-cluster
- name: gcr.io/cloud-builders/docker
env:
- CLOUDSDK_COMPUTE_ZONE=us-central1
- CLOUDSDK_CORE_PROJECT=PROJECT-NAME
args:
- '-c'
- >-
docker run -d --net cloudbuild -p 8080:8080 --name kubectl-proxy
gcr.io/cloud-builders/gcloud compute start-iap-tunnel kubectl-bastion
8080 --local-host-port 0.0.0.0:8080 --zone us-central1-a --project
PROJECT-NAME && sleep 5
id: connect-kubectl-bastion
entrypoint: sh
- name: gcr.io/cloud-builders/kubectl
env:
- CLOUDSDK_COMPUTE_ZONE=us-central1
- CLOUDSDK_CONTAINER_CLUSTER=CLUSTER-NAME
- CLOUDSDK_CORE_PROJECT=PROJECT-NAME
args:
- '-c'
- 'HTTPS_PROXY=socks5://127.0.0.1:8080 kubectl apply -f yamls/'
id: deploy-to-cluster
entrypoint: sh
@Keydero
Copy link

Keydero commented Sep 26, 2021

I found out that the problem is in the step 1.
When it tries to listen it doesnt output in the container "Listening on port 8080" (The bastion has the port 1080 open).
And the second thing that is weird, when you change the port to 8282 for example, kubectl keeps trying to listen on port 8080 and i didn't find anyway to make it work.

And obviously when i tried in command line, it works fine and prints "lilstening on port 8080).
I don't know why it doesnt work but i have an idea, as i have a tiny proxy installed on the bastion, i will try to tunnel throw it, maybe it will work...
another thing if it remains impossible, I'm still looking for a way to ssh on the bastion and use kubectl... I will be so thankful if you found another way.

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