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

Commit d9e5551

Browse files
Akado2009k8s-ci-robot
authored andcommitted
Add operator and dashboard image builds (#156)
* 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
1 parent 4f58a83 commit d9e5551

File tree

10 files changed

+136
-21
lines changed

10 files changed

+136
-21
lines changed

Dockerfile_controller

Lines changed: 0 additions & 5 deletions
This file was deleted.

Dockerfile_dashboard

Lines changed: 0 additions & 6 deletions
This file was deleted.

build/images/dashboard/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM golang:1.8 AS build
2+
COPY kubebench-dashboard /app/kubebench-dashboard
3+
ENTRYPOINT /app/kubebench-dashboard
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
#
3+
# Build Docker images for Kubebench controller.
4+
# This is intended to be invoked as a step in Argo to build the docker image.
5+
#
6+
# build_image.sh ${SRC_DIR} ${DOCKERFILE} ${IMAGE} ${VERSION}
7+
set -ex
8+
9+
SRC_DIR=$(realpath $1)
10+
DOCKERFILE=$(realpath $2)
11+
IMAGE=$3
12+
VERSION=$4
13+
if [ -z ${VERSION} ]; then
14+
VERSION=$(git describe --tags --always --dirty)
15+
fi
16+
TAG=${REGISTRY}/${REPO_NAME}/${IMAGE}:${VERSION}
17+
18+
echo "Setup build directory"
19+
export GOPATH=`mktemp -d -p $(dirname $SRC_DIR)`
20+
export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH}
21+
mkdir -p ${GOPATH}/src/github.com/kubeflow/kubebench
22+
BUILD_DIR=${GOPATH}/src/github.com/kubeflow/kubebench
23+
24+
echo "Copy source and Dockerfile to build directory"
25+
cp -r ${SRC_DIR}/vendor ${BUILD_DIR}/vendor
26+
mkdir -p ${BUILD_DIR}/dashboard/
27+
cp -r ${SRC_DIR}/dashboard/kubebench-dashboard ${BUILD_DIR}/dashboard
28+
cp -r ${SRC_DIR}/controller ${BUILD_DIR}/controller
29+
cp ${DOCKERFILE} ${BUILD_DIR}/Dockerfile
30+
31+
echo "Change working directory to ${BUILD_DIR}"
32+
cd ${BUILD_DIR}
33+
34+
echo "Build go binaries"
35+
GOOS=linux CGO_ENABLED=0 go build -o kubebench-dashboard github.com/kubeflow/kubebench/dashboard/kubebench-dashboard
36+
37+
echo "Authenticate gcloud account"
38+
gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS}
39+
echo "Build image ${TAG}"
40+
gcloud builds submit --tag=${TAG} --project=${PROJECT} .
41+
42+
echo "Clean up go build directory"
43+
cd
44+
rm -rf ${GOPATH}
45+
46+
echo "Image ${TAG} built successfully"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM golang:1.8 AS build
2+
COPY kubebench-operator /app/kubebench-operator
3+
ENTRYPOINT /app/kubebench-operator
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
#
3+
# Build Docker images for Kubebench controller.
4+
# This is intended to be invoked as a step in Argo to build the docker image.
5+
#
6+
# build_image.sh ${SRC_DIR} ${DOCKERFILE} ${IMAGE} ${VERSION}
7+
set -ex
8+
9+
SRC_DIR=$(realpath $1)
10+
DOCKERFILE=$(realpath $2)
11+
IMAGE=$3
12+
VERSION=$4
13+
if [ -z ${VERSION} ]; then
14+
VERSION=$(git describe --tags --always --dirty)
15+
fi
16+
TAG=${REGISTRY}/${REPO_NAME}/${IMAGE}:${VERSION}
17+
18+
echo "Setup build directory"
19+
export GOPATH=`mktemp -d -p $(dirname $SRC_DIR)`
20+
export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH}
21+
mkdir -p ${GOPATH}/src/github.com/kubeflow/kubebench
22+
BUILD_DIR=${GOPATH}/src/github.com/kubeflow/kubebench
23+
24+
echo "Copy source and Dockerfile to build directory"
25+
cp -r ${SRC_DIR}/vendor ${BUILD_DIR}/vendor
26+
cp -r ${SRC_DIR}/controller ${BUILD_DIR}/controller
27+
cp ${DOCKERFILE} ${BUILD_DIR}/Dockerfile
28+
29+
echo "Change working directory to ${BUILD_DIR}"
30+
cd ${BUILD_DIR}
31+
32+
echo "Build go binaries"
33+
GOOS=linux CGO_ENABLED=0 go build github.com/kubeflow/kubebench/controller/cmd/kubebench-operator
34+
35+
echo "Authenticate gcloud account"
36+
gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS}
37+
echo "Build image ${TAG}"
38+
gcloud builds submit --tag=${TAG} --project=${PROJECT} .
39+
40+
echo "Clean up go build directory"
41+
cd
42+
rm -rf ${GOPATH}
43+
44+
echo "Image ${TAG} built successfully"

controller/cmd/kubebench-operator/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import (
55
"os/signal"
66
"syscall"
77

8+
kubeclient "github.com/kubeflow/kubebench/controller/pkg/client"
9+
controllers "github.com/kubeflow/kubebench/controller/pkg/controller"
810
log "github.com/sirupsen/logrus"
9-
kubeclient "github.com/kubeflow/kubebench/controller/kubebench-operator/pkg/client"
10-
controllers "github.com/kubeflow/kubebench/controller/kubebench-operator/pkg/controller"
1111

12-
// "github.com/kubeflow/kubebench/controller/kubebench-operator/pkg/handler"
13-
"github.com/kubeflow/kubebench/controller/kubebench-operator/pkg/util"
12+
// "github.com/kubeflow/kubebench/controller/pkg/handler"
13+
"github.com/kubeflow/kubebench/controller/pkg/util"
1414
)
1515

1616
func main() {

dashboard/kubebench-dashboard/backend.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import (
88

99
argoproj "github.com/argoproj/argo/pkg/client/clientset/versioned/typed/workflow/v1alpha1"
1010
"github.com/ghodss/yaml"
11-
kbjob "github.com/kubeflow/kubebench/controller/kubebench-operator/pkg/apis/kubebenchjob/v1"
12-
kubeclient "github.com/kubeflow/kubebench/controller/kubebench-operator/pkg/client"
13-
kubebenchjobclientset "github.com/kubeflow/kubebench/controller/kubebench-operator/pkg/client/clientset/versioned"
14-
kubebench "github.com/kubeflow/kubebench/controller/kubebench-operator/pkg/client/clientset/versioned/typed/kubebenchjob/v1"
15-
"github.com/kubeflow/kubebench/controller/kubebench-operator/pkg/util"
16-
utils "github.com/kubeflow/kubebench/controller/kubebench-operator/pkg/util"
11+
kbjob "github.com/kubeflow/kubebench/controller/pkg/apis/kubebenchjob/v1"
12+
kubeclient "github.com/kubeflow/kubebench/controller/pkg/client"
13+
kubebenchjobclientset "github.com/kubeflow/kubebench/controller/pkg/client/clientset/versioned"
14+
kubebench "github.com/kubeflow/kubebench/controller/pkg/client/clientset/versioned/typed/kubebenchjob/v1"
15+
"github.com/kubeflow/kubebench/controller/pkg/util"
16+
utils "github.com/kubeflow/kubebench/controller/pkg/util"
1717
log "github.com/sirupsen/logrus"
1818
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1919
"k8s.io/client-go/kubernetes"

main3

-32.5 MB
Binary file not shown.

test/workflows/components/workflows.libsonnet

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,14 @@
216216
name: "build-kubebench-examples",
217217
template: "build-kubebench-examples",
218218
},
219+
{
220+
name: "build-kubebench-operator",
221+
template: "build-kubebench-operator",
222+
},
223+
{
224+
name: "build-kubebench-dashboard",
225+
template: "build-kubebench-dashboard",
226+
},
219227
],
220228
[
221229
{
@@ -322,6 +330,28 @@
322330
],
323331
workingDir=srcDir,
324332
), // build-kubebench-controller
333+
$.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate(
334+
"build-kubebench-operator",
335+
[
336+
srcDir + "/build/images/kubebench-operator/build_image.sh",
337+
srcDir,
338+
srcDir + "/build/images/kubebench-operator/Dockerfile",
339+
"kubebench-operator",
340+
versionTag,
341+
],
342+
workingDir=srcDir,
343+
), // build-kubebench-operator
344+
$.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate(
345+
"build-kubebench-dashboard",
346+
[
347+
srcDir + "/build/images/dashboard/build_image.sh",
348+
srcDir,
349+
srcDir + "/build/images/dashboard/Dockerfile",
350+
"kubebench-dashboard",
351+
versionTag,
352+
],
353+
workingDir=srcDir,
354+
), // build-kubebench-dashboard
325355
$.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate(
326356
"build-kubebench-examples",
327357
[

0 commit comments

Comments
 (0)