Kubectl exec error

hi,
i have test5 master kubernetes and test5 -worker.

kubectl describe pod demotest
Name: demotest
Namespace: default
Priority: 0
Node: test55/192.168.42.179
Start Time: Mon, 08 Jul 2019 11:09:06 -0400
Labels:
Annotations:
Status: Running
IP: 192.168.42.179
Containers:
centos:
Container ID: docker://24a285c9ff373660be1302f12424011593a7a26c0ea2de7119989518ba97df2c
Image: centos
Image ID: docker-pullable://docker.io/centos@sha256:a799dd8a2ded4a83484bbae769d97655392b3f86533ceb7dd96bbac929809f3c
Port:
Host Port:
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Completed
Exit Code: 0
Started: Mon, 08 Jul 2019 11:56:39 -0400
Finished: Mon, 08 Jul 2019 11:56:39 -0400
Ready: False
Restart Count: 14
Environment:
Mounts:
/mnt/data from demo (rw)
/var/run/secrets/kubernetes.io/serviceaccount from default-token-z7q7n (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
demo:
Type: EmptyDir (a temporary directory that shares a pod’s lifetime)
Medium:
SizeLimit:
default-token-z7q7n:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-z7q7n
Optional: false
QoS Class: BestEffort
Node-Selectors:
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message


Normal Scheduled 47m default-scheduler Successfully assigned default/demotest to test55
Normal Pulled 46m (x4 over 47m) kubelet, test55 Successfully pulled image “centos”
Normal Created 46m (x4 over 47m) kubelet, test55 Created container centos
Normal Started 46m (x4 over 47m) kubelet, test55 Started container centos
Normal Pulling 46m (x5 over 47m) kubelet, test55 Pulling image “centos”
Warning BackOff 2m47s (x206 over 47m) kubelet, test55 Back-off restarting failed container
[root@test55 ~]# kubectl exec -it demotest – /bin/bash
The connection to the server localhost:8080 was refused - did you specify the right host or port?

why this?

[root@test5 ~]# kubectl cluster-info
Kubernetes master is running at https://192.168.42.181:6443

[root@test5 ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
test5 Ready master 111m v1.15.0
test55 Ready 90m v1.15.

Your are trying to exec into a running container, to get a remote shell.
This is though is only possible when the/a container is actually running.
Looking at the output of your describe command, your are in a crashloop backoff so there is nothing actually running that you could exec into.