1

我一直在尝试使用 VSCode 设置 Cloud Code,并且在使用 Cloud Code: Deploy 启动部署过程时遇到了问题。

我已经尝试将示例 python-hello-world-1 和 go-hello-world-1 部署到 GKE 上的 kubernetes 集群,但在部署过程开始下载包时总是会出错:

输出

Running: skaffold run --enable-rpc -v info --rpc-http-port 49869 --filename skaffold.yaml --default-repo gcr.io/abx-lernende
starting gRPC server on port 50051
starting gRPC HTTP server on port 49869
Using kubectl context: gke_abx-lernende_europe-west4-a_joshu-test-cluster
Generating tags...
 - go-hello-world -> gcr.io/abx-lernende/go-hello-world:latest
Checking cache...
 - go-hello-world: Not found. Building
Building [go-hello-world]...
Sending build context to Docker daemon  57.86kB
Step 1/8 : FROM golang:1.13
 ---> 6586e3d10e96
Step 2/8 : RUN go get -u -v github.com/go-delve/delve/cmd/dlv
 ---> Running in b75ce8e5dae9
[91mgithub.com/go-delve/delve (download)
[0m[91m# cd .; git clone -- https://github.com/go-delve/delve /go/src/github.com/go-delve/delve
Cloning into '/go/src/github.com/go-delve/delve'...
fatal: unable to access 'https://github.com/go-delve/delve/': Failed to connect to github.com port 443: Connection refused
package github.com/go-delve/delve/cmd/dlv: exit status 128
[0mfailed to build: build failed: building [go-hello-world]: build artifact: unable to stream build output: The command '/bin/sh -c go get -u -v github.com/go-delve/delve/cmd/dlv' returned a non-zero code: 1
Exited with code 1.

Python 输出

Running: skaffold run --enable-rpc -v info --rpc-http-port 50185 --filename 
skaffold.yaml --default-repo gcr.io/abx-lernende
starting gRPC server on port 50051
starting gRPC HTTP server on port 50185
Skaffold &{Version:v1.3.1 ConfigVersion:skaffold/v2alpha3 GitVersion: GitCommit:6ba887a42438d1da578a005cf550e618fee6dfb8 GitTreeState:clean BuildDate:2020-01-31T19:55:18Z GoVersion:go1.13.4 Compiler:gc Platform:windows/amd64}
Using kubectl context: gke_abx-lernende_europe-west4-a_joshu-test-cluster
Generating tags...
 - python-hello-world -> Tags generated in 0s
gcr.io/abx-lernende/python-hello-world:latest
Checking cache...
 - python-hello-world: Cache check complete in 6.0001ms
Not found. Building
Building [python-hello-world]...
Sending build context to Docker daemon  4.608kB
Step 1/7 : FROM python:3.8
 ---> efdecc2e377a
Step 2/7 : WORKDIR /app
 ---> Using cache
 ---> a131b81cad66
Step 3/7 : COPY requirements.txt .
 ---> Using cache
 ---> 4625ef1862bd
Step 4/7 : RUN pip install --trusted-host pypi.python.org -r requirements.txt
 ---> Running in 4da23a158ae3
[91mWARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f17ba9c9d60>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/flask/

我假设这是因为我支持公司代理。作为对策,我已明确配置 VSCode、Git、pip、go 和 google cloud sdk 都使用上述代理。最重要的是,我为代理设置了 Windows ENV 变量。遗憾的是没有成功。

谢谢!

4

1 回答 1

0

您可以配置 docker将代理信息传递到容器中,方法是在您的~/.docker/config.json:

{
  "proxies": {
    "default": {
      "httpProxy": "http://192.168.1.12:3128",
      "httpsProxy": "http://192.168.1.12:3128"
    }
  }
}

Docker 将在容器中设置HTTP_PROXY/环境变量,许多工具都会使用该变量。HTTPS_PROXY

于 2021-07-07T17:26:21.417 回答