Skip to content

Building cAdvisor

aborkar-ibm edited this page Mar 24, 2020 · 54 revisions

Building cAdvisor

Below versions of cAdvisor are available in respective distributions at the time of creation of these build instructions:

  • Ubuntu 16.04 has 0.20.5
  • Ubuntu (18.04, 19.10) has 0.27.1

The instructions provided below specify the steps to build cAdvisor version 0.35.0 on Linux on IBM Z for the following distributions:

  • RHEL (7.5, 7.6, 7.7, 8.0, 8.1)
  • SLES (12 SP4, 12 SP5, 15 SP1)
  • Ubuntu (16.04, 18.04, 19.10)

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified.
  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.
  • It is recommended to use cadvisor >= 0.23.9 on Kernel version >= 4.4 for SLES & Ubuntu, Kernel version >= 3.10.0-366 for RHEL in order to avoid inconsistent fs usage data from device thin pool. Click here for details.

Step 1: Build using script

If you want to build cAdvisor using manual steps, go to STEP 2.

Use the following commands to build cAdvisor using the build script. Please make sure you have wget installed.

wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/cAdvisor/0.35.0/build_cadvisor.sh

# Build cAdvisor
bash build_cadvisor.sh   [Provide -t option for executing build with tests]

If the build completes successfully, go to STEP 9. In case of error, check logs for more details or go to STEP 2 to follow manual build steps.

Step 2: Install the dependencies

export SOURCE_ROOT=/<source_root>/
  • RHEL (7.5, 7.6, 7.7)

    sudo yum install -y curl git golang gcc
  • RHEL (8.0, 8.1)

    sudo yum install -y curl git golang 
  • SLES (12 SP4, 12 SP5, 15 SP1)

    sudo zypper install -y curl git wget tar gcc
    • Install Go 1.10.5
      cd $SOURCE_ROOT
      wget https://dl.google.com/go/go1.10.5.linux-s390x.tar.gz
      sudo tar -C /usr/local -xzf go1.10.5.linux-s390x.tar.gz
      export PATH=$PATH:/usr/local/go/bin
      sudo ln /usr/bin/gcc /usr/bin/s390x-linux-gnu-gcc
      Note: Make sure to set GOROOT environment variable to point to GO Installation directory.
  • Ubuntu (16.04, 18.04)

    sudo apt-get update
    sudo apt-get install -y curl git golang-1.10 
    export PATH=/usr/lib/go-1.10/bin/:$PATH
  • Ubuntu (19.10)

    sudo apt-get update
    sudo apt-get install -y curl git golang-1.12 
    export PATH=/usr/lib/go-1.12/bin/:$PATH

Step 3: Export GO path

export GOPATH=$SOURCE_ROOT
export PATH=$PATH:$GOPATH/bin

Step 4: Install godep tool

cd $SOURCE_ROOT
go get github.com/tools/godep

Step 5: Checkout the source code from github

mkdir -p $GOPATH/src/github.com/google
cd $GOPATH/src/github.com/google
git clone https://github.com/google/cadvisor.git
cd cadvisor
git checkout v0.35.0

Step 6: Apply patch

  • Append changes to the file $GOPATH/src/github.com/google/cadvisor/vendor/github.com/klauspost/crc32/crc32.go
    curl  -o "crc32.go.diff" https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/cAdvisor/0.35.0/patch/crc32.go.diff 
    patch "${GOPATH}/src/github.com/google/cadvisor/vendor/github.com/klauspost/crc32/crc32.go" crc32.go.diff 
    rm -rf crc32.go.diff 
    
    Note: cAdvisor uses 'klauspost/crc32' over standard crc32 library of golang which is optimized for x64 platform. We add the above code to align it with Go standard library hash/crc32.

Step 7: Build cAdvisor

cd $GOPATH/src/github.com/google/cadvisor
godep go build .
sudo cp ${GOPATH}/src/github.com/google/cadvisor/cadvisor /usr/bin/

Step 8: Run unit tests (Optional)

cd $GOPATH/src/github.com/google/cadvisor 
go test -short `go list ./... | grep -v Microsoft`

Notes:

  • Microsoft related tests will be skipped.
  • Ignore TestTopology failure as it is known issue on system Z.

Step 9: Run cAdvisor

sudo cadvisor

Step 10: Access cAdvisor web user interface from browser

http://<host-ip>:<http-port>/

Note: Default port number for cAdvisor is 8080

References:

Clone this wiki locally