I have a Kubernetes clusters in an EC2 instance on AWS. We have one bastion host (also in an EC2 instance) which is used to connect to this cluster. kubectl tools can be used from Bastion then. I need to use port-forward to expose some services on my local browser, but I am having trouble doing that.
First I tried using kubectl port-forward service/my_service 8080:8080
inside Bastion, which returns
Forwarding from 127.0.0.1:8080 -> 8080
Forwarding from [::1]:8080 -> 8080
However, when I tried accessing this service through localhost/8080/my_service
, I get `Safari can’t open the page "localhost:8080/my_service/#" because Safari can’t connect to the server “localhost”. I realized then I needed to send kubectl commands from my local machine.
I have already installed kubectl in my local machine. I also copied the config file from the cluster and pasted it in my local machine in the .kube/config folder. However, I can't reach the cluster from local machine. When I use kubectl get pods
for example, I get:
E0307 12:03:10.363122 3315 memcache.go:238] couldn't get current server API group list: Get "https://172.31.10.11:6443/api?timeout=32s": dial tcp 172.31.10.11:6443: i/o timeout
I checked and I am able to ssh into the machine without problems, so I guess the problem is the connection between my local machine and Bastion? Does anyone have a suggestion here?
Thanks