Closed3

GGP cloudshell上でkubectl port-forwardしてもローカルPCブラウザから転送したトラフィック確認できない

PurecoPureco

kubectl port-forward sample-pod 9999:80
Forwarding from 127.0.0.1:9999 -> 80
Handling connection for 9999
ちゃんとポート転送できている

ローカルPC

PurecoPureco

GGP cloudshell上でのcurlで疎通確認は問題なし
$ curl -vl localhost:9999

  • Host localhost:9999 was resolved.
  • IPv6: ::1
  • IPv4: 127.0.0.1
  • Trying [::1]:9999...
  • Immediate connect fail for ::1: Cannot assign requested address
  • Trying 127.0.0.1:9999...
  • Connected to localhost (127.0.0.1) port 9999

GET / HTTP/1.1
Host: localhost:9999
User-Agent: curl/8.5.0
Accept: /

< HTTP/1.1 200 OK
< Server: nginx/1.17.10
< Date: Sat, 14 Dec 2024 01:43:47 GMT
< Content-Type: text/html
< Content-Length: 612
< Last-Modified: Tue, 14 Apr 2020 14:19:26 GMT
< Connection: keep-alive
< ETag: "5e95c66e-264"
< Accept-Ranges: bytes
<
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.

Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

  • Connection #0 to host localhost left intact
PurecoPureco

理由:GCPのcloudshellでのlocalhost、とキーボード打ってる自分のローカルPCでのlocalhostは別だ。
その上での解消方法:GCP Cloud Shell のWeb Preview 機能使う

このスクラップは2024/12/21にクローズされました