Added scheduler binaries plus other misc fixes

* Support cleaning out built docker images
* Use bash arrays in places
* Lock etcd version we are testing against
This commit is contained in:
Joe Beda 2014-09-08 16:12:38 -07:00
parent ec8ede9354
commit 7fc3a6c050
9 changed files with 122 additions and 38 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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
)

View File

@ -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"
@ -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
@ -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}"
}
@ -116,11 +118,12 @@ 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}/"
@ -128,6 +131,16 @@ function kube::build::run-image() {
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.
@ -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() {
@ -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"

View File

@ -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

View File

@ -19,5 +19,5 @@ MAINTAINER Joe Beda <jbeda@google.com>
WORKDIR /kubernetes
# Upload Kubernetes
# Upload Kubernetes server binaries
ADD kube-bins.tar.gz /kubernetes

View File

@ -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 <jbeda@google.com>
ENV API_SERVER 127.0.0.1:8080
ADD . /kubernetes
CMD ["/kubernetes/run.sh"]

View File

@ -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}"

View File

@ -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