k8s.io/client-go@v0.31.1/INSTALL.md (about)

     1  # Installing client-go
     2  
     3  ## Using the latest version
     4  
     5  If you want to use the latest version of this library, use go1.16+ and run:
     6  
     7  ```sh
     8  go get k8s.io/client-go@latest
     9  ```
    10  
    11  This will record a dependency on `k8s.io/client-go` in your go module.
    12  You can now import and use the `k8s.io/client-go` APIs in your project.
    13  The next time you `go build`, `go test`, or `go run` your project,
    14  `k8s.io/client-go` and its dependencies will be downloaded (if needed),
    15  and detailed dependency version info will be added to your `go.mod` file
    16  (or you can also run `go mod tidy` to do this directly).
    17  
    18  ## Using a specific version
    19  
    20  If you want to use a particular version of the `k8s.io/client-go` library,
    21  you can indicate which version of `client-go` your project requires:
    22  
    23  - If you are using Kubernetes versions >= `v1.17.0`, use a corresponding `v0.x.y` tag.
    24    For example, `k8s.io/client-go@v0.20.4` corresponds to Kubernetes `v1.20.4`:
    25  
    26  ```sh
    27  go get k8s.io/client-go@v0.20.4
    28  ```
    29  
    30  - If you are using Kubernetes versions < `v1.17.0`, use a corresponding `kubernetes-1.x.y` tag.
    31    For example, `k8s.io/client-go@kubernetes-1.16.3` corresponds to Kubernetes `v1.16.3`:
    32  
    33  ```sh
    34  go get k8s.io/client-go@kubernetes-1.16.3
    35  ```
    36  
    37  You can now import and use the `k8s.io/client-go` APIs in your project.
    38  The next time you `go build`, `go test`, or `go run` your project,
    39  `k8s.io/client-go` and its dependencies will be downloaded (if needed),
    40  and detailed dependency version info will be added to your `go.mod` file
    41  (or you can also run `go mod tidy` to do this directly).
    42  
    43  ## Troubleshooting
    44  
    45  ### Go versions prior to 1.16
    46  
    47  If you get a message like 
    48  `module k8s.io/client-go@latest found (v1.5.2), but does not contain package k8s.io/client-go/...`,
    49  you are likely using a go version prior to 1.16 and must explicitly specify the k8s.io/client-go version you want.
    50  For example:
    51  ```sh
    52  go get k8s.io/client-go@v0.20.4
    53  ```
    54  
    55  ### Conflicting requirements for older client-go versions
    56  
    57  If you get a message like
    58  `module k8s.io/api@latest found, but does not contain package k8s.io/api/auditregistration/v1alpha1`,
    59  something in your build is likely requiring an old version of `k8s.io/client-go` like `v11.0.0+incompatible`.
    60  
    61  First, try to fetch a more recent version. For example:
    62  ```sh
    63  go get k8s.io/client-go@v0.20.4
    64  ```
    65  
    66  If that doesn't resolve the problem, see what is requiring an `...+incompatible` version of client-go,
    67  and update to use a newer version of that library, if possible:
    68  ```sh
    69  go mod graph | grep " k8s.io/client-go@"
    70  ```
    71  
    72  As a last resort, you can force the build to use a specific version of client-go,
    73  even if some of your dependencies still want `...+incompatible` versions. For example:
    74  ```sh
    75  go mod edit -replace=k8s.io/client-go=k8s.io/client-go@v0.20.4
    76  go get k8s.io/client-go@v0.20.4
    77  ```
    78  
    79  ### Go modules disabled
    80  
    81  If you get a message like `cannot use path@version syntax in GOPATH mode`,
    82  you likely do not have go modules enabled.  This should be on by default in all
    83  supported versions of Go.
    84  
    85  ```sh
    86  export GO111MODULE=on
    87  ```
    88  
    89  Ensure your project has a `go.mod` file defined at the root of your project.
    90  If you do not already have one, `go mod init` will create one for you:
    91  
    92  ```sh
    93  go mod init
    94  ```