Skip to content

Commit

Permalink
Added scheduler binaries plus other misc fixes
Browse files Browse the repository at this point in the history
* Support cleaning out built docker images
* Use bash arrays in places
* Lock etcd version we are testing against
  • Loading branch information
jbeda committed Sep 9, 2014
1 parent ec8ede9 commit 7fc3a6c
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 38 deletions.
9 changes: 7 additions & 2 deletions build/build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ ENV GOPATH /go
ENV GOOS linux
ENV GOARCH amd64

# Get the code coverage tool and etcd for integration tests
RUN go get code.google.com/p/go.tools/cmd/cover github.com/coreos/etcd github.com/tools/godep
# Get the code coverage tool and godep
RUN go get code.google.com/p/go.tools/cmd/cover github.com/tools/godep

RUN mkdir -p /go/src/github.com/coreos/etcd && \
cd /go/src/github.com/coreos/etcd && \
git clone https://github.com/coreos/etcd.git . -b v0.4.6 --depth=1 && \
go install github.com/coreos/etcd

# Mark this as a kube-build container
RUN touch /kube-build-image
Expand Down
49 changes: 31 additions & 18 deletions build/build-image/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,44 @@ if [[ ! -f "/kube-build-image" ]]; then
echo "WARNING: This script should be run in the kube-build conrtainer image!" >&2
fi

function make-binary() {
local -r gopkg=$1
local -r bin=${gopkg##*/}

echo "+++ Building ${bin} for ${GOOS}/${GOARCH}"
pushd "${KUBE_REPO_ROOT}"
godep go build -o "${ARCH_TARGET}/${bin}" "${gopkg}"
popd
}

function make-binaries() {
readonly BINARIES="
proxy
integration
apiserver
controller-manager
kubelet
kubecfg"
if [[ ${#targets[@]} -eq 0 ]]; then
targets=(
cmd/proxy
cmd/apiserver
cmd/controller-manager
cmd/kubelet
cmd/kubecfg
plugin/cmd/scheduler
)
fi

binaries=()
local target
for target in "${targets[@]}"; do
binaries+=("${KUBE_GO_PACKAGE}/${target}")
done

ARCH_TARGET="${KUBE_TARGET}/${GOOS}/${GOARCH}"
mkdir -p "${ARCH_TARGET}"

function make-binary() {
echo "+++ Building $1 for ${GOOS}/${GOARCH}"
godep go build \
-o "${ARCH_TARGET}/$1" \
github.com/GoogleCloudPlatform/kubernetes/cmd/$1
}

if [[ -n $1 ]]; then
make-binary $1
if [[ -n "$1" ]]; then
make-binary "$1"
exit 0
fi

for b in ${BINARIES}; do
make-binary $b
local b
for b in "${binaries[@]}"; do
make-binary "$b"
done
}
8 changes: 4 additions & 4 deletions build/build-image/make-cross.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ set -e

source $(dirname $0)/common.sh

readonly CROSS_BINARIES="
kubecfg
"
readonly CROSS_BINARIES=(
"./cmd/kubecfg"
)

for platform in ${KUBE_CROSSPLATFORMS}; do
(
export GOOS=${platform%/*}
export GOARCH=${platform##*/}
for binary in ${CROSS_BINARIES}; do
for binary in "${CROSS_BINARIES[@]}"; do
make-binaries "${binary}"
done
)
Expand Down
43 changes: 32 additions & 11 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ readonly DOCKER_CONTAINER_NAME=kube-build
readonly DOCKER_MOUNT="-v ${LOCAL_OUTPUT_DIR}:${REMOTE_OUTPUT_DIR}"

readonly KUBE_RUN_IMAGE_BASE="kubernetes"
readonly KUBE_RUN_BINARIES="
apiserver
controller-manager
proxy
"
readonly KUBE_RUN_BINARIES=(
apiserver
controller-manager
proxy
scheduler
)


# This is where the final release artifacts are created locally
readonly RELEASE_DIR="${KUBE_REPO_ROOT}/_output/release"
Expand Down Expand Up @@ -88,7 +90,7 @@ function kube::build::verify-prereqs() {
# Set up the context directory for the kube-build image and build it.
function kube::build::build-image() {
local -r BUILD_CONTEXT_DIR="${KUBE_REPO_ROOT}/_output/images/${KUBE_BUILD_IMAGE}"
local -r SOURCE="
local -r SOURCE=(
api
build
cmd
Expand All @@ -100,9 +102,9 @@ function kube::build::build-image() {
plugin
README.md
third_party
"
)
mkdir -p ${BUILD_CONTEXT_DIR}
tar czf ${BUILD_CONTEXT_DIR}/kube-source.tar.gz ${SOURCE}
tar czf ${BUILD_CONTEXT_DIR}/kube-source.tar.gz "${SOURCE[@]}"
cp build/build-image/Dockerfile ${BUILD_CONTEXT_DIR}/Dockerfile
kube::build::docker-build "${KUBE_BUILD_IMAGE}" "${BUILD_CONTEXT_DIR}"
}
Expand All @@ -116,18 +118,29 @@ function kube::build::run-image() {
mkdir -p "${BUILD_CONTEXT_BASE}"
tar czf ${BUILD_CONTEXT_BASE}/kube-bins.tar.gz \
-C "_output/build/linux/amd64" \
${KUBE_RUN_BINARIES}
"${KUBE_RUN_BINARIES[@]}"
cp -R build/run-images/base/* "${BUILD_CONTEXT_BASE}/"
kube::build::docker-build "${KUBE_RUN_IMAGE_BASE}" "${BUILD_CONTEXT_BASE}"

for b in $KUBE_RUN_BINARIES ; do
local b
for b in "${KUBE_RUN_BINARIES[@]}" ; do
local SUB_CONTEXT_DIR="${BUILD_CONTEXT_BASE}-$b"
mkdir -p "${SUB_CONTEXT_DIR}"
cp -R build/run-images/$b/* "${SUB_CONTEXT_DIR}/"
kube::build::docker-build "${KUBE_RUN_IMAGE_BASE}-$b" "${SUB_CONTEXT_DIR}"
done
}

function kube::build::clean-images() {
# Clean the build image
kube::build::clean-image "${KUBE_BUILD_IMAGE}"

local b
for b in "${KUBE_RUN_BINARIES[@]}" ; do
kube::build::clean-image "${KUBE_RUN_IMAGE_BASE}-${b}"
done
}

# Build a docker image from a Dockerfile.
# $1 is the name of the image to build
# $2 is the location of the "context" directory, with the Dockerfile at the root.
Expand All @@ -154,6 +167,13 @@ function kube::build::docker-build() {
set -e
}

function kube::build::clean-image() {
local -r IMAGE=$1

echo "+++ Deleting docker image ${IMAGE}"
docker rmi ${IMAGE} 2> /dev/null || true
}

# Run a command in the kube-build image. This assumes that the image has
# already been built. This will sync out all output data from the build.
function kube::build::run-build-command() {
Expand Down Expand Up @@ -325,7 +345,8 @@ function kube::release::gcs::push-images() {
kube::release::gcs::ensure-docker-registry

# Tag each of our run binaries with the right registry and push
for b in ${KUBE_RUN_BINARIES} ; do
local b
for b in "${KUBE_RUN_BINARIES[@]}" ; do
echo "+++ Tagging and pushing ${KUBE_RUN_IMAGE_BASE}-$b to GCS bucket ${KUBE_RELEASE_BUCKET}"
docker tag "${KUBE_RUN_IMAGE_BASE}-$b" "localhost:5000/${KUBE_RUN_IMAGE_BASE}-$b"
docker push "localhost:5000/${KUBE_RUN_IMAGE_BASE}-$b"
Expand Down
4 changes: 4 additions & 0 deletions build/make-clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ source $(dirname $0)/common.sh

kube::build::verify-prereqs
kube::build::build-image

echo "+++ Cleaning out _output/build/*"
kube::build::run-build-command rm -rf _output/build/*

kube::build::clean-images
4 changes: 2 additions & 2 deletions build/run-images/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

# This file creates a minimal container for running Kubernetes binaries

FROM google/debian:wheezy
FROM google/debian:wheezy
MAINTAINER Joe Beda <[email protected]>

WORKDIR /kubernetes

# Upload Kubernetes
# Upload Kubernetes server binaries
ADD kube-bins.tar.gz /kubernetes
24 changes: 24 additions & 0 deletions build/run-images/scheduler/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2014 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This file creates a minimal container for running Kubernetes binaries

FROM kubernetes
MAINTAINER Joe Beda <[email protected]>

ENV API_SERVER 127.0.0.1:8080

ADD . /kubernetes

CMD ["/kubernetes/run.sh"]
17 changes: 17 additions & 0 deletions build/run-images/scheduler/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#! /bin/bash

# Copyright 2014 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

./scheduler -master="${API_SERVER}"
2 changes: 1 addition & 1 deletion build/run-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ source $(dirname $0)/common.sh

kube::build::verify-prereqs
kube::build::build-image
kube::build::run-build-command build/build-image/make-binaries.sh "integration"
kube::build::run-build-command build/build-image/make-binaries.sh "./cmd/integration"
kube::build::run-build-command build/build-image/run-integration.sh

0 comments on commit 7fc3a6c

Please sign in to comment.