Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
Add operator and dashboard image builds (#156)
Browse files Browse the repository at this point in the history
* new brancb fuasdc:x

* dashboard image added

* tests added

* dashboard fix

* small fix

* small fix

* small fi

* FINAL FIX

* improvement

* small fix

* small fix

* small fi

* small

* small fix

* additional testing

* sasdas

* path

* final fix

* print gopath

* done

* added controller

* FINAL FIX FS
  • Loading branch information
Akado2009 authored and k8s-ci-robot committed Dec 18, 2018
1 parent 4f58a83 commit d9e5551
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 21 deletions.
5 changes: 0 additions & 5 deletions Dockerfile_controller

This file was deleted.

6 changes: 0 additions & 6 deletions Dockerfile_dashboard

This file was deleted.

3 changes: 3 additions & 0 deletions build/images/dashboard/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM golang:1.8 AS build
COPY kubebench-dashboard /app/kubebench-dashboard
ENTRYPOINT /app/kubebench-dashboard
46 changes: 46 additions & 0 deletions build/images/dashboard/build_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
#
# Build Docker images for Kubebench controller.
# This is intended to be invoked as a step in Argo to build the docker image.
#
# build_image.sh ${SRC_DIR} ${DOCKERFILE} ${IMAGE} ${VERSION}
set -ex

SRC_DIR=$(realpath $1)
DOCKERFILE=$(realpath $2)
IMAGE=$3
VERSION=$4
if [ -z ${VERSION} ]; then
VERSION=$(git describe --tags --always --dirty)
fi
TAG=${REGISTRY}/${REPO_NAME}/${IMAGE}:${VERSION}

echo "Setup build directory"
export GOPATH=`mktemp -d -p $(dirname $SRC_DIR)`
export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH}
mkdir -p ${GOPATH}/src/github.com/kubeflow/kubebench
BUILD_DIR=${GOPATH}/src/github.com/kubeflow/kubebench

echo "Copy source and Dockerfile to build directory"
cp -r ${SRC_DIR}/vendor ${BUILD_DIR}/vendor
mkdir -p ${BUILD_DIR}/dashboard/
cp -r ${SRC_DIR}/dashboard/kubebench-dashboard ${BUILD_DIR}/dashboard
cp -r ${SRC_DIR}/controller ${BUILD_DIR}/controller
cp ${DOCKERFILE} ${BUILD_DIR}/Dockerfile

echo "Change working directory to ${BUILD_DIR}"
cd ${BUILD_DIR}

echo "Build go binaries"
GOOS=linux CGO_ENABLED=0 go build -o kubebench-dashboard github.com/kubeflow/kubebench/dashboard/kubebench-dashboard

echo "Authenticate gcloud account"
gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS}
echo "Build image ${TAG}"
gcloud builds submit --tag=${TAG} --project=${PROJECT} .

echo "Clean up go build directory"
cd
rm -rf ${GOPATH}

echo "Image ${TAG} built successfully"
3 changes: 3 additions & 0 deletions build/images/kubebench-operator/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM golang:1.8 AS build
COPY kubebench-operator /app/kubebench-operator
ENTRYPOINT /app/kubebench-operator
44 changes: 44 additions & 0 deletions build/images/kubebench-operator/build_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
#
# Build Docker images for Kubebench controller.
# This is intended to be invoked as a step in Argo to build the docker image.
#
# build_image.sh ${SRC_DIR} ${DOCKERFILE} ${IMAGE} ${VERSION}
set -ex

SRC_DIR=$(realpath $1)
DOCKERFILE=$(realpath $2)
IMAGE=$3
VERSION=$4
if [ -z ${VERSION} ]; then
VERSION=$(git describe --tags --always --dirty)
fi
TAG=${REGISTRY}/${REPO_NAME}/${IMAGE}:${VERSION}

echo "Setup build directory"
export GOPATH=`mktemp -d -p $(dirname $SRC_DIR)`
export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH}
mkdir -p ${GOPATH}/src/github.com/kubeflow/kubebench
BUILD_DIR=${GOPATH}/src/github.com/kubeflow/kubebench

echo "Copy source and Dockerfile to build directory"
cp -r ${SRC_DIR}/vendor ${BUILD_DIR}/vendor
cp -r ${SRC_DIR}/controller ${BUILD_DIR}/controller
cp ${DOCKERFILE} ${BUILD_DIR}/Dockerfile

echo "Change working directory to ${BUILD_DIR}"
cd ${BUILD_DIR}

echo "Build go binaries"
GOOS=linux CGO_ENABLED=0 go build github.com/kubeflow/kubebench/controller/cmd/kubebench-operator

echo "Authenticate gcloud account"
gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS}
echo "Build image ${TAG}"
gcloud builds submit --tag=${TAG} --project=${PROJECT} .

echo "Clean up go build directory"
cd
rm -rf ${GOPATH}

echo "Image ${TAG} built successfully"
8 changes: 4 additions & 4 deletions controller/cmd/kubebench-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"os/signal"
"syscall"

kubeclient "github.com/kubeflow/kubebench/controller/pkg/client"
controllers "github.com/kubeflow/kubebench/controller/pkg/controller"
log "github.com/sirupsen/logrus"
kubeclient "github.com/kubeflow/kubebench/controller/kubebench-operator/pkg/client"
controllers "github.com/kubeflow/kubebench/controller/kubebench-operator/pkg/controller"

// "github.com/kubeflow/kubebench/controller/kubebench-operator/pkg/handler"
"github.com/kubeflow/kubebench/controller/kubebench-operator/pkg/util"
// "github.com/kubeflow/kubebench/controller/pkg/handler"
"github.com/kubeflow/kubebench/controller/pkg/util"
)

func main() {
Expand Down
12 changes: 6 additions & 6 deletions dashboard/kubebench-dashboard/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (

argoproj "github.com/argoproj/argo/pkg/client/clientset/versioned/typed/workflow/v1alpha1"
"github.com/ghodss/yaml"
kbjob "github.com/kubeflow/kubebench/controller/kubebench-operator/pkg/apis/kubebenchjob/v1"
kubeclient "github.com/kubeflow/kubebench/controller/kubebench-operator/pkg/client"
kubebenchjobclientset "github.com/kubeflow/kubebench/controller/kubebench-operator/pkg/client/clientset/versioned"
kubebench "github.com/kubeflow/kubebench/controller/kubebench-operator/pkg/client/clientset/versioned/typed/kubebenchjob/v1"
"github.com/kubeflow/kubebench/controller/kubebench-operator/pkg/util"
utils "github.com/kubeflow/kubebench/controller/kubebench-operator/pkg/util"
kbjob "github.com/kubeflow/kubebench/controller/pkg/apis/kubebenchjob/v1"
kubeclient "github.com/kubeflow/kubebench/controller/pkg/client"
kubebenchjobclientset "github.com/kubeflow/kubebench/controller/pkg/client/clientset/versioned"
kubebench "github.com/kubeflow/kubebench/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1"
"github.com/kubeflow/kubebench/controller/pkg/util"
utils "github.com/kubeflow/kubebench/controller/pkg/util"
log "github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
Expand Down
Binary file removed main3
Binary file not shown.
30 changes: 30 additions & 0 deletions test/workflows/components/workflows.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@
name: "build-kubebench-examples",
template: "build-kubebench-examples",
},
{
name: "build-kubebench-operator",
template: "build-kubebench-operator",
},
{
name: "build-kubebench-dashboard",
template: "build-kubebench-dashboard",
},
],
[
{
Expand Down Expand Up @@ -322,6 +330,28 @@
],
workingDir=srcDir,
), // build-kubebench-controller
$.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate(
"build-kubebench-operator",
[
srcDir + "/build/images/kubebench-operator/build_image.sh",
srcDir,
srcDir + "/build/images/kubebench-operator/Dockerfile",
"kubebench-operator",
versionTag,
],
workingDir=srcDir,
), // build-kubebench-operator
$.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate(
"build-kubebench-dashboard",
[
srcDir + "/build/images/dashboard/build_image.sh",
srcDir,
srcDir + "/build/images/dashboard/Dockerfile",
"kubebench-dashboard",
versionTag,
],
workingDir=srcDir,
), // build-kubebench-dashboard
$.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate(
"build-kubebench-examples",
[
Expand Down

0 comments on commit d9e5551

Please sign in to comment.