Skip to content

Latest commit

 

History

History
94 lines (70 loc) · 3.13 KB

INSTALL.md

File metadata and controls

94 lines (70 loc) · 3.13 KB

Installing client-go

Using the latest version

If you want to use the latest version of this library, use go1.16+ and run:

go get k8s.io/client-go@latest

This will record a dependency on k8s.io/client-go in your go module. You can now import and use the k8s.io/client-go APIs in your project. The next time you go build, go test, or go run your project, k8s.io/client-go and its dependencies will be downloaded (if needed), and detailed dependency version info will be added to your go.mod file (or you can also run go mod tidy to do this directly).

Using a specific version

If you want to use a particular version of the k8s.io/client-go library, you can indicate which version of client-go your project requires:

  • If you are using Kubernetes versions >= v1.17.0, use a corresponding v0.x.y tag. For example, k8s.io/[email protected] corresponds to Kubernetes v1.20.4:
go get k8s.io/[email protected]
  • If you are using Kubernetes versions < v1.17.0, use a corresponding kubernetes-1.x.y tag. For example, k8s.io/[email protected] corresponds to Kubernetes v1.16.3:
go get k8s.io/[email protected]

You can now import and use the k8s.io/client-go APIs in your project. The next time you go build, go test, or go run your project, k8s.io/client-go and its dependencies will be downloaded (if needed), and detailed dependency version info will be added to your go.mod file (or you can also run go mod tidy to do this directly).

Troubleshooting

Go versions prior to 1.16

If you get a message like module k8s.io/client-go@latest found (v1.5.2), but does not contain package k8s.io/client-go/..., you are likely using a go version prior to 1.16 and must explicitly specify the k8s.io/client-go version you want. For example:

go get k8s.io/[email protected]

Conflicting requirements for older client-go versions

If you get a message like module k8s.io/api@latest found, but does not contain package k8s.io/api/auditregistration/v1alpha1, something in your build is likely requiring an old version of k8s.io/client-go like v11.0.0+incompatible.

First, try to fetch a more recent version. For example:

go get k8s.io/[email protected]

If that doesn't resolve the problem, see what is requiring an ...+incompatible version of client-go, and update to use a newer version of that library, if possible:

go mod graph | grep " k8s.io/client-go@"

As a last resort, you can force the build to use a specific version of client-go, even if some of your dependencies still want ...+incompatible versions. For example:

go mod edit -replace=k8s.io/client-go=k8s.io/[email protected]
go get k8s.io/[email protected]

Go modules disabled

If you get a message like cannot use path@version syntax in GOPATH mode, you likely do not have go modules enabled. This should be on by default in all supported versions of Go.

export GO111MODULE=on

Ensure your project has a go.mod file defined at the root of your project. If you do not already have one, go mod init will create one for you:

go mod init