Skip to content

Commit

Permalink
Use binary releases for cluster push scripts.
Browse files Browse the repository at this point in the history
This is for GCE right now.  Other clouds/clusters are probably broken.
  • Loading branch information
jbeda committed Oct 10, 2014
1 parent f5dffe3 commit 15cd6f0
Show file tree
Hide file tree
Showing 19 changed files with 394 additions and 434 deletions.
110 changes: 76 additions & 34 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,16 @@ function kube::build::clean_images() {
function kube::build::run_build_command() {
[[ -n "$@" ]] || { echo "Invalid input." >&2; return 4; }

local -r docker="docker run --rm --name=${DOCKER_CONTAINER_NAME} -it ${DOCKER_MOUNT} ${KUBE_BUILD_IMAGE}"
local -r docker="docker run --name=${DOCKER_CONTAINER_NAME} -it ${DOCKER_MOUNT} ${KUBE_BUILD_IMAGE}"

# Remove the container if it is left over from some previous aborted run
docker rm ${DOCKER_CONTAINER_NAME} >/dev/null 2>&1 || true

${docker} "$@"

# Remove the container after we run. '--rm' might be appropriate but it
# appears that sometimes it fails. See
# https://github.com/docker/docker/issues/3968
docker rm ${DOCKER_CONTAINER_NAME} >/dev/null 2>&1 || true
}

# If the Docker server is remote, copy the results back out.
Expand All @@ -264,7 +269,7 @@ function kube::build::copy_output() {
# The easiest thing I (jbeda) could figure out was to launch another
# container pointed at the same volume, tar the output directory and ship
# that tar over stdou.
local -r docker="docker run -a stdout --rm --name=${DOCKER_CONTAINER_NAME} ${DOCKER_MOUNT} ${KUBE_BUILD_IMAGE}"
local -r docker="docker run -a stdout --name=${DOCKER_CONTAINER_NAME} ${DOCKER_MOUNT} ${KUBE_BUILD_IMAGE}"

# Kill any leftover container
docker rm ${DOCKER_CONTAINER_NAME} >/dev/null 2>&1 || true
Expand All @@ -275,6 +280,11 @@ function kube::build::copy_output() {
${docker} sh -c "tar c -C ${REMOTE_OUTPUT_DIR} . ; sleep 1" \
| tar xv -C "${LOCAL_OUTPUT_BUILD}"

# Remove the container after we run. '--rm' might be appropriate but it
# appears that sometimes it fails. See
# https://github.com/docker/docker/issues/3968
docker rm ${DOCKER_CONTAINER_NAME} >/dev/null 2>&1 || true

# I (jbeda) also tried getting rsync working using 'docker run' as the
# 'remote shell'. This mostly worked but there was a hang when
# closing/finishing things off. Ug.
Expand All @@ -292,27 +302,10 @@ function kube::release::package_tarballs() {
rm -rf "${RELEASE_DIR}"
mkdir -p "${RELEASE_DIR}"

kube::release::package_full_tarball
kube::release::package_client_tarballs
kube::release::package_server_tarball
}

# This is all the stuff you need to run/install kubernetes. This includes:
# - precompiled binaries for client and server
# - Cluster spin up/down scripts and configs for various cloud providers
function kube::release::package_full_tarball() {
local release_stage="${LOCAL_OUTPUT_ROOT}/release-stage/full/kubernetes"
rm -rf "${release_stage}"
mkdir -p "${release_stage}"

cp -R "${LOCAL_OUTPUT_ROOT}/build" "${release_stage}/platforms"
cp -R "${KUBE_REPO_ROOT}/cluster" "${release_stage}/"
cp -R "${KUBE_REPO_ROOT}/examples" "${release_stage}/"
cp "${KUBE_REPO_ROOT}/README.md" "${release_stage}/"
cp "${KUBE_REPO_ROOT}/LICENSE" "${release_stage}/"

local package_name="${RELEASE_DIR}/kubernetes.tar.gz"
tar czf "${package_name}" -C "${release_stage}/.." .
kube::release::package_server_tarballs
kube::release::package_salt_tarball
kube::release::package_full_tarball
}

# Package up all of the cross compiled clients. Over time this should grow into
Expand All @@ -323,43 +316,92 @@ function kube::release::package_client_tarballs() {
platforms=($(cd "${LOCAL_OUTPUT_ROOT}/build" ; echo */*))
for platform in "${platforms[@]}" ; do
local platform_tag=${platform/\//-} # Replace a "/" for a "-"
echo "+++ Building client tarball for $platform_tag"
echo "+++ Building tarball: client $platform_tag"

local release_stage="${LOCAL_OUTPUT_ROOT}/release-stage/client/${platform_tag}/kubernetes/client"
local release_stage="${LOCAL_OUTPUT_ROOT}/release-stage/client/${platform_tag}/kubernetes"
rm -rf "${release_stage}"
mkdir -p "${release_stage}/bin"
mkdir -p "${release_stage}/client/bin"

# This fancy expression will expand to prepend a path
# (${LOCAL_OUTPUT_ROOT}/build/${platform}/) to every item in the
# KUBE_CLIENT_BINARIES array.
cp "${KUBE_CLIENT_BINARIES[@]/#/${LOCAL_OUTPUT_ROOT}/build/${platform}/}" "${release_stage}/bin/"
cp "${KUBE_CLIENT_BINARIES[@]/#/${LOCAL_OUTPUT_ROOT}/build/${platform}/}" \
"${release_stage}/client/bin/"

local package_name="${RELEASE_DIR}/kubernetes-client-${platform_tag}.tar.gz"
tar czf "${package_name}" -C "${release_stage}/../.." .
tar czf "${package_name}" -C "${release_stage}/.." .
done
}

# Package up all of the server binaries
function kube::release::package_server_tarball() {
function kube::release::package_server_tarballs() {
local platform
for platform in "${KUBE_SERVER_PLATFORMS[@]}" ; do
local platform_tag=${platform/\//-} # Replace a "/" for a "-"
echo "+++ Building server tarball for $platform_tag"
echo "+++ Building tarball: server $platform_tag"

local release_stage="${LOCAL_OUTPUT_ROOT}/release-stage/server/${platform_tag}/kubernetes/server"
local release_stage="${LOCAL_OUTPUT_ROOT}/release-stage/server/${platform_tag}/kubernetes"
rm -rf "${release_stage}"
mkdir -p "${release_stage}/bin"
mkdir -p "${release_stage}/server/bin"

# This fancy expression will expand to prepend a path
# (${LOCAL_OUTPUT_ROOT}/build/${platform}/) to every item in the
# KUBE_SERVER_BINARIES array.
cp "${KUBE_SERVER_BINARIES[@]/#/${LOCAL_OUTPUT_ROOT}/build/${platform}/}" "${release_stage}/bin/"
cp "${KUBE_SERVER_BINARIES[@]/#/${LOCAL_OUTPUT_ROOT}/build/${platform}/}" \
"${release_stage}/server/bin/"

local package_name="${RELEASE_DIR}/kubernetes-server-${platform_tag}.tar.gz"
tar czf "${package_name}" -C "${release_stage}/../.." .
tar czf "${package_name}" -C "${release_stage}/.." .
done
}

# Package up the salt configuration tree. This is an optional helper to getting
# a cluster up and running.
function kube::release::package_salt_tarball() {
echo "+++ Building tarball: salt"

local release_stage="${LOCAL_OUTPUT_ROOT}/release-stage/salt/kubernetes"
rm -rf "${release_stage}"
mkdir -p "${release_stage}"

cp -R "${KUBE_REPO_ROOT}/cluster/saltbase" "${release_stage}/"

local package_name="${RELEASE_DIR}/kubernetes-salt.tar.gz"
tar czf "${package_name}" -C "${release_stage}/.." .
}

# This is all the stuff you need to run/install kubernetes. This includes:
# - precompiled binaries for client
# - Cluster spin up/down scripts and configs for various cloud providers
# - tarballs for server binary and salt configs that are ready to be uploaded
# to master by whatever means appropriate.
function kube::release::package_full_tarball() {
echo "+++ Building tarball: full"

local release_stage="${LOCAL_OUTPUT_ROOT}/release-stage/full/kubernetes"
rm -rf "${release_stage}"
mkdir -p "${release_stage}"

cp -R "${LOCAL_OUTPUT_ROOT}/build" "${release_stage}/platforms"

# We want everything in /cluster except saltbase. That is only needed on the
# server.
cp -R "${KUBE_REPO_ROOT}/cluster" "${release_stage}/"
rm -rf "${release_stage}/cluster/saltbase"

mkdir -p "${release_stage}/server"
cp "${RELEASE_DIR}/kubernetes-salt.tar.gz" "${release_stage}/server/"
cp "${RELEASE_DIR}"/kubernetes-server-*.tar.gz "${release_stage}/server/"

cp -R "${KUBE_REPO_ROOT}/examples" "${release_stage}/"
cp "${KUBE_REPO_ROOT}/README.md" "${release_stage}/"
cp "${KUBE_REPO_ROOT}/LICENSE" "${release_stage}/"

local package_name="${RELEASE_DIR}/kubernetes.tar.gz"
tar czf "${package_name}" -C "${release_stage}/.." .
}


# ---------------------------------------------------------------------------
# GCS Release

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
# the release tar to download and unpack. It is meant to be pushed to the
# master and run.

echo "Downloading release ($MASTER_RELEASE_TAR)"
gsutil cp $MASTER_RELEASE_TAR master-release.tgz

echo "Downloading binary release tar ($SERVER_BINARY_TAR_URL)"
gsutil cp "$SERVER_BINARY_TAR_URL" .

echo "Unpacking release"
rm -rf master-release || false
tar xzf master-release.tgz
echo "Downloading binary release tar ($SALT_TAR_URL)"
gsutil cp "$SALT_TAR_URL" .

echo "Unpacking Salt tree"
rm -rf kubernetes
tar xzf "${SALT_TAR_URL##*/}"

echo "Running release install script"
sudo master-release/src/scripts/master-release-install.sh
sudo kubernetes/saltbase/install.sh "${SERVER_BINARY_TAR_URL##*/}"
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ grains:
cloud: gce
EOF

cat <<EOF >/srv/pillar/cluster-params.sls
node_instance_prefix: $NODE_INSTANCE_PREFIX
EOF

# Auto accept all keys from minions that try to join
mkdir -p /etc/salt/master.d
cat <<EOF >/etc/salt/master.d/auto-accept.conf
Expand Down
File renamed without changes.
Loading

0 comments on commit 15cd6f0

Please sign in to comment.