Skip to content

flannel 0.7.0

salamani edited this page Feb 13, 2017 · 1 revision

Building flannel

The instructions provided below specify the steps to build flannel 0.5.5 on IBM z Systems for RHEL 7.1/7.2/7.3, SLES 12/12-SP1/12-SP2 and Ubuntu 16.04/16.10

Prerequisites

  • Go (RHEL 7.1/7.2/7.3 & SLES 12/12-SP1/12-SP2) -- Instructions for building Go can be found here

General Notes:
When following the steps below please use a standard permission user unless otherwise specified.

Step 1: Install the Dependencies

  • RHEL 7.1/7.2/7.3

      sudo yum install -y git make wget gcc   
    
  • SLES 12/12-SP1/12-SP2

      sudo zypper install -y git make wget gcc
    
  • Ubuntu 16.04/16.10

      sudo apt-get install -y golang git make gcc
    

Step 2: Build and install flannel

  • Get the source

      export GOPATH=$HOME/gopath
      export PATH=$HOME/gopath/bin:$PATH
      mkdir -p $HOME/gopath/src/github.com/coreos
      cd $HOME/gopath/src/github.com/coreos/
      git clone https://github.com/linux-on-ibm-z/flannel
      cd $HOME/gopath/src/github.com/coreos/flannel
      git checkout v0.5.5-s390x
    
  • Make following changes to the Makefile

@@ -5,7 +5,7 @@

 # Default tag and architecture. Can be overridden
 TAG?=$(shell git describe --tags --dirty)
-ARCH?=amd64
+ARCH?=s390x

 # These variables can be overridden by setting an environment variable.
 TEST_PACKAGES?=pkg/ip subnet remote
@@ -30,6 +30,10 @@
        LIB_DIR=powerpc64le-linux-gnu
        CC=powerpc64le-linux-gnu-gcc
 endif
+ifeq ($(ARCH),s390x)
+        LIB_DIR=s390x-linux-gnu
+        CC=s390x-linux-gnu-gcc
+endif
 GOARM=6
 KUBE_CROSS_TAG=v1.6.2-2
 IPTABLES_VERSION=1.4.21
@@ -96,6 +100,7 @@

 ## Build an architecture specific flanneld binary
 dist/flanneld-$(ARCH):
+       @echo " ravi salamani $(ARCH)"
        # Build for other platforms with ARCH=$$ARCH make build
        # valid values for $$ARCH are [amd64 arm arm64 ppc64le]
        docker run -e CC=$(CC) -e GOARM=$(GOARM) -e GOARCH=$(ARCH) \
@@ -143,10 +148,11 @@

 ## Make a release after creating a tag
 release: dist/flannel-$(TAG)-linux-amd64.tar.gz
+       ARCH=s390x make dist/flanneld-$(TAG)-s390x.aci
        ARCH=amd64 make dist/flanneld-$(TAG)-amd64.aci
        ARCH=arm make dist/flanneld-$(TAG)-arm.aci
        ARCH=arm64 make dist/flanneld-$(TAG)-arm64.aci
-       ARCH=ppc64le make dist/flanneld-$(TAG)-ppc64le.aci
+       ARCH=ppc64le make dist/flanneld-$(TAG)-ppc64le.aci
        @echo "Everything should be built for $(TAG)"
        @echo "Add all *.aci, flanneld-* and *.tar.gz files from dist/ to the Github release"
        @echo "Use make docker-push-all to push the images to a registry"
@@ -156,6 +162,7 @@
        ARCH=arm make docker-push
        ARCH=arm64 make docker-push
        ARCH=ppc64le make docker-push
+       ARCH=s390x make docker-push

 flannel-git:
        ARCH=amd64 REGISTRY=quay.io/coreos/flannel-git make clean dist/flanneld-$(TAG)-amd64.docker docker-push
@@ -164,3 +171,4 @@
        ARCH=arm REGISTRY=quay.io/coreos/flannel-git make clean dist/flanneld-$(TAG)-arm.docker docker-push
        ARCH=arm64 REGISTRY=quay.io/coreos/flannel-git make clean dist/flanneld-$(TAG)-arm64.docker docker-push
        ARCH=ppc64le REGISTRY=quay.io/coreos/flannel-git make clean dist/flanneld-$(TAG)-ppc64le.docker docker-push
+       ARCH=s390x REGISTRY=quay.io/coreos/flannel-git make clean dist/flanneld-$(TAG)-s390x.docker docker-push
  • Build flannel

      cd $HOME/gopath/src/github.com/coreos/flannel
      make dist/flanneld
    
    • Run test cases make test
  • Build flannel on container

    • Create ubuntu_golang image Create Dockerfile with the following contents

        FROM s390x/ubuntu:16.04
        RUN apt-get update
        RUN apt-get install -y golang
      

      Create golang image using the below command

        docker build -t  ubuntu_golang .
      
    • Create gcr.io/google_containers/kube-cross:v1.6.2-2 image

      Create Dockerfile with the following contents

        FROM ubuntu_golang
      
        ENV GOARM 6
        ENV KUBE_DYNAMIC_CROSSPLATFORMS \
        s390x
      
        ENV KUBE_CROSSPLATFORMS \
        linux/386 \
        linux/arm linux/arm64 \
        linux/ppc64le \
        linux/s390x \
        darwin/amd64 darwin/386 \
        windows/amd64 windows/386
      
        # Pre-compile the standard go library when cross-compiling. This is much easier now when we have go1.5+
        RUN for platform in ${KUBE_CROSSPLATFORMS}; do GOOS=${platform%/*} GOARCH=${platform##*/} go install std; done
      
        # Install g++, then download and install protoc for generating protobuf output
        RUN apt-get update \
        && apt-get install -y g++ rsync apt-utils curl  file git unzip autoconf libtool automake g++ make git bzip2 curl unzip zlib1g-dev etcd \
        && apt-get clean && rm -rf /var/lib/apt/lists/*
        RUN mkdir -p /usr/local/src/protobuf \
        && cd /usr/local/src/protobuf \
        && git clone https://github.com/google/protobuf.git \
        && cd protobuf && git checkout -b v3.0.0 \
        && ./autogen.sh && ./configure \
        && make install \
        && ldconfig \
        && cd .. \
        && rm -rf protobuf \
        && protoc --version
      
        # Use dynamic cgo linking for architectures other than amd64 for the server platforms
        # More info here: https://wiki.debian.org/CrossToolchains
        RUN echo "deb http://emdebian.org/tools/debian/ jessie main" > /etc/apt/sources.list.d/cgocrosscompiling.list \
        && curl -s http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | apt-key add - \
        && for platform in ${KUBE_DYNAMIC_CROSSPLATFORMS}; do dpkg --add-architecture ${platform}; done \
        && apt-get update \
        && apt-get install -y build-essential \
        #  && for platform in ${KUBE_DYNAMIC_CROSSPLATFORMS}; do apt-get install -y crossbuild-essential-${platform}; done \
        && apt-get clean && rm -rf /var/lib/apt/lists/*
      
        # work around 64MB tmpfs size in Docker 1.6
        ENV TMPDIR /tmp.k8s
      
        # Get the code coverage tool, godep, and go-bindata
        RUN  mkdir $TMPDIR \
        && export GOPATH=$TMPDIR \
        && chmod a+rwx $TMPDIR \
        && chmod o+t $TMPDIR \
        && chmod o+t $TMPDIR \
        && go get golang.org/x/tools/cmd/cover \
        golang.org/x/tools/cmd/goimports \
        github.com/tools/godep \
        github.com/jteeuwen/go-bindata/go-bindata 
      

      Create kube-cross image using the below command

        docker build -t gcr.io/google_containers/kube-cross:v1.6.2-2 .
      
    • Build the flannel container cd $HOME/gopath/src/github.com/coreos/flannel make dist/flanneld-s390x

    • Build flanneld-v0.7.0-dirty-s390x.docker

      • Create file Dockerfile.s390x at location $HOME/gopath/src/github.com/coreos/flannel FROM s390x/busybox:glibc

          MAINTAINER Tom Denham <tom@tigera.io>
        
          COPY dist/flanneld-s390x /opt/bin/flanneld
          COPY dist/iptables-s390x /usr/local/bin/iptables
          COPY dist/mk-docker-opts.sh /opt/bin/
          COPY dist/libpthread.so.0-s390x /lib/libpthread.so.0
          CMD ["/opt/bin/flanneld"]
        
      • Build the flanneld-v0.7.0-dirty-s390x.docker cd $HOME/gopath/src/github.com/coreos/flannel make dist/flanneld-v0.7.0-dirty-s390x.docker

  • Run functional test cases(Optional) Note: Funtional test cases require the image of quay.io/coreos/etcd:v3.0.3. Working on build the etcd image.

      cd $HOME/gopath/src/github.com/coreos/flannel
      ./test
    

    Note: Test case github.com/coreos/flannel/remote failure is not related to IBM z System

Clone this wiki locally