簡體   English   中英

Kubernetes 端口轉發 - 連接被拒絕

[英]Kubernetes Port Forwarding - Connection refused

轉發端口時出現以下錯誤。 任何人都可以幫忙嗎?

mjafary$ sudo kubectl port-forward sa-frontend 88:82

Forwarding from 127.0.0.1:88 -> 82
Forwarding from [::1]:88 -> 82

錯誤日志:

Handling connection for 88
Handling connection for 88
E1214 01:25:48.704335   51463 portforward.go:331] an error occurred forwarding 88 -> 82: error forwarding port 82 to pod a017a46573bbc065902b600f0767d3b366c5dcfe6782c3c31d2652b4c2b76941, uid : exit status 1: 2018/12/14 08:25:48 socat[19382] E connect(5, AF=2 127.0.0.1:82, 16): Connection refused

這是 pod 的描述。 我的期望是,當我在瀏覽器中點擊 localhost:88 時,請求應該轉發到 jafary/sentiment-analysis-frontend 容器並且應用程序頁面應該加載

mjafary$ kubectl describe pods sa-frontend

Name:         sa-frontend
Namespace:    default
Node:         minikube/192.168.64.2
Start Time:   Fri, 14 Dec 2018 00:51:28 -0700
Labels:       app=sa-frontend
Annotations:  <none>
Status:       Running
IP:           172.17.0.23
Containers:
  sa-frontend:
    Container ID: docker://a87e614545e617be104061e88493b337d71d07109b0244b2b40002b2f5230967
    Image:          jafary/sentiment-analysis-frontend
    Image ID:       docker-pullable://jafary/sentiment-analysis-frontend@sha256:5ac784b51eb5507e88d8e2c11e5e064060871464e2c6d467c5b61692577aeeb1
    Port:           82/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Fri, 14 Dec 2018 00:51:30 -0700
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
  /var/run/secrets/kubernetes.io/serviceaccount from default-token-mc5cn (ro)
Conditions:
  Type           Status
  Initialized    True 
  Ready          True 
  PodScheduled   True 
Volumes:
  default-token-mc5cn:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-mc5cn
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
             node.kubernetes.io/unreachable:NoExecute for 300s
Events:          <none>

轉發端口時出現以下錯誤。 有人可以幫忙嗎?

mjafary$ sudo kubectl port-forward sa-frontend 88:82

Forwarding from 127.0.0.1:88 -> 82
Forwarding from [::1]:88 -> 82

錯誤日志:

Handling connection for 88
Handling connection for 88
E1214 01:25:48.704335   51463 portforward.go:331] an error occurred forwarding 88 -> 82: error forwarding port 82 to pod a017a46573bbc065902b600f0767d3b366c5dcfe6782c3c31d2652b4c2b76941, uid : exit status 1: 2018/12/14 08:25:48 socat[19382] E connect(5, AF=2 127.0.0.1:82, 16): Connection refused

這是吊艙的描述。 我的期望是,當我在瀏覽器中命中localhost:88時,請求應轉發到jafary / sentiment-analysis-frontend容器,並且應加載應用程序頁面

mjafary$ kubectl describe pods sa-frontend

Name:         sa-frontend
Namespace:    default
Node:         minikube/192.168.64.2
Start Time:   Fri, 14 Dec 2018 00:51:28 -0700
Labels:       app=sa-frontend
Annotations:  <none>
Status:       Running
IP:           172.17.0.23
Containers:
  sa-frontend:
    Container ID: docker://a87e614545e617be104061e88493b337d71d07109b0244b2b40002b2f5230967
    Image:          jafary/sentiment-analysis-frontend
    Image ID:       docker-pullable://jafary/sentiment-analysis-frontend@sha256:5ac784b51eb5507e88d8e2c11e5e064060871464e2c6d467c5b61692577aeeb1
    Port:           82/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Fri, 14 Dec 2018 00:51:30 -0700
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
  /var/run/secrets/kubernetes.io/serviceaccount from default-token-mc5cn (ro)
Conditions:
  Type           Status
  Initialized    True 
  Ready          True 
  PodScheduled   True 
Volumes:
  default-token-mc5cn:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-mc5cn
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
             node.kubernetes.io/unreachable:NoExecute for 300s
Events:          <none>

轉發端口時出現以下錯誤。 有人可以幫忙嗎?

mjafary$ sudo kubectl port-forward sa-frontend 88:82

Forwarding from 127.0.0.1:88 -> 82
Forwarding from [::1]:88 -> 82

錯誤日志:

Handling connection for 88
Handling connection for 88
E1214 01:25:48.704335   51463 portforward.go:331] an error occurred forwarding 88 -> 82: error forwarding port 82 to pod a017a46573bbc065902b600f0767d3b366c5dcfe6782c3c31d2652b4c2b76941, uid : exit status 1: 2018/12/14 08:25:48 socat[19382] E connect(5, AF=2 127.0.0.1:82, 16): Connection refused

這是吊艙的描述。 我的期望是,當我在瀏覽器中命中localhost:88時,請求應轉發到jafary / sentiment-analysis-frontend容器,並且應加載應用程序頁面

mjafary$ kubectl describe pods sa-frontend

Name:         sa-frontend
Namespace:    default
Node:         minikube/192.168.64.2
Start Time:   Fri, 14 Dec 2018 00:51:28 -0700
Labels:       app=sa-frontend
Annotations:  <none>
Status:       Running
IP:           172.17.0.23
Containers:
  sa-frontend:
    Container ID: docker://a87e614545e617be104061e88493b337d71d07109b0244b2b40002b2f5230967
    Image:          jafary/sentiment-analysis-frontend
    Image ID:       docker-pullable://jafary/sentiment-analysis-frontend@sha256:5ac784b51eb5507e88d8e2c11e5e064060871464e2c6d467c5b61692577aeeb1
    Port:           82/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Fri, 14 Dec 2018 00:51:30 -0700
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
  /var/run/secrets/kubernetes.io/serviceaccount from default-token-mc5cn (ro)
Conditions:
  Type           Status
  Initialized    True 
  Ready          True 
  PodScheduled   True 
Volumes:
  default-token-mc5cn:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-mc5cn
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
             node.kubernetes.io/unreachable:NoExecute for 300s
Events:          <none>

正如帕特里克正確指出的那樣。 我遇到了同樣的問題,困擾了我 2 天。 所以步驟是:

  1. 確保您的 Dockerfile 正在使用您的首選端口 (EXPOSE 5000)
  2. 在您的 pod.yml 文件中,確保 containerPort 為 5000(containerPort:5000)
  3. 應用 kubectl 命令以反映上述內容:

kubectl port-forward pod/my-name-of-pod 8080:5000

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM