I'd like to make some changes to heapster and create a new docker image for it. I'm completely new to golang and I can't seem to figure out the dependency / build system.
I have a linux system. I'm starting from
git clone https://github.com/kubernetes/heapster.git
make container
But then I get
godep: [WARNING]: godep should only be used inside a valid go package directory and
godep: [WARNING]: may not function correctly. You are probably outside of your $GOPATH.
...
can't load package: package k8s.io/heapster/metrics
...
So my questions are:
Is there any documentation on how to build heapster? I haven't been able to find any.
Should I set up dependencies before running make? The use of godep seems to suggest that the dependencies are managed by the makefile, but clearly it's still missing a package.
What should be the right value for $GOPATH? Should I add the heapster working copy to my $GOPATH, as the warnings seems to suggest? I've tried it, but it seems to need a heapster/src directory which doesn't exist)
many thanks in advance,
Martijn
With some effort, I figured it out myself. I'll reply my own question here for future reference:
The thing that made the difference is to use the right directory structure. If you check out a working copy of the heapster code below $GOPATH/src/k8s.io/heapster, things work smoothly. Perhaps this is obvious for experienced go developers, but it wasn't for me.
On my linux box, the following commands are sufficient to build heapster:
# Install go
apt install golang-go
# Edit .profile to set GOPATH and update PATH
cat >> ~/.profile <<EOF
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$PATH
EOF
source ~/.profile
mkdir -p ~/go/src/k8s.io
# Install godep tool
go get -u github.com/tools/godep
# Check out heapster repository
cd ~/go/src/k8s.io
git clone https://github.com/kubernetes/heapster.git
# Build
cd ~/go/src/k8s.io/heapster
make
regards,
Martijn