I want to set up port forwarding from my local ports (nodes) to the pod redis-master after the online guide from kubernetes.
At the moment my prompt is frozen for more than 5 minutes at the port-forward
command.
[root@k8s-master deployments]# kubectl create -f https://k8s.io/docs/tasks/access-application-cluster/redis-master.yaml
pod "redis-master" created
[root@k8s-master deployments]# kubectl get pods
NAME READY STATUS RESTARTS AGE
redis-master 2/2 Running 0 1m
[root@k8s-master deployments]# kubectl get pods redis-master --template='{{(index (index .spec.containers 0).ports 0).containerPort}}{{"\n"}}'
6379
[root@k8s-master deployments]# kubectl port-forward redis-master 6379:6379
Forwarding from 127.0.0.1:6379 -> 6379
^C
I don't know why my prompt is frozen. In my logs aren't some error or warn entries.
journalctl -u kubelet.service -f --since "2018-02-19 10:30:00" --priority 0
-- Logs begin at Sa 2018-02-03 21:21:50 CET. --
kubectl version
[root@k8s-master deployments]# kubectl version
Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.2", GitCommit:"5fa2db2bd46ac79e5e00a4e6ed24191080aa463b", GitTreeState:"clean", BuildDate:"2018-01-18T10:09:24Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.2", GitCommit:"5fa2db2bd46ac79e5e00a4e6ed24191080aa463b", GitTreeState:"clean", BuildDate:"2018-01-18T09:42:01Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}
os-release
[root@k8s-master deployments]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
Ports
[root@k8s-master deployments]# ss -atun | grep 6379
[root@k8s-master deployments]#
Kubectl port-forward is a method to access, interact and manage internal Kubernetes clusters directly from your local network. This method is popularly used to investigate issues concerning your applications. Kubectl is a command-line tool that is used to run commands and control Kubernetes clusters.
To cancel or quit the kubectl command, you can simply press Ctrl + C and the port forwarding will end immediately.
Method-1: Listen on port 8080 locally, forwarding to port 80 in the pod. Once done you can either kill the PID of the port-forward command or press ctrl+c on the terminal where kubectl port-forward is running.
Transport security By default, the Kubernetes API server listens on port 6443 on the first non-localhost network interface, protected by TLS.
The behaviour you see is expected. This command does not get daemonized by default. It will be forwarding the port until you kill the command with CTRL-C or other similar methods.
You could try using &
at the end of the command if you want to continue using that prompt. Personally I would use a terminal multiplexer like tmux or screen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With