-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Build Kubernetes in Docker #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Building Kubernetes | ||
|
||
To build Kubernetes you need to have access to a Docker installation through either of the following methods: | ||
|
||
## Requirements | ||
|
||
1. Run on Mac OS X. The best way to go is to use `boot2docker`. See instructions [here](https://docs.docker.com/installation/mac/). | ||
2. Run on Linux against a local Docker. Install Docker according to the [instructions](https://docs.docker.com/installation/#installation) for your OS. The scripts here assume that they are using a local Docker server and that they can "reach around" docker and grab results directly from the file system. | ||
|
||
## Basic Flow | ||
|
||
The scripts directly under `build/` are used to build and test. They will ensure that the `kube-build` Docker image is built (based on `build/build-image/Dockerfile`) and then execute the appropriate command in that container. If necessary (for Mac OS X), the scripts will also copy results out. | ||
|
||
The `kube-build` container image is built by first creating a "context" directory in `output/build-image`. It is done there instead of at the root of the Kubernetes repo to minimize the amount of data we need to package up when building the image. | ||
|
||
Everything in `build/build-image/` is meant to be run inside of the container. If it doesn't think it is running in the container it'll throw a warning. While you can run some of that stuff outside of the container, it wasn't built to do so. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# 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 standard build environment for building Kubernetes | ||
|
||
FROM google/debian:wheezy | ||
MAINTAINER Joe Beda <jbeda@google.com> | ||
|
||
RUN apt-get update -y && apt-get install --no-install-recommends -y -q \ | ||
curl \ | ||
build-essential \ | ||
ca-certificates \ | ||
git \ | ||
mercurial \ | ||
rsync | ||
|
||
# Install Go | ||
# TODO(jbeda) -- we need to verify this against the hash | ||
RUN curl -s https://storage.googleapis.com/golang/go1.2.2.src.tar.gz | tar -C /usr/local -xz | ||
ENV PATH /usr/local/go/bin:$PATH | ||
RUN cd /usr/local/go/src && ./make.bash --no-clean 2>&1 | ||
|
||
# Compile Go for cross compilation | ||
ENV KUBE_CROSSPLATFORMS \ | ||
linux/386 linux/arm \ | ||
darwin/amd64 darwin/386 | ||
# (set an explicit GOARM of 5 for maximum compatibility) | ||
ENV GOARM 5 | ||
RUN cd /usr/local/go/src && \ | ||
bash -xc 'for platform in $KUBE_CROSSPLATFORMS; do GOOS=${platform%/*} GOARCH=${platform##*/} ./make.bash --no-clean 2>&1; done' | ||
|
||
# Set up Go Environment | ||
ENV PATH /go/bin:$PATH | ||
ENV GOPATH /go:/go/src/github.com/GoogleCloudPlatform/kubernetes/third_party | ||
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 | ||
|
||
# Mark this as a kube-build container | ||
RUN touch /kube-build-image | ||
|
||
WORKDIR /go/src/github.com/GoogleCloudPlatform/kubernetes | ||
|
||
# Upload Kubernetes | ||
ADD kube-source.tar.gz /go/src/github.com/GoogleCloudPlatform/kubernetes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# 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 script sets up a go workspace locally and builds all go components. | ||
# You can 'source' this file if you want to set up GOPATH in your local shell. | ||
|
||
cd $(dirname "${BASH_SOURCE}")/../.. >/dev/null | ||
readonly KUBE_REPO_ROOT="${PWD}" | ||
readonly KUBE_TARGET="${KUBE_REPO_ROOT}/output/build" | ||
readonly KUBE_GO_PACKAGE=github.com/GoogleCloudPlatform/kubernetes | ||
|
||
mkdir -p "${KUBE_TARGET}" | ||
|
||
if [[ ! -f "/kube-build-image" ]]; then | ||
echo "WARNING: This script should be run in the kube-build conrtainer image!" >&2 | ||
fi | ||
|
||
function make-binaries() { | ||
readonly BINARIES=" | ||
proxy | ||
integration | ||
apiserver | ||
controller-manager | ||
kubelet | ||
cloudcfg | ||
localkube" | ||
|
||
ARCH_TARGET="${KUBE_TARGET}/${GOOS}/${GOARCH}" | ||
mkdir -p "${ARCH_TARGET}" | ||
|
||
function make-binary() { | ||
echo "+++ Building $1 for ${GOOS}/${GOARCH}" | ||
go build \ | ||
-o "${ARCH_TARGET}/$1" \ | ||
github.com/GoogleCloudPlatform/kubernetes/cmd/$1 | ||
} | ||
|
||
if [[ -n $1 ]]; then | ||
make-binary $1 | ||
exit 0 | ||
fi | ||
|
||
for b in ${BINARIES}; do | ||
make-binary $b | ||
done | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/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. | ||
|
||
# This and builds all go components. | ||
|
||
set -e | ||
|
||
source $(dirname $0)/common.sh | ||
|
||
make-binaries |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/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. | ||
|
||
# This and builds all go components. | ||
|
||
set -e | ||
|
||
source $(dirname $0)/common.sh | ||
|
||
readonly CROSS_BINARIES=" | ||
cloudcfg | ||
" | ||
|
||
for platform in ${KUBE_CROSSPLATFORMS}; do | ||
( | ||
export GOOS=${platform%/*} | ||
export GOARCH=${platform##*/} | ||
for binary in ${CROSS_BINARIES}; do | ||
make-binaries "${binary}" | ||
done | ||
) | ||
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/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. | ||
|
||
set -e | ||
|
||
source $(dirname $0)/common.sh | ||
|
||
ETCD_DIR="${KUBE_REPO_ROOT}/output/etcd" | ||
mkdir -p "${ETCD_DIR}" | ||
|
||
etcd -name test -data-dir ${ETCD_DIR} > "${KUBE_REPO_ROOT}/output/etcd.log" & | ||
ETCD_PID=$! | ||
|
||
sleep 5 | ||
|
||
${KUBE_TARGET}/integration | ||
|
||
kill $ETCD_PID |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/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. | ||
|
||
|
||
set -e | ||
|
||
source $(dirname $0)/common.sh | ||
|
||
find_test_dirs() { | ||
( | ||
cd ${KUBE_REPO_ROOT} | ||
find . -not \( \ | ||
\( \ | ||
-wholename './third_party' \ | ||
-o -wholename './output' \ | ||
\) -prune \ | ||
\) -name '*_test.go' -print0 | xargs -0n1 dirname | sort -u | ||
) | ||
} | ||
|
||
cd "${KUBE_TARGET}" | ||
|
||
if [[ -n "$1" ]]; then | ||
go test -cover -coverprofile="tmp.out" "$KUBE_GO_PACKAGE/$1" | ||
exit 0 | ||
fi | ||
|
||
for package in $(find_test_dirs); do | ||
go test -cover -coverprofile="tmp.out" "${KUBE_GO_PACKAGE}/${package}" | ||
done |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason you do that as a separate step instead of adding linux/amd64 to the GOOS list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inspired by the Docker Dockerfile. Regardless -- linux/amd64 is special as that is the combo that we'll be supporting for cluster binaries. The others are just for the client code.