Git Product home page Git Product logo

Comments (6)

aofei avatar aofei commented on May 18, 2024 1

首先,如果你的 GOPROXY 环境变量是 https://goproxy.cn,那么你会拿到一个 404 错误,并且是一个正常的 404 错误,因为 k8s 并不存在 v0.0.0 这个版本。

其次,如果你的 GOPROXY 环境变量是 https://goproxy.cn,direct,那么你会拿到一个网络超时错误,因为这个工作原理是 goproxy.cn 返回给你了 404(和上面的理由一样),然后 Go 模块选择走你指定的这个 direct,也就是直连 k8s.io 这个域名,由于它被墙了,所以网络超时。

你遇到的这两个错误均是 k8s 本身的锅,据我所知他们已经在着手解决了,你可以去他们的 Issues 里查看。

from goproxy.cn.

helios741 avatar helios741 commented on May 18, 2024 1

@aofei 感谢您的回复。
我在k8s的一个issue中找到了方法。后续的人也可以参考这个:kubernetes/kubernetes#79384 (comment)

from goproxy.cn.

aofei avatar aofei commented on May 18, 2024

可以,你可能用错了吧,或者忽略了什么设置,麻烦给我看一下你的 go env 内容。

from goproxy.cn.

helios741 avatar helios741 commented on May 18, 2024

@aofei

[root@hl-k8s-test3 admission-webhook-example]# go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/gopath"
GOPRIVATE=""
GOPROXY="https://goproxy.cn"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/gopath/src/github.com/cnych/admission-webhook-example/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build651513223=/tmp/go-build -gno-record-gcc-switches"

然后执行go build会有下面的问题:

# go build
go: k8s.io/[email protected] requires
	k8s.io/[email protected]: reading https://goproxy.cn/k8s.io/api/@v/v0.0.0.mod: 404 Not Found

go get 的时候也报k8s.io/[email protected]: reading https://goproxy.cn/k8s.io/api/@v/v0.0.0.mod: 404 Not Found类似的错误

from goproxy.cn.

helios741 avatar helios741 commented on May 18, 2024

@aofei
感谢您的回复,还有下面的问题:

go build main.go webhook.go
go: finding github.com/golang/glog latest
go: finding github.com/ghodss/yaml v1.0.0
go: downloading github.com/ghodss/yaml v1.0.0
go: extracting github.com/ghodss/yaml v1.0.0
go: k8s.io/[email protected] requires
	k8s.io/[email protected]: unrecognized import path "k8s.io/api" (https fetch: Get https://k8s.io/api?go-get=1: dial tcp 35.201.71.162:443: i/o timeout)
[root@hl-k8s-test3 kube-mutating-webhook-tutorial]# go get -v -u k8s.io/api
k8s.io/api
go build k8s.io/api: no non-test Go files in /home/gopath/pkg/mod/k8s.io/[email protected]

from goproxy.cn.

wenhuwang avatar wenhuwang commented on May 18, 2024

@helios741 看了这个链接:kubernetes/kubernetes#79384 (comment),麻烦问一下这个脚本怎么用呢?

#!/bin/sh
set -euo pipefail

VERSION=${1#"v"}
if [ -z "$VERSION" ]; then
    echo "Must specify version!"
    exit 1
fi
MODS=($(
    curl -sS https://raw.githubusercontent.com/kubernetes/kubernetes/v${VERSION}/go.mod |
    sed -n 's|.*k8s.io/\(.*\) => ./staging/src/k8s.io/.*|k8s.io/\1|p'
))
for MOD in "${MODS[@]}"; do
    V=$(
        go mod download -json "${MOD}@kubernetes-${VERSION}" |
        sed -n 's|.*"Version": "\(.*\)".*|\1|p'
    )
    go mod edit "-replace=${MOD}=${MOD}@${V}"
done
go get "k8s.io/kubernetes@v${VERSION}"

@aofei 感谢您的回复。
我在k8s的一个issue中找到了方法。后续的人也可以参考这个:kubernetes/kubernetes#79384 (comment)

from goproxy.cn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.