Skip to content

openfaas Github

Cnaik edited this page Aug 9, 2019 · 1 revision

Building OpenFaas

The instructions provided below specify the steps to build OpenFaas version 0.13.4 and OpenFaas Cloud components version 0.9.4 on Linux on IBM Z for following distributions:

  • RHEL (7.6)

General Notes:

  • When following the steps below please use a super 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.

Prerequisites

  • Docker 18.06.2
  • Kubernetes v1.10 or newer cluster

Step 1: Build using script

If you want to build OpenFaas and OpenFaas Cloud components using manual steps, go to STEP 2.

To build OpenFaas and OpenFaas Cloud components using the build script, copy the build script to /<source_root>/ and execute the following command.

# Build
bash build_openfaas.sh

If the build is successful, run the following command to set Openfaas environment and go to STEP 4.

#Source environment file
source $HOME/setenv.sh

Step 2: Install dependencies

export SOURCE_ROOT=/<source_root>/
yum install -y make curl tar wget git vim patch
  • Install Go 1.11.4
    wget https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/Go/build_go.sh
    bash build_go.sh -v 1.11.4
    mkdir $SOURCE_ROOT/go
    export GOPATH=$SOURCE_ROOT/go
  • Build git v2.22.0 from source
    yum install -y asciidoc-8.6.8-5.el7.noarch openssl-devel curl-devel expat-devel perl-ExtUtils-MakeMaker gettext-devel tar make
    cd $SOURCE_ROOT
    git clone https://github.com/git/git.git
    cd $SOURCE_ROOT/git/
    git checkout v2.22.0
    make prefix=/usr/local && make prefix=/usr/local install 
    export PATH=/usr/local/bin:$PATH  
    

Step 3: Build OpenFaas Components

  • Build openfaas/gateway image

    • Download the source code

      go get github.com/openfaas/faas/gateway
      cd $GOPATH/src/github.com/openfaas/faas/gateway
      git checkout tags/0.13.4
    • Create Dockerfile named Dockerfile.gate-s390x with following content

      FROM s390x/golang:1.10.4 as build
      WORKDIR /go/src/github.com/openfaas/faas/gateway
      
      #  RUN curl -sL https://github.com/alexellis/license-check/releases/download/0.1/license-check > /usr/bin/license-check && chmod +x /usr/bin/license-check
      
      COPY vendor         vendor
      
      COPY handlers       handlers
      COPY metrics        metrics
      COPY requests       requests
      COPY tests          tests
      
      COPY types          types
      COPY queue          queue
      COPY plugin         plugin
      COPY version        version
      COPY scaling        scaling
      COPY server.go      .
      
      #Run a gofmt and exclude all vendored code.
      #RUN license-check -path ./ --verbose=false \
      RUN GOARCH=s390x CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gateway .
      
      FROM s390x/alpine:3.8
      
      RUN addgroup -S app \
        && adduser -S -g app app
      
      WORKDIR /home/app
      
      EXPOSE 8080
      EXPOSE 8082
      ENV http_proxy      ""
      ENV https_proxy     ""
      
      COPY --from=build /go/src/github.com/openfaas/faas/gateway/gateway    .
      COPY assets     assets
      
      RUN chown -R app:app ./
      
      USER app
      
      RUN sed -ie s/store.json/store-s390x.json/g /home/app/assets/script/funcstore.js
      
      CMD ["./gateway"]
    • Build the image

      docker build -f Dockerfile.gate-s390x -t openfaas/gateway:0.13.4-s390x .
  • Build the image openfaas/faas-swarm

    • Download the source code

      go get -d github.com/openfaas/faas-swarm
      cd $GOPATH/src/github.com/openfaas/faas-swarm
      git checkout 0.6.2
    • Modify the Dockerfile

      sed -i 's/RUN license-check/#RUN license-check/g' Dockerfile
      sed -i 's/RUN curl -sL/#RUN curl -sL/g' Dockerfile
      sed -i 's/    && chmod +x/#    && chmod +x/g' Dockerfile
    • Build the image

      docker build -f Dockerfile -t openfaas/faas-swarm:0.6.2-s390x .
  • Build the image prom/prometheus

    • Download the source code
       cd $GOPATH/src/github.com
       mkdir -p Prometheus && cd Prometheus
       wget https://raw.githubusercontent.com/linux-on-ibm-z/dockerfile-examples/master/Prometheus/Dockerfile
    • Build the image
       docker build -f Dockerfile -t prom/prometheus:v2.7.1-s390x .
  • Build the image openfaas/queue-worker

    • Download the source code
      go get github.com/openfaas/nats-queue-worker 
      cd $GOPATH/src/github.com/openfaas/nats-queue-worker
      git checkout 0.7.2
    • Build the image
      docker build -f Dockerfile -t openfaas/queue-worker:0.7.2-s390x .
  • Build the image prom/alertmanager

    • Download the source code

      go get github.com/prometheus/alertmanager
      cd $GOPATH/src/github.com/prometheus/alertmanager
      git checkout v0.16.2
    • Create Dockerfile named Dockerfile.s390x with following content

      FROM        s390x/golang:1.11.4
      LABEL maintainer="LoZ Open Source Ecosystem (https://www.ibm.com/developerworks/community/groups/community/lozopensource)"
      
      WORKDIR /go/src/github.com/prometheus/alertmanager
      COPY    . /go/src/github.com/prometheus/alertmanager
      
      RUN apt-get install make \
      	&& make build \
      	&& cp alertmanager /bin/ \
      	&& mkdir -p /etc/alertmanager/template \
      	&& mv ./doc/examples/simple.yml /etc/alertmanager/config.yml \
      	&& rm -rf /go
      
      EXPOSE     9093
      VOLUME     [ "/alertmanager" ]
      WORKDIR    /alertmanager
      ENTRYPOINT [ "/bin/alertmanager" ]
      CMD        [ "-config.file=/etc/alertmanager/config.yml", \
      			 "-storage.path=/alertmanager" ]
    • Build the image

      docker build -f Dockerfile.s390x -t prom/alertmanager:v0.16.2-s390x .
  • Build the image nats-streaming

    • Download the source code
      go get github.com/nats-io/nats-streaming-server
      cd $GOPATH/src/github.com/nats-io/nats-streaming-server
      git checkout v0.11.2
    • Modify the Dockerfile as below
      sed -i '/window/a RUN CGO_ENABLED=0 GOOS=linux   GOARCH=s390x go build -v -a -tags netgo -installsuffix netgo -ldflags "-s -w -X github.com/nats-io/nats-streaming-server/version.GITCOMMIT=`git rev-parse --short HEAD`" -o pkg/linux-s390x/nats-streaming-server && cp pkg/linux-s390x/nats-streaming-server /' Dockerfile
    • Build the image
      docker build -f Dockerfile -t nats-streaming:0.11.2-s390x .
  • Build the faas-cli binary & openfaas/faas-cli image

    • Download the source code

       cd $GOPATH/src/github.com/openfaas
       go get github.com/openfaas/faas-cli && cd faas-cli/
       git checkout 0.8.14
       CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -installsuffix cgo -o faas-cli .
       cp faas-cli /usr/bin
    • Modify the Dockerfile as below

      sed -i 's/RUN curl -sLSf/#RUN curl -sLSf/g' Dockerfile
      sed -i 's/RUN \/usr\/bin\/license-check/#RUN \/usr\/bin\/license-check/g' Dockerfile
    • Build the image

      docker build -f Dockerfile -t openfaas/faas-cli:0.8.14-s390x .
  • Build the watchdog binary and openfaas/classic-watchdog image

    • Download the source code
      go get github.com/openfaas/faas/watchdog
      cd $GOPATH/src/github.com/openfaas/faas/watchdog
      git checkout tags/0.13.4
      
      GOARCH=s390x CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-s -w  -X main.GitCommit=$GIT_COMMIT -X main.Version=$VERSION" -installsuffix cgo -o watchdog . && cp watchdog /usr/bin/fwatchdog
    • Create Dockerfile named Dockerfile.s390x with following content
      FROM s390x/golang:1.10 as build
      
      ARG VERSION
      ARG GIT_COMMIT
      
      RUN mkdir -p /go/src/github.com/openfaas/faas/watchdog
      WORKDIR /go/src/github.com/openfaas/faas/watchdog
      
      COPY vendor                     vendor
      COPY metrics                    metrics
      COPY types                      types
      COPY main.go                    .
      COPY handler.go                         .
      COPY readconfig.go                  .
      COPY readconfig_test.go             .
      COPY requesthandler_test.go     .
      COPY version.go                 .
      
      # Run a gofmt and exclude all vendored code.
      RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))"
      
      RUN go test -v ./...
      # Stripping via -ldflags "-s -w"
      RUN GOARCH=s390x CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-s -w \
      		-X main.GitCommit=$GIT_COMMIT \
      		-X main.Version=$VERSION" \
      		-installsuffix cgo -o watchdog . \
      		&& cp watchdog /fwatchdog
      
    • Build the image
      docker build -f Dockerfile.s390x -t openfaas/classic-watchdog:0.13.4 .
  • Build the ofc-bootstrap binary

     go get -d github.com/openfaas-incubator/ofc-bootstrap
     cd $GOPATH/src/github.com/openfaas-incubator/ofc-bootstrap/
     git checkout 0.6.4
     go build
  • Build the image openfaas/kafka-connector

    • Download the source code
       go get github.com/openfaas-incubator/kafka-connector
       cd $GOPATH/src/github.com/openfaas-incubator/kafka-connector
       git checkout 0.3.3
    • Build the image
       docker build -f Dockerfile -t openfaas/kafka-connector:0.3.3-s390x .
  • Build the image for Tiller

    • Download the source code
      go get -d github.com/helm/helm
      cd $GOPATH/src/github.com/helm/helm
      git checkout v2.13.1
      cd rootfs && wget https://storage.googleapis.com/kubernetes-helm/helm-v2.13.1-linux-s390x.tar.gz
      tar -xzvf helm-v2.13.1-linux-s390x.tar.gz && cp linux-s390x/tiller . && cp linux-s390x/helm .
      cp linux-s390x/helm /usr/bin
      cp linux-s390x/tiller /usr/bin
      rm -rf helm-v2.13.1-linux-s390x.tar.gz linux-s390x/
    • Build the image
      docker build -f Dockerfile -t gcr.io/kubernetes-helm/tiller:v2.13.1 .
    • Initialize Helm
      kubectl create clusterrolebinding tiller-cluster-admin \
      --clusterrole=cluster-admin \
      --serviceaccount=kube-system:default
      helm init --tiller-image gcr.io/kubernetes-helm/tiller:v2.13.1
  • Build the image openfaas/faas-netes

    • Download the source code

       go get github.com/openfaas/faas-netes
       cd $GOPATH/src/github.com/openfaas/faas-netes
       git checkout 0.7.5
    • Modify the Dockerfile as below

      sed -i 's/RUN license-check/#RUN license-check/g' Dockerfile
    • Modify the values.yaml files as below

      sed -i 's/0.3.3/0.3.3-s390x/g' chart/kafka-connector/values.yaml
      sed -i 's/0.7.3/0.7.5-s390x/g' chart/openfaas/values.yaml
      sed -i 's/Always/IfNotPresent/g' chart/openfaas/values.yaml
      sed -i 's/0.13.0/0.13.4-s390x/g' chart/openfaas/values.yaml
      sed -i 's/0.7.1/0.7.2-s390x/g' chart/openfaas/values.yaml
      sed -i 's/0.9.4/0.9.4-s390x/g' chart/openfaas/values.yaml
      sed -i 's/v2.7.1/v2.7.1-s390x/g' chart/openfaas/values.yaml
      sed -i 's/v0.16.1/v0.16.2-s390x/g' chart/openfaas/values.yaml
      sed -i 's/0.11.2/0.11.2-s390x/g' chart/openfaas/values.yaml
      sed -i 's/0.1.9/0.1.9-s390x/g' chart/openfaas/values.yaml
    • Modify the chart/openfaas/templates/alertmanager-dep.yaml as below

      sed -i  '/--spider/d' chart/openfaas/templates/alertmanager-dep.yaml
    • Modify the chart/openfaas/templates/prometheus-dep.yaml as below

      sed -i  '/--spider/d' chart/openfaas/templates/prometheus-dep.yaml
    • Package the openfaas and kafka-connector charts

      cd chart/ 
      helm package openfaas/
      helm package kafka-connector/
      mv openfaas-3.2.3.tgz ../docs && mv kafka-connector-0.2.2.tgz ../docs && cd ../
    • Build the image

      docker build -f Dockerfile -t openfaas/faas-netes:0.7.5-s390x .
  • Build the image openfaas/openfaas-operator

    • Download the source code
       go get github.com/openfaas-incubator/openfaas-operator
       cd $GOPATH/src/github.com/openfaas-incubator/openfaas-operator
       git checkout 0.9.4
    • Build the image
      docker build -f Dockerfile -t openfaas/openfaas-operator:0.9.4-s390x .
  • Build the image openfaas/faas-idler

    • Download the source code

       go get github.com/openfaas-incubator/faas-idler
       cd $GOPATH/src/github.com/openfaas-incubator/faas-idler
       git checkout 0.1.9
    • Create the patch patch_idler

      diff --git a/main.go b/main.go
      index 35a4fc0..c703469 100644
      --- a/main.go
      +++ b/main.go
      @@ -42,15 +42,6 @@ func main() {
      
      		credentials := Credentials{}
      
      -       client := &http.Client{}
      -       version, err := getVersion(client, config.GatewayURL, &credentials)
      -
      -       if err != nil {
      -               panic(err)
      -       }
      -
      -       log.Printf("Gateway version: %s, SHA: %s\n", version.Version.Release, version.Version.SHA)
      -
      		val, err := readFile("/var/secrets/basic-auth-user")
      		if err == nil {
      				credentials.Username = val
      @@ -65,6 +56,15 @@ func main() {
      				log.Printf("Unable to read password: %s", err)
      		}
      
      +        client := &http.Client{}
      +        version, err := getVersion(client, config.GatewayURL, &credentials)
      +
      +        if err != nil {
      +                panic(err)
      +        }
      +
      +        log.Printf("Gateway version: %s, SHA: %s\n", version.Version.Release, version.Version.SHA)
      +
      		fmt.Printf(`dry_run: %t
       gateway_url: %s
       inactivity_duration: %s `, dryRun, config.GatewayURL, config.InactivityDuration)
    • Apply the above patch to main.go

       patch --ignore-whitespace main.go patch_idler
    • Build the image

      docker build -f Dockerfile -t openfaas/faas-idler:0.1.9-s390x .
  • Build the image minio/minio

    • Download the source code
      go get -d github.com/minio/minio
      cd $GOPATH/src/github.com/minio/minio
      git checkout RELEASE.2019-05-14T23-57-45Z
    • Build the image
      docker build -t minio/minio:RELEASE.2019-05-14T23-57-45Z .
      Note: Docker build may hang while fetching/building Go modules. You may want to kill the build process and start over again.
  • Build the image minio/mc for minion client

    • Download the source code
      go get -d github.com/minio/mc
      cd $GOPATH/src/github.com/minio/mc
      git checkout RELEASE.2019-05-01T23-27-44Z
    • Build the image
      docker build -f Dockerfile -t minio/mc:RELEASE.2019-05-01T23-27-44Z .
  • Build the image quay.io/bitnami/sealed-secrets-controller

     mkdir $SOURCE_ROOT/sealed-secrets
     cd $SOURCE_ROOT/sealed-secrets
    • Create Dockerfile with following content.
      FROM golang:1.12-alpine
      RUN apk add --no-cache make git && go get github.com/bitnami-labs/sealed-secrets/cmd/kubeseal  \
      	&&  cd src/github.com/bitnami-labs/sealed-secrets/ && git checkout v0.7.0 \
      	&& make && chmod +x controller kubeseal \
      	&& cp controller /usr/local/bin/ && cp kubeseal /usr/local/bin/
      
      EXPOSE 8080
      ENTRYPOINT ["controller"]
    • Build the image
      docker build -t quay.io/bitnami/sealed-secrets-controller:v0.7.0 .
  • Build the image quay.io/kubernetes-ingress-controller/nginx-ingress-controller

    • Build the image
      cd $SOURCE_ROOT 
      mkdir nginx-ingress-controller && cd $SOURCE_ROOT/nginx-ingress-controller
      wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/NGINX-ingress-controller/0.25.0/build_nginx-ingress-controller.sh
      bash build_nginx-ingress-controller.sh -y
      docker tag quay.io/kubernetes-ingress-controller/nginx-ingress-controller-s390x:0.25.0 quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.25.0
  • Build kubeseal

     go get -d github.com/bitnami-labs/sealed-secrets/cmd/kubeseal
     cd $GOPATH/src/github.com/bitnami-labs/sealed-secrets/cmd/kubeseal
     git checkout v0.7.0
     go build
     cp kubeseal /usr/bin/kubeseal

    Note: Warnings related to No GO files should be ignored.

  • Build the images openfaas/edge-router, openfaas/of-builder and openfaas/edge-auth

     go get -d github.com/openfaas/openfaas-cloud
     cd $GOPATH/src/github.com/openfaas/openfaas-cloud
     git checkout 0.9.4
     cd edge-router && docker build -f Dockerfile -t openfaas/edge-router:0.6.1 .
     cd ../of-builder && docker build -f Dockerfile -t openfaas/of-builder:0.6.2 .
     cd ../edge-auth && docker build -f Dockerfile -t openfaas/edge-auth:0.5.2 .   

    Note: Warnings related to No GO files should be ignored.

  • Build the image k8s.gcr.io/defaultbackend

    • Download the source code
      go get -d github.com/kubernetes/ingress-gce
      cd $GOPATH/src/github.com/kubernetes/ingress-gce
      git checkout v1.5.0
    • Modify the Dockerfile.404-server as below:
      sed -i 's/ARG_BIN/404-server/g' Dockerfile.404-server
      sed -i 's/ARG_ARCH/s390x/g' Dockerfile.404-server
    • Modify the Makefile as below:
      sed -i 's/amd64/s390x/g' Makefile
    • Build
      make && cp .go/bin/404-server bin/s390x/
    • Build the image
      docker build -f Dockerfile.404-server -t k8s.gcr.io/defaultbackend-amd64:1.5 .
      Note: Leave the tag as amd64 otherwise we need to create local helm charts.
  • Build the image openfaas/of-watchdog:0.5.3

    • Download the source code

      go get github.com/openfaas-incubator/of-watchdog
      cd $GOPATH/src/github.com/openfaas-incubator/of-watchdog
      git checkout 0.5.3
      
      CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -installsuffix cgo -o of-watchdog . && cp of-watchdog /usr/bin/of-watchdog	
    • Create Dockerfile.s390x with below content

      FROM s390x/golang:1.10
      
      RUN mkdir -p /go/src/github.com/openfaas-incubator/of-watchdog
      WORKDIR /go/src/github.com/openfaas-incubator/of-watchdog
      
      COPY vendor              vendor
      COPY config              config
      COPY executor            executor
      COPY metrics             metrics
      COPY metrics             metrics
      COPY main.go             .
      
      # Run a gofmt and exclude all vendored code.
      #RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))"
      
      #RUN go test -v ./...
      
      # Stripping via -ldflags "-s -w"
      RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -installsuffix cgo -o of-watchdog . \
          && cp of-watchdog /fwatchdog		
    • Build the image

      docker build -f Dockerfile.s390x -t openfaas/of-watchdog:0.5.3 .
  • Build the openfaas-fn images

    • Build image functions/of-git-tar

      cd $GOPATH/src/github.com/openfaas/openfaas-cloud/git-tar
      rm -rf template/
      git clone https://github.com/openfaas/templates.git
      cd templates/
      git checkout 7b1468c0b522ab67665528862769c4f7327bc303
      mv -vf template/ $GOPATH/src/github.com/openfaas/openfaas-cloud/git-tar
      cd ..
      rm -vrf templates/
      cp /usr/bin/faas-cli .
      cp /usr/bin/fwatchdog .	
      • Modify the function/handler.go file with the below contents.

        --- handler.go_org	2019-07-15 03:00:41.061432200 -0400
        +++ handler.go	2019-07-15 03:34:35.522102310 -0400
        @@ -8,6 +8,7 @@
            "log"
            "net/http"
            "os"
        +        "os/exec"
            "path"
            "strconv"
            "strings"
        @@ -155,6 +156,15 @@
                }
                os.Exit(-1)
            }
        +        
        +        repCmd := exec.Command("cp", "/tmp/fixtemplate.sh", clonePath)
        +        err = repCmd.Start()
        +        err = repCmd.Wait()
        +
        +        repCmd = exec.Command("sh", "fixtemplate.sh")
        +        repCmd.Dir = clonePath
        +        err = repCmd.Start()
        +        err = repCmd.Wait()
        
            var shrinkWrapPath string
            shrinkWrapPath, err = shrinkwrap(pushEvent, clonePath)
        

        Note: Run gofmt -w function/handler.go to format the handler.go file .

      • Create the patch patch_dockerfile with below content.

        Note: If the patch fails use --ignore-whitespace option.

        --- Dockerfile_orig	2019-07-14 00:57:14.794503742 -0400
        +++ Dockerfile	2019-07-14 01:01:49.044223601 -0400
        @@ -1,9 +1,8 @@
         FROM golang:1.10-alpine3.9 as build
        +COPY faas-cli /usr/local/bin/faas-cli
        +COPY fwatchdog /usr/bin/fwatchdog
        
         RUN apk --no-cache add curl \ 
        -    && echo "Pulling watchdog binary from GitHub." \
        -    && curl -sSL https://github.com/openfaas/faas/releases/download/0.13.0/fwatchdog > /usr/bin/fwatchdog \
        -    && curl -sSL https://github.com/openfaas/faas-cli/releases/download/0.8.10/faas-cli > /usr/local/bin/faas-cli \
             && chmod +x /usr/bin/fwatchdog \
        	 && chmod +x /usr/local/bin/faas-cli \
        	 &&  apk del curl --no-cache
        @@ -38,6 +37,16 @@
        
         COPY --from=build /go/src/handler/handler    .
         COPY --from=build /usr/bin/fwatchdog         .
        +RUN echo "#!/bin/sh" >> /tmp/fixtemplate.sh && \
        +    echo "for dir in template/*"  >> /tmp/fixtemplate.sh && \
        +    echo "do" >> /tmp/fixtemplate.sh && \
        +    echo " dockerfile=\`find \$dir -name Dockerfile\`" >> /tmp/fixtemplate.sh && \
        +    echo " sed -i 's/--from=watchdog \/fwatchdog/fwatchdog/' \$dockerfile" >> /tmp/fixtemplate.sh && \
        +    echo " sed -i '/classic-watchdog/d' \$dockerfile" >> /tmp/fixtemplate.sh && \
        +    echo " dirD=\`echo \$dockerfile|rev|cut -d\"/\" -f2-|rev\`" >> /tmp/fixtemplate.sh && \
        +    echo " cp /home/app/fwatchdog \$dirD/" >> /tmp/fixtemplate.sh && \
        +    echo "done" >> /tmp/fixtemplate.sh && \
        +    chmod 755 /tmp/fixtemplate.sh
        
         COPY --from=build /usr/local/bin/faas-cli    /usr/local/bin/faas-cli
         RUN chmod 777 /tmp
        
      • Apply the above patch to Dockerfile

        patch --ignore-whitespace Dockerfile patch_dockerfile
        
      • Build the image

        faas-cli build --image  functions/of-git-tar:0.12.2 --lang Dockerfile --handler . --name git-tar
        
    • Build image functions/of-buildshiprun

      cd $GOPATH/src/github.com/openfaas/openfaas-cloud/buildshiprun
      git clone https://github.com/openfaas/templates.git
      cd templates/
      git checkout 7b1468c0b522ab67665528862769c4f7327bc303
      mv -vf template/ $GOPATH/src/github.com/openfaas/openfaas-cloud/buildshiprun
      cd ..
      rm -vrf templates/
      faas-cli build --image functions/of-buildshiprun:0.11.1 --lang go --handler . --name buildshiprun
    • Build image functions/github-event

      cd $GOPATH/src/github.com/openfaas/openfaas-cloud/github-event
      git clone https://github.com/openfaas/templates.git
      cd templates/
      git checkout 7b1468c0b522ab67665528862769c4f7327bc303
      mv -vf template/ $GOPATH/src/github.com/openfaas/openfaas-cloud/github-event
      cd ..
      rm -vrf templates/
      faas-cli build --image functions/github-event:0.8.0 --lang go --handler . --name github-event
    • Build image functions/import-secrets

      cd $GOPATH/src/github.com/openfaas/openfaas-cloud/import-secrets
      git clone https://github.com/openfaas/templates.git
      cd templates/
      git checkout 7b1468c0b522ab67665528862769c4f7327bc303
      mv -vf template/ $GOPATH/src/github.com/openfaas/openfaas-cloud/import-secrets
      cd ..
      rm -vrf templates/
      faas-cli build --image functions/import-secrets:0.3.3 --lang go --handler . --name import-secrets	
    • Build image functions/system-metrics

      cd $GOPATH/src/github.com/openfaas/openfaas-cloud/system-metrics
      git clone https://github.com/openfaas/templates.git
      cd templates/
      git checkout 7b1468c0b522ab67665528862769c4f7327bc303
      mv -vf template/ $GOPATH/src/github.com/openfaas/openfaas-cloud/system-metrics
      cd ..
      rm -vrf templates/
      faas-cli build --image functions/system-metrics:0.1.1 --lang go --handler . --name system-metrics		
    • Build image functions/github-status

      cd $GOPATH/src/github.com/openfaas/openfaas-cloud/github-status
      git clone https://github.com/openfaas/templates.git
      cd templates/
      git checkout 7b1468c0b522ab67665528862769c4f7327bc303
      mv -vf template/ $GOPATH/src/github.com/openfaas/openfaas-cloud/github-status
      cd ..
      rm -vrf templates/	
      faas-cli build --image functions/github-status:0.3.6 --lang go --handler . --name github-status
    • Build image functions/garbage-collect

      cd $GOPATH/src/github.com/openfaas/openfaas-cloud/garbage-collect
      git clone https://github.com/openfaas/templates.git
      cd templates/
      git checkout 7b1468c0b522ab67665528862769c4f7327bc303
      mv -vf template/ $GOPATH/src/github.com/openfaas/openfaas-cloud/garbage-collect
      cd ..
      rm -vrf templates/
      faas-cli build --image functions/garbage-collect:0.4.4 --lang go --handler . --name garbage-collect	
    • Build image functions/pipeline-log:0.3.3

      cd $GOPATH/src/github.com/openfaas/openfaas-cloud/pipeline-log
      git clone https://github.com/openfaas/templates.git
      cd templates/
      git checkout 7b1468c0b522ab67665528862769c4f7327bc303
      mv -vf template/ $GOPATH/src/github.com/openfaas/openfaas-cloud/pipeline-log
      cd ..
      rm -vrf templates/
      faas-cli build --image  functions/pipeline-log:0.3.3 --lang go --handler . --name pipeline-log		
    • Build image functions/github-push

      cd $GOPATH/src/github.com/openfaas/openfaas-cloud/github-push
      git clone https://github.com/openfaas/templates.git
      cd templates/
      git checkout 7b1468c0b522ab67665528862769c4f7327bc303
      mv -vf template/ $GOPATH/src/github.com/openfaas/openfaas-cloud/github-push
      cd ..
      rm -vrf templates/
      faas-cli build --image  functions/github-push:0.7.3 --lang go --handler . --name github-push		
    • Build image functions/audit-event

      cd $GOPATH/src/github.com/openfaas/openfaas-cloud/audit-event
      git clone https://github.com/openfaas/templates.git
      cd templates/
      git checkout 7b1468c0b522ab67665528862769c4f7327bc303
      mv -vf template/ $GOPATH/src/github.com/openfaas/openfaas-cloud/audit-event
      cd ..
      rm -vrf templates/
      faas-cli build --image functions/audit-event:0.1.2 --lang go --handler . --name audit-event		
    • Build image functions/list-functions

      cd $GOPATH/src/github.com/openfaas/openfaas-cloud/list-functions
      git clone https://github.com/openfaas/templates.git
      cd templates/
      git checkout 7b1468c0b522ab67665528862769c4f7327bc303
      mv -vf template/ $GOPATH/src/github.com/openfaas/openfaas-cloud/list-functions
      cd ..
      rm -vrf templates/
      faas-cli build --image functions/list-functions:0.4.7 --lang go --handler . --name list-functions	
    • Build image functions/of-cloud-dashboard

      cd $GOPATH/src/github.com/openfaas/openfaas-cloud/dashboard
      make
      faas-cli template pull https://github.com/openfaas-incubator/node10-express-template	
      faas-cli build --image functions/of-cloud-dashboard:0.4.3 --lang node --handler . --name dashboard	
    • Build image functions/gitlab-status

      cd $GOPATH/src/github.com/openfaas/openfaas-cloud/gitlab-status
      git clone https://github.com/openfaas/templates.git
      cd templates/
      git checkout 7b1468c0b522ab67665528862769c4f7327bc303
      mv -vf template/ $GOPATH/src/github.com/openfaas/openfaas-cloud/gitlab-status
      cd ..
      rm -vrf templates/
      faas-cli build --image functions/gitlab-status:0.1.1 --lang go --handler . --name gitlab-status		
    • Build image functions/gitlab-push

      cd $GOPATH/src/github.com/openfaas/openfaas-cloud/gitlab-push
      git clone https://github.com/openfaas/templates.git
      cd templates/
      git checkout 7b1468c0b522ab67665528862769c4f7327bc303
      mv -vf template/ $GOPATH/src/github.com/openfaas/openfaas-cloud/gitlab-push
      cd ..
      rm -vrf templates/
      faas-cli build --image functions/gitlab-push:0.2.1 --lang go --handler . --name gitlab-push		
    • Build image functions/gitlab-event

      cd $GOPATH/src/github.com/openfaas/openfaas-cloud/gitlab-event
      git clone https://github.com/openfaas/templates.git
      cd templates/
      git checkout 7b1468c0b522ab67665528862769c4f7327bc303
      mv -vf template/ $GOPATH/src/github.com/openfaas/openfaas-cloud/gitlab-event
      cd ..
      rm -vrf templates/
      faas-cli build --image functions/gitlab-event:0.1.2 --lang go --handler . --name gitlab-event		
  • Build image functions/alpine

     cd $GOPATH/src/github.com/openfaas/openfaas-cloud
     mkdir alpine && cd alpine && wget -q https://raw.githubusercontent.com/openfaas/faas/master/sample-functions/AlpineFunction/Dockerfile
     sed -i 's/0.14.4/0.13.4/g' Dockerfile
     docker build -f Dockerfile -t functions/alpine:latest .
     cd ../ && rm -rf alpine/
  • Apply the bootstrap changes during deployment

    cd $GOPATH/src/github.com/openfaas-incubator/ofc-bootstrap/
    sed -i 's/Always/IfNotPresent/g' templates/edge-auth-dep.yml
  • Update the ofc-bootstrap scripts

    cd $GOPATH/src/github.com/openfaas-incubator/ofc-bootstrap/

    Note: If the patch fails use --ignore-whitespace option.

    • Create the patch file patch_deploycloud with the below content

      --- scripts/deploy-cloud-components.sh_orig	2019-07-08 10:51:46.268870198 +0000
      +++ scripts/deploy-cloud-components.sh	2019-07-08 10:52:21.891227857 +0000
      @@ -17,7 +17,7 @@
          kubectl apply -f ./tmp/openfaas-cloud/yaml/core/edge-router-dep.yml
       else
          #  Disable auth service by pointing the router at the echo function:
      -    sed s/auth.openfaas/echo.openfaas-fn/g ./tmp/openfaas-cloud/yaml/core/edge-router-dep.yml | kubectl    apply -f -
      +    sed 's/edge-auth.openfaas/echo.openfaas-fn/g' ./tmp/openfaas-cloud/yaml/core/edge-router-dep.yml | kubectl apply -f -
       fi
       kubectl apply -f ./tmp/openfaas-cloud/yaml/core/edge-router-svc.yml
      
      @@ -66,7 +66,7 @@
       if [ "$GITLAB" = "true" ] ; then
          cp ../generated-gitlab.yml ./gitlab.yml
          echo "Deploying gitlab functions..."
      -    faas deploy -f ./gitlab.yml
      +    faas-cli deploy -f ./gitlab.yml
       fi
      
       cd ./dashboard
    • Apply the above patch to scripts/deploy-cloud-components.sh

      patch --ignore-whitespace scripts/deploy-cloud-components.sh patch_deploycloud
      
    • Create the patch file patch_clonecloud with the below content

      diff --git a/scripts/clone-cloud-components.sh b/scripts/clone-cloud-components.sh
      index 781ed24..ef629a8 100755
      --- a/scripts/clone-cloud-components.sh
      +++ b/scripts/clone-cloud-components.sh
      @@ -7,3 +7,5 @@ git clone https://github.com/openfaas/openfaas-cloud ./tmp/openfaas-cloud
       cd ./tmp/openfaas-cloud
       echo "Checking out openfaas/openfaas-cloud@$TAG"
       git checkout $TAG
      +sed -i 's/Always/IfNotPresent/g' yaml/core/edge-router-dep.yml
      +sed -i 's/Always/IfNotPresent/g' yaml/core/of-builder-dep.yml
    • Apply the above patch to scripts/clone-cloud-components.sh

      patch scripts/clone-cloud-components.sh patch_clonecloud
      
    • Create the patch file patch_stackyml patch_create_tiller

      Note: If the patch fails use --ignore-whitespace option.

      --- stack.yml_orig	2019-07-15 02:41:21.431435490 -0400
      +++ stack.yml	2019-07-15 02:42:45.411395542 -0400
      @@ -49,7 +49,7 @@
          git-tar:
          lang: dockerfile
          handler: ./git-tar
      -    image: functions/of-git-tar:0.13.0
      +    image: functions/of-git-tar:0.12.2
          labels:
          openfaas-cloud: "1"
          role: openfaas-system
      @@ -179,7 +179,7 @@
          list-functions:
              lang: go
              handler: ./list-functions
      -    image: functions/list-functions:0.4.8
      +    image: functions/list-functions:0.4.7
              labels:
              openfaas-cloud: "1"
              role: openfaas-system   
    • Apply the above patch to templates/stack.yml

      patch --ignore-whitespace templates/stack.yml patch_stackyml
      
    • Create the patch file patch_create_tiller with the below content

      diff --git a/scripts/create-tiller.sh b/scripts/create-tiller.sh
      index 30b9623..fee4b55 100755
      --- a/scripts/create-tiller.sh
      +++ b/scripts/create-tiller.sh
      @@ -1,3 +1,2 @@
       #!/bin/bash
      -
      -helm init --skip-refresh --upgrade --service-account tiller
      +helm init --skip-refresh  --service-account tiller
    • Apply the above patch to scripts/create-tiller.sh

      patch scripts/create-tiller.sh patch_create_tiller
      
    • Create the patch file patch_sealedsecret with the below content

      diff --git a/scripts/export-sealed-secret-pubcert.sh b/scripts/export-sealed-secret-pubcert.sh
      index babee7d..b560418 100755
      --- a/scripts/export-sealed-secret-pubcert.sh
      +++ b/scripts/export-sealed-secret-pubcert.sh
      @@ -5,14 +5,12 @@ then
           GOOS=$(go env GOOS)
           GOARCH=$(go env GOARCH)
      
      -    release=$(curl -sI https://github.com/bitnami-labs/sealed-secrets/releases/latest | grep Location | awk -F"/" '{ printf "%s", $NF }' | tr -d '\r')
      +    #release=$(curl -sI https://github.com/bitnami-labs/sealed-secrets/releases/latest | grep Location | awk -F"/" '{ printf "%s", $NF }' | tr -d '\r')
      
       #    release=$(curl --silent "https://api.github.com/repos/bitnami-labs/sealed-secrets/releases/latest" | sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p')
      -    echo "SealedSecrets release: $release"
      -
      -    curl -sLSf https://github.com/bitnami/sealed-secrets/releases/download/$release/kubeseal-$GOOS-$GOARCH > kubeseal && \
      -    chmod +x kubeseal
      +    cd $GOPATH/src/github.com/bitnami-labs/sealed-secrets/cmd/kubeseal
      +    cp kubeseal /usr/bin/kubeseal
       fi
      
      -./kubeseal --fetch-cert --controller-name=ofc-sealedsecrets-sealed-secrets > tmp/pub-cert.pem && \
      +/usr/bin/kubeseal --fetch-cert --controller-name=ofc-sealedsecrets-sealed-secrets > tmp/pub-cert.pem && \
         cat tmp/pub-cert.pem
    • Apply the above patch to scripts/export-sealed-secret-pubcert.sh

      patch scripts/export-sealed-secret-pubcert.sh patch_sealedsecret
      
    • Create the patch file patch_install_openfaas with the below content

      diff --git a/scripts/install-openfaas.sh b/scripts/install-openfaas.sh
      index a99504e..6b89fdc 100755
      --- a/scripts/install-openfaas.sh
      +++ b/scripts/install-openfaas.sh
      @@ -1,6 +1,6 @@
       #!/bin/bash
       
      -helm repo add openfaas https://openfaas.github.io/faas-netes
      +helm repo add openfaas http://127.0.0.1:8879/charts 
       
       helm repo update && \
       helm upgrade openfaas --install openfaas/openfaas \
    • Apply the above patch to scripts/install-openfaas.sh

      patch scripts/install-openfaas.sh patch_install_openfaas
      
    • Add the file minio-sa.yml in scripts

      apiVersion: v1
      kind: ServiceAccount
      metadata:
        namespace: openfaas
        name: cloud-minio
    • Create the patch file patch_install_minio with the below content

      --- a/scripts/install-minio.sh
      +++ b/scripts/install-minio.sh
      @@ -2,7 +2,7 @@
      
       export ACCESS_KEY=$(kubectl get secret -n openfaas-fn s3-access-key -o jsonpath='{.data.s3-access-key}'| base64 --decode)
       export SECRET_KEY=$(kubectl get secret -n openfaas-fn s3-secret-key -o jsonpath='{.data.s3-secret-key}'| base64 --decode)
      -
      +kubectl apply -f $GOPATH/src/github.com/openfaas-incubator/ofc-bootstrap/scripts/minio-sa.yml
       helm install --name cloud-minio --namespace openfaas \
          --set accessKey="$ACCESS_KEY",secretKey="$SECRET_KEY",replicas=1,persistence.enabled=false,service.port=9000,service.type=NodePort \
      -  stable/minio
      +  stable/minio --version 2.4.16
    • Apply the above patch to scripts/install-minio.sh

      patch scripts/install-minio.sh patch_install_minio
      
    • Create the patch file patch_install_nginx with the below content

      --- install-nginx.sh_orig       2019-07-16 08:54:20.927954252 -0400
      +++ install-nginx.sh    2019-07-16 08:55:15.257994182 -0400
      @@ -1,4 +1,5 @@
       #!/bin/bash
      
       echo helm install stable/nginx-ingress --name nginxingress --set rbac.create=true$ADDITIONAL_SET
      -helm install stable/nginx-ingress --name nginxingress --set rbac.create=true$ADDITIONAL_SET
      +
      +helm install stable/nginx-ingress --name nginxingress --version 1.9.0 --set rbac.create=true$ADDITIONAL_SET
    • Apply the above patch to scripts/install-nginx.sh

      patch scripts/install-nginx.sh patch_install_nginx
      
    • Create the patch file patch_sealed_secrets with the below content

      --- a/scripts/install-sealedsecrets.sh
      +++ b/scripts/install-sealedsecrets.sh
      @@ -5,4 +5,4 @@ release=$(curl -sI https://github.com/bitnami-labs/sealed-secrets/releases/lates
      
       echo "SealedSecrets release: $release"
      
      -helm install --namespace kube-system --name ofc-sealedsecrets stable/sealed-secrets
      +helm install --namespace kube-system --name ofc-sealedsecrets stable/sealed-secrets --version 1.2.0
    • Apply the above patch to scripts/install-sealedsecrets.sh

      patch --ignore-whitespace scripts/install-sealedsecrets.sh patch_sealed_secrets
      

Step 4: Deploy OpenFaaS Cloud

  • Serve local helm chart

     cd $GOPATH/src/github.com/openfaas/faas-netes
     helm repo index docs --url https://openfaas.github.io/faas-netes/ --merge ./docs/index.yaml
     helm serve &
  • Deploy OpenFaaS Cloud using ofc-bootstrap tool

    Note: These guidelines supplement ofc-bootstrap instructions. Before you can deploy OpenFaas Cloud using ofc-bootstap make sure your environment is ready for deployment.

    • Ensure you have a private Docker registry setup to hold OpenFaas functions deployed by the OpenFaas Cloud pipeline.
    • A DNS server as required by OpenFaas Cloud installation.
    • Ensure that old git binary is removed from /usr/bin.
    • Setup your GitHub or GitLab integration.
    • Ensure you have a Gitlab/GitHub acount to host your OpenFaaS functions and appropriate Hooks to trigger the build.
    • For Gitlab ensure you have entered the correct Redirect URL in OAuth application.
    • For GitHub ensure you configure webhook for each repository.

    Once all the required images have been built by preceding steps and init.yaml file has been created as per ofc-bootstarp instructions, you can start the deployment as follows:

    cd $GOPATH/src/github.com/openfaas-incubator/ofc-bootstrap/
    ./ofc-bootstrap -yaml=init.yaml

    Note: If the execution fails with deployments.extensions "ofc-sealedsecrets-sealed-secrets" not found please execute /scripts/reset.sh script and rerun the above command.

    References:

    https://github.com/openfaas-incubator/ofc-bootstrap#create-your-own-inityaml

    https://github.com/openfaas/openfaas-cloud/blob/0.9.4/docs/GITLAB.md

    https://docs.openfaas.com/openfaas-cloud/self-hosted/github/

    https://www.openfaas.com/blog/openfaas-cloud-gitlab/

Clone this wiki locally