Try KubeCTL by Proxy
Setup proxy¶
Add the following to ~/ssh_proxy.sh
:
gcloud config configurations activate sandbox-account
gcloud compute ssh --zone "us-west1-b" "andrew@jhub-gce" --tunnel-through-iap --project "sandbox-project" -- -D 2244
Change bash permission:
chmod +x ~/ssh_proxy.sh
Add the following to ~/env_proxy.sh
:
export http_proxy='socks5://127.0.0.1:2244'
export https_proxy='socks5://127.0.0.1:2244'
Change bash permission:
chmod +x ~/env_proxy.sh
Enabling autocompletion¶
Upgrade bash¶
You can install/upgrade it using Homebrew:
brew install bash
sudo bash -c 'echo /usr/local/bin/bash >> /etc/shells'
chsh -s /usr/local/bin/bash
Reload your shell and verify that the desired version is being used:
echo $BASH_VERSION $SHELL
Install bash-completion¶
You can test if you have bash-completion v2 already installed with type _init_completion
. If not, you can install it with Homebrew:
brew install bash-completion@2
As stated in the output of this command, add the following to your ~/.bash_profile file
:
export BASH_COMPLETION_COMPAT_DIR="/usr/local/etc/bash_completion.d"
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
Reload your shell and verify that bash-completion v2 is correctly installed with
type _init_completion
Enable kubectl autocompletion¶
Source the completion script in your ~/.bash_profile file
:
echo 'source <(kubectl completion bash)' >>~/.bash_profile
Add the completion script to the /usr/local/etc/bash_completion.d
directory:
kubectl completion bash >/usr/local/etc/bash_completion.d/kubectl
If you have an alias for kubectl, you can extend shell completion to work with that alias by adding the following to your ~/.bash_profile
file:
alias kroxyctl="http_proxy='socks5://127.0.0.1:2244' https_proxy='socks5://127.0.0.1:2244' kubectl"
complete -F __start_kubectl kroxyctl
Setup cluster-info¶
gcloud container clusters get-credentials jhub-cluster --zone us-central1-b --project sandbox-project
kubectl config rename-context gke_sandbox-project_us-central1-b_jhub-cluster jhub-cluster
Try kubectl by proxy¶
kroxyctl --context=jhub-cluster get pods