sample-controller: add note about fetching deps in README

This commit is contained in:
Nikhita Raghunath 2019-06-16 23:23:03 +05:30
parent 391da79abd
commit f039c31a9e
2 changed files with 42 additions and 3 deletions

View File

@ -55,7 +55,7 @@ Note, however, that if you intend to
[generate code](#changes-to-the-types) then you will also need the [generate code](#changes-to-the-types) then you will also need the
code-generator repo to exist in an old-style location. One easy way code-generator repo to exist in an old-style location. One easy way
to do this is to use the command `go mod vendor` to create and to do this is to use the command `go mod vendor` to create and
popdulate the `vendor` directory. populate the `vendor` directory.
### A Note on kubernetes/kubernetes ### A Note on kubernetes/kubernetes

View File

@ -31,6 +31,47 @@ The sample controller uses [client-go library](https://github.com/kubernetes/cli
The details of interaction points of the sample controller with various mechanisms from this library are The details of interaction points of the sample controller with various mechanisms from this library are
explained [here](docs/controller-client-go.md). explained [here](docs/controller-client-go.md).
## Fetch sample-controller and its dependencies
Like the rest of Kubernetes, sample-controller has used
[godep](https://github.com/tools/godep) and `$GOPATH` for years and is
now adopting go 1.11 modules. There are thus two alternative ways to
go about fetching this demo and its dependencies.
### Fetch with godep
When NOT using go 1.11 modules, you can use the following commands.
```sh
go get -d k8s.io/sample-controller
cd $GOPATH/src/k8s.io/sample-controller
godep restore
```
### When using go 1.11 modules
When using go 1.11 modules (`GO111MODULE=on`), issue the following
commands --- starting in whatever working directory you like.
```sh
git clone https://github.com/kubernetes/sample-controller.git
cd sample-controller
```
Note, however, that if you intend to
[generate code](#changes-to-the-types) then you will also need the
code-generator repo to exist in an old-style location. One easy way
to do this is to use the command `go mod vendor` to create and
populate the `vendor` directory.
### A Note on kubernetes/kubernetes
If you are developing Kubernetes according to
https://github.com/kubernetes/community/blob/master/contributors/guide/github-workflow.md
then you already have a copy of this demo in
`kubernetes/staging/src/k8s.io/sample-controller` and its dependencies
--- including the code generator --- are in usable locations
(valid for all Go versions).
## Purpose ## Purpose
@ -42,8 +83,6 @@ This is an example of how to build a kube-like controller with a single type.
```sh ```sh
# assumes you have a working kubeconfig, not required if operating in-cluster # assumes you have a working kubeconfig, not required if operating in-cluster
go get k8s.io/sample-controller
cd $GOPATH/src/k8s.io/sample-controller
go build -o sample-controller . go build -o sample-controller .
./sample-controller -kubeconfig=$HOME/.kube/config ./sample-controller -kubeconfig=$HOME/.kube/config