mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-16 22:53:22 +00:00
Move everything out of src and reorganize scripts.
Fixed up some scripts to be more robust. Changed the e2e test setup to use g1-small instances. Fixed up documentation to reflect the new script locations. Disabled the "curl | bash" cluster launch as it hasn't been well tested and doesn't include the cloudcfg tool yet.
This commit is contained in:
83
release/config.sh
Executable file
83
release/config.sh
Executable file
@@ -0,0 +1,83 @@
|
||||
# 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.
|
||||
|
||||
# A set of defaults for Kubernetes releases
|
||||
|
||||
PROJECT=$(gcloud config list project | tail -n 1 | cut -f 3 -d ' ')
|
||||
|
||||
if which md5 > /dev/null; then
|
||||
HASH=$(md5 -q -s $PROJECT)
|
||||
else
|
||||
HASH=$(echo -n "$PROJECT" | md5sum)
|
||||
fi
|
||||
HASH=${HASH:0:5}
|
||||
RELEASE_BUCKET=${RELEASE_BUCKET-gs://kubernetes-releases-$HASH/}
|
||||
RELEASE_PREFIX=${RELEASE_PREFIX-devel/$USER/}
|
||||
RELEASE_NAME=${RELEASE_NAME-r$(date -u +%Y%m%d-%H%M%S)}
|
||||
|
||||
# This is a 'soft link' to the release in question. It is a single line file to
|
||||
# the full GS path for a release.
|
||||
RELEASE_TAG=${RELEASE_TAG-testing}
|
||||
|
||||
RELEASE_TAR_FILE=master-release.tgz
|
||||
|
||||
RELEASE_FULL_PATH=$RELEASE_BUCKET$RELEASE_PREFIX$RELEASE_NAME
|
||||
RELEASE_FULL_TAG_PATH=$RELEASE_BUCKET$RELEASE_PREFIX$RELEASE_TAG
|
||||
|
||||
# Takes a release path ($1 if passed, otherwise $RELEASE_FULL_TAG_PATH) and
|
||||
# computes the normalized release path. Results are stored in
|
||||
# $RELEASE_NORMALIZED. Returns 0 if a valid release can be found.
|
||||
function normalize_release() {
|
||||
RELEASE_NORMALIZED=${1-$RELEASE_FULL_TAG_PATH}
|
||||
|
||||
# First test to see if there is a valid release at this path.
|
||||
if gsutil -q stat $RELEASE_NORMALIZED/$RELEASE_TAR_FILE; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Check if this is a simple file. If so, read it and use the result as the
|
||||
# new RELEASE_NORMALIZED.
|
||||
if gsutil -q stat $RELEASE_NORMALIZED; then
|
||||
RELEASE_NORMALIZED=$(gsutil -q cat $RELEASE_NORMALIZED)
|
||||
normalize_release $RELEASE_NORMALIZED
|
||||
return
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# Sets a tag ($1) to a release ($2)
|
||||
function set_tag() {
|
||||
echo $2 | gsutil -q cp - $1
|
||||
|
||||
gsutil -q setmeta -h "Cache-Control:private, max-age=0, no-transform" $1
|
||||
make_public_readable $1
|
||||
}
|
||||
|
||||
# Makes a GCS object ($1) publicly readable
|
||||
function make_public_readable() {
|
||||
# Ideally we'd run the command below. But this is currently broken in the
|
||||
# newest version of gsutil. Instead, download the ACL and edit the json
|
||||
# quickly.
|
||||
|
||||
# gsutil -q acl ch -g AllUsers:R $1
|
||||
|
||||
TMPFILE=$(mktemp -t release 2>/dev/null || mktemp -t release.XXXX)
|
||||
|
||||
gsutil -q acl get $1 \
|
||||
| python $(dirname $0)/make-public-gcs-acl.py \
|
||||
> $TMPFILE
|
||||
gsutil -q acl set $TMPFILE $RELEASE_FULL_PATH/$x
|
||||
|
||||
rm $TMPFILE
|
||||
}
|
48
release/launch-kubernetes-base.sh
Executable file
48
release/launch-kubernetes-base.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
# 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.
|
||||
|
||||
# Prerequisites
|
||||
# TODO (bburns): Perhaps install cloud SDK automagically if we can't find it?
|
||||
|
||||
# Exit on any error
|
||||
set -e
|
||||
|
||||
echo "Auto installer for launching Kubernetes"
|
||||
echo "Release: $RELEASE_PREFIX$RELEASE_NAME"
|
||||
|
||||
# Make sure that prerequisites are installed.
|
||||
for x in gcloud gsutil; do
|
||||
if [ "$(which $x)" == "" ]; then
|
||||
echo "Can't find $x in PATH, please fix and retry."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# TODO(jbeda): Provide a way to install this in to someplace beyond a temp dir
|
||||
# so that users have access to local tools.
|
||||
TMPDIR=$(mktemp -d /tmp/installer.kubernetes.XXXXXX)
|
||||
|
||||
cd $TMPDIR
|
||||
|
||||
echo "Downloading support files"
|
||||
gsutil cp $RELEASE_FULL_PATH/launch-kubernetes.tgz .
|
||||
|
||||
tar xzf launch-kubernetes.tgz
|
||||
|
||||
./src/scripts/kube-up.sh $RELEASE_FULL_PATH
|
||||
|
||||
cd /
|
||||
|
||||
# clean up
|
||||
# rm -rf $TMPDIR
|
26
release/make-public-gcs-acl.py
Normal file
26
release/make-public-gcs-acl.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# 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 is a quick script that adds AllUsers as READER to a JSON file
|
||||
# representing an ACL on a GCS object. This is a quick workaround for a bug in
|
||||
# gsutil.
|
||||
import json
|
||||
import sys
|
||||
|
||||
acl = json.load(sys.stdin)
|
||||
acl.append({
|
||||
"entity": "allUsers",
|
||||
"role": "READER"
|
||||
})
|
||||
json.dump(acl, sys.stdout)
|
46
release/master-release-install.sh
Executable file
46
release/master-release-install.sh
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/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 file is meant to run on the master. It takes the release in the current
|
||||
# directory and installs everything that needs to be installed. It will then
|
||||
# also kick off a saltstack config pass
|
||||
|
||||
RELEASE_BASE=$(dirname $0)/../..
|
||||
|
||||
echo "Installing release files"
|
||||
|
||||
# Put all of the salt stuff under /srv
|
||||
mkdir -p /srv
|
||||
cp -R --preserve=mode $RELEASE_BASE/src/saltbase/* /srv
|
||||
|
||||
# Copy various go source code into the right places in the salt directory
|
||||
# hieararchy so it can be downloaded/built on all the nodes.
|
||||
mkdir -p /srv/salt/apiserver/go
|
||||
cp -R --preserve=mode $RELEASE_BASE/src/go/* /srv/salt/apiserver/go
|
||||
|
||||
mkdir -p /srv/salt/kube-proxy/go
|
||||
cp -R --preserve=mode $RELEASE_BASE/src/go/* /srv/salt/kube-proxy/go
|
||||
|
||||
mkdir -p /srv/salt/controller-manager/go
|
||||
cp -R --preserve=mode $RELEASE_BASE/src/go/* /srv/salt/controller-manager/go
|
||||
|
||||
mkdir -p /srv/salt/kubelet/go
|
||||
cp -R --preserve=mode $RELEASE_BASE/src/go/* /srv/salt/kubelet/go
|
||||
|
||||
mkdir -p /srv/salt/third-party/go
|
||||
cp -R --preserve=mode $RELEASE_BASE/third_party/go/* /srv/salt/third-party/go
|
||||
|
||||
|
99
release/release.sh
Executable file
99
release/release.sh
Executable file
@@ -0,0 +1,99 @@
|
||||
#!/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 script will build and release Kubernetes.
|
||||
#
|
||||
# The main parameters to this script come from the config.sh file. This is set
|
||||
# up by default for development releases. Feel free to edit it or override some
|
||||
# of the variables there.
|
||||
|
||||
# exit on any error
|
||||
set -e
|
||||
|
||||
source $(dirname $0)/config.sh
|
||||
|
||||
cd $(dirname $0)/..
|
||||
|
||||
# First build the release tar. This gets copied on to the master and installed
|
||||
# from there. It includes the go source for the necessary servers along with
|
||||
# the salt configs.
|
||||
rm -rf output/release/*
|
||||
|
||||
MASTER_RELEASE_DIR=output/release/master-release
|
||||
mkdir -p $MASTER_RELEASE_DIR/bin
|
||||
mkdir -p $MASTER_RELEASE_DIR/src/scripts
|
||||
mkdir -p $MASTER_RELEASE_DIR/third_party/go
|
||||
|
||||
echo "Building release tree"
|
||||
cp release/master-release-install.sh $MASTER_RELEASE_DIR/src/scripts/master-release-install.sh
|
||||
cp -r cluster/saltbase $MASTER_RELEASE_DIR/src/saltbase
|
||||
cp -r third_party $MASTER_RELEASE_DIR/third_party/go/src
|
||||
|
||||
function find_go_files() {
|
||||
find * -not \( \
|
||||
\( \
|
||||
-wholename 'third_party' \
|
||||
-o -wholename 'release' \
|
||||
\) -prune \
|
||||
\) -name '*.go'
|
||||
}
|
||||
for f in $(find_go_files); do
|
||||
mkdir -p $MASTER_RELEASE_DIR/src/go/$(dirname ${f})
|
||||
cp ${f} ${MASTER_RELEASE_DIR}/src/go/${f}
|
||||
done
|
||||
|
||||
echo "Packaging release"
|
||||
tar cz -C output/release -f output/release/master-release.tgz master-release
|
||||
|
||||
echo "Building launch script"
|
||||
# Create the local install script. These are the tools to install the local
|
||||
# tools and launch a new cluster.
|
||||
LOCAL_RELEASE_DIR=output/release/local-release
|
||||
mkdir -p $LOCAL_RELEASE_DIR/src/scripts
|
||||
|
||||
cp -r cluster/templates $LOCAL_RELEASE_DIR/src/templates
|
||||
cp -r cluster/*.sh $LOCAL_RELEASE_DIR/src/scripts
|
||||
|
||||
tar cz -C $LOCAL_RELEASE_DIR -f output/release/launch-kubernetes.tgz .
|
||||
|
||||
echo "#!/bin/bash" >> output/release/launch-kubernetes.sh
|
||||
echo "RELEASE_TAG=$RELEASE_TAG" >> output/release/launch-kubernetes.sh
|
||||
echo "RELEASE_PREFIX=$RELEASE_PREFIX" >> output/release/launch-kubernetes.sh
|
||||
echo "RELEASE_NAME=$RELEASE_NAME" >> output/release/launch-kubernetes.sh
|
||||
echo "RELEASE_FULL_PATH=$RELEASE_FULL_PATH" >> output/release/launch-kubernetes.sh
|
||||
cat release/launch-kubernetes-base.sh >> output/release/launch-kubernetes.sh
|
||||
chmod a+x output/release/launch-kubernetes.sh
|
||||
|
||||
# Now copy everything up to the release structure on GS
|
||||
echo "Uploading to Google Storage"
|
||||
if ! gsutil ls $RELEASE_BUCKET > /dev/null 2>&1 ; then
|
||||
echo "Creating $RELEASE_BUCKET"
|
||||
gsutil mb $RELEASE_BUCKET
|
||||
fi
|
||||
for x in master-release.tgz launch-kubernetes.tgz launch-kubernetes.sh; do
|
||||
gsutil -q cp output/release/$x $RELEASE_FULL_PATH/$x
|
||||
|
||||
make_public_readable $RELEASE_FULL_PATH/$x
|
||||
done
|
||||
set_tag $RELEASE_FULL_TAG_PATH $RELEASE_FULL_PATH
|
||||
|
||||
echo "Release pushed ($RELEASE_PREFIX$RELEASE_NAME)."
|
||||
|
||||
# This isn't quite working right now. Need to figure out packaging the cloudcfg tool.
|
||||
# echo " Launch with:"
|
||||
# echo
|
||||
# echo " curl -s -L ${RELEASE_FULL_PATH/gs:\/\//http://storage.googleapis.com/}/launch-kubernetes.sh | bash"
|
||||
# echo
|
Reference in New Issue
Block a user