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 GOOS linux
ENV GOARCH amd64 ENV GOARCH amd64
# Get the code coverage tool and etcd for integration tests # Get the code coverage tool and godep
RUN go get code.google.com/p/go.tools/cmd/cover github.com/coreos/etcd github.com/tools/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 # Mark this as a kube-build container
RUN touch /kube-build-image 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 echo "WARNING: This script should be run in the kube-build conrtainer image!" >&2
fi 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() { function make-binaries() {
readonly BINARIES=" if [[ ${#targets[@]} -eq 0 ]]; then
proxy targets=(
integration cmd/proxy
apiserver cmd/apiserver
controller-manager cmd/controller-manager
kubelet cmd/kubelet
kubecfg" 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}" ARCH_TARGET="${KUBE_TARGET}/${GOOS}/${GOARCH}"
mkdir -p "${ARCH_TARGET}" mkdir -p "${ARCH_TARGET}"
function make-binary() { if [[ -n "$1" ]]; then
echo "+++ Building $1 for ${GOOS}/${GOARCH}" make-binary "$1"
godep go build \
-o "${ARCH_TARGET}/$1" \
github.com/GoogleCloudPlatform/kubernetes/cmd/$1
}
if [[ -n $1 ]]; then
make-binary $1
exit 0 exit 0
fi fi
for b in ${BINARIES}; do local b
make-binary $b for b in "${binaries[@]}"; do
make-binary "$b"
done done
} }

View File

@ -20,15 +20,15 @@ set -e
source $(dirname $0)/common.sh source $(dirname $0)/common.sh
readonly CROSS_BINARIES=" readonly CROSS_BINARIES=(
kubecfg "./cmd/kubecfg"
" )
for platform in ${KUBE_CROSSPLATFORMS}; do for platform in ${KUBE_CROSSPLATFORMS}; do
( (
export GOOS=${platform%/*} export GOOS=${platform%/*}
export GOARCH=${platform##*/} export GOARCH=${platform##*/}
for binary in ${CROSS_BINARIES}; do for binary in "${CROSS_BINARIES[@]}"; do
make-binaries "${binary}" make-binaries "${binary}"
done done
) )

View File

@ -38,11 +38,13 @@ readonly DOCKER_CONTAINER_NAME=kube-build
readonly DOCKER_MOUNT="-v ${LOCAL_OUTPUT_DIR}:${REMOTE_OUTPUT_DIR}" readonly DOCKER_MOUNT="-v ${LOCAL_OUTPUT_DIR}:${REMOTE_OUTPUT_DIR}"
readonly KUBE_RUN_IMAGE_BASE="kubernetes" readonly KUBE_RUN_IMAGE_BASE="kubernetes"
readonly KUBE_RUN_BINARIES=" readonly KUBE_RUN_BINARIES=(
apiserver apiserver
controller-manager controller-manager
proxy proxy
" scheduler
)
# This is where the final release artifacts are created locally # This is where the final release artifacts are created locally
readonly RELEASE_DIR="${KUBE_REPO_ROOT}/_output/release" 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. # Set up the context directory for the kube-build image and build it.
function kube::build::build-image() { function kube::build::build-image() {
local -r BUILD_CONTEXT_DIR="${KUBE_REPO_ROOT}/_output/images/${KUBE_BUILD_IMAGE}" local -r BUILD_CONTEXT_DIR="${KUBE_REPO_ROOT}/_output/images/${KUBE_BUILD_IMAGE}"
local -r SOURCE=" local -r SOURCE=(
api api
build build
cmd cmd
@ -100,9 +102,9 @@ function kube::build::build-image() {
plugin plugin
README.md README.md
third_party third_party
" )
mkdir -p ${BUILD_CONTEXT_DIR} 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 cp build/build-image/Dockerfile ${BUILD_CONTEXT_DIR}/Dockerfile
kube::build::docker-build "${KUBE_BUILD_IMAGE}" "${BUILD_CONTEXT_DIR}" kube::build::docker-build "${KUBE_BUILD_IMAGE}" "${BUILD_CONTEXT_DIR}"
} }
@ -116,11 +118,12 @@ function kube::build::run-image() {
mkdir -p "${BUILD_CONTEXT_BASE}" mkdir -p "${BUILD_CONTEXT_BASE}"
tar czf ${BUILD_CONTEXT_BASE}/kube-bins.tar.gz \ tar czf ${BUILD_CONTEXT_BASE}/kube-bins.tar.gz \
-C "_output/build/linux/amd64" \ -C "_output/build/linux/amd64" \
${KUBE_RUN_BINARIES} "${KUBE_RUN_BINARIES[@]}"
cp -R build/run-images/base/* "${BUILD_CONTEXT_BASE}/" cp -R build/run-images/base/* "${BUILD_CONTEXT_BASE}/"
kube::build::docker-build "${KUBE_RUN_IMAGE_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" local SUB_CONTEXT_DIR="${BUILD_CONTEXT_BASE}-$b"
mkdir -p "${SUB_CONTEXT_DIR}" mkdir -p "${SUB_CONTEXT_DIR}"
cp -R build/run-images/$b/* "${SUB_CONTEXT_DIR}/" cp -R build/run-images/$b/* "${SUB_CONTEXT_DIR}/"
@ -128,6 +131,16 @@ function kube::build::run-image() {
done 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. # Build a docker image from a Dockerfile.
# $1 is the name of the image to build # $1 is the name of the image to build
# $2 is the location of the "context" directory, with the Dockerfile at the root. # $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 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 # 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. # already been built. This will sync out all output data from the build.
function kube::build::run-build-command() { function kube::build::run-build-command() {
@ -325,7 +345,8 @@ function kube::release::gcs::push-images() {
kube::release::gcs::ensure-docker-registry kube::release::gcs::ensure-docker-registry
# Tag each of our run binaries with the right registry and push # 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}" 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 tag "${KUBE_RUN_IMAGE_BASE}-$b" "localhost:5000/${KUBE_RUN_IMAGE_BASE}-$b"
docker push "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::verify-prereqs
kube::build::build-image kube::build::build-image
echo "+++ Cleaning out _output/build/*"
kube::build::run-build-command rm -rf _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 WORKDIR /kubernetes
# Upload Kubernetes # Upload Kubernetes server binaries
ADD kube-bins.tar.gz /kubernetes 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::verify-prereqs
kube::build::build-image 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 kube::build::run-build-command build/build-image/run-integration.sh