Merge pull request #3325 from jbeda/cleanup

Some quick cleanup
This commit is contained in:
Tim Hockin 2015-01-08 10:54:58 -08:00
commit e28ed8629e
8 changed files with 0 additions and 429 deletions

View File

@ -1,3 +0,0 @@
This is a temporary directory to store code that is broken and waiting to be fixed.
As we move to binary deploys, there have been major disruptions to the way we build and deploy. Initiually this was fixed up for GCE and Vagrant. The rest of the clouds will need to be updated for this new model.

View File

@ -1,29 +0,0 @@
#!/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.
## Contains configuration values for interacting with a Local cluster
# NUMBER OF MINIONS IN THE CLUSTER
NUM_MINIONS=1
# IP LOCATIONS FOR INTERACTING WITH THE MASTER
export KUBE_MASTER_IP="127.0.0.1"
export KUBERNETES_MASTER="http://127.0.0.1:8080"
# IP LOCATIONS FOR INTERACTING WITH THE MINIONS
for (( i=0; i <${NUM_MINIONS}; i++)) do
KUBE_MINION_IP_ADDRESSES[$i]="127.0.0.1"
done

View File

@ -1,69 +0,0 @@
#!/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.
# A library of helper functions that each provider hosting Kubernetes must implement to use cluster/kube-*.sh scripts.
source $(dirname ${BASH_SOURCE})/${KUBE_CONFIG_FILE-"config-default.sh"}
function detect-master () {
echo "KUBE_MASTER_IP: $KUBE_MASTER_IP"
echo "KUBE_MASTER: $KUBE_MASTER"
}
# Get minion IP addresses and store in KUBE_MINION_IP_ADDRESSES[]
function detect-minions {
echo "Minions already detected"
}
# Verify prereqs on host machine
function verify-prereqs {
for x in go; do
if [ "$(which $x)" == "" ]; then
echo "Can't find $x in PATH, please fix and retry."
exit 1
fi
done
}
# Instantiate a kubernetes cluster
function kube-up {
echo "Not applicable"
}
# Delete a kubernetes cluster
function kube-down {
echo "Not applicable"
}
# Update a kubernetes cluster with latest source
function kube-push {
echo "Not applicable"
}
# Execute prior to running tests to build a release if required for env
function test-build-release {
echo "Not applicable"
}
# Execute prior to running tests to initialize required structure
function test-setup {
echo "Not applicable"
}
# Execute after running tests to perform any required clean-up
function test-teardown {
echo "Not applicable"
}

View File

@ -1,74 +0,0 @@
#!/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 a Kubernetes release tarball
# exit on any error
set -eu
set -o pipefail
SCRIPT_DIR=$(CDPATH="" cd $(dirname $0); pwd)
INSTANCE_PREFIX=$1
KUBE_DIR=$SCRIPT_DIR/..
. "${KUBE_DIR}/hack/config-go.sh"
# Next 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 $KUBE_DIR/_output/release/*
MASTER_RELEASE_DIR=$KUBE_DIR/_output/release/master-release
mkdir -p $MASTER_RELEASE_DIR/bin
mkdir -p $MASTER_RELEASE_DIR/src/scripts
echo "Building release tree"
cp $KUBE_DIR/release/master-release-install.sh $MASTER_RELEASE_DIR/src/scripts/master-release-install.sh
cp -r $KUBE_DIR/cluster/saltbase $MASTER_RELEASE_DIR/src/saltbase
# Capture the same version we are using to build the client tools and pass that
# on.
version_ldflags=$(kube::version_ldflags)
# Note: go_opt must stay in sync with the flags in hack/build-go.sh.
cat << EOF > $MASTER_RELEASE_DIR/src/saltbase/pillar/common.sls
instance_prefix: $INSTANCE_PREFIX-minion
go_opt: -ldflags '${version_ldflags}'
EOF
function find_go_files() {
find * -not \( \
\( \
-wholename 'release' \
-o -wholename 'output' \
-o -wholename '_output' \
-o -wholename 'examples' \
-o -wholename 'test' \
\) -prune \
\) -name '*.go'
}
# find_go_files is directory dependent
pushd $KUBE_DIR >/dev/null
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
popd >/dev/null
echo "Packaging release"
tar cz -C $KUBE_DIR/_output/release -f $KUBE_DIR/_output/release/master-release.tgz master-release

View File

@ -1,98 +0,0 @@
# 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
if [ "$(which gcloud)" == "" ]; then
echo "Couldn't find gcloud in PATH"
exit 1
fi
if [ -n "$(gcloud auth list 2>&1 | grep 'No credentialed accounts')" ]; then
gcloud auth login
fi
PROJECT=$(gcloud config list project | tail -n 1 | cut -f 3 -d ' ')
if [ ! -n "$PROJECT" ]; then
echo "Default project is not set."
echo "Please run gcloud config set project <project>"
exit 1
fi
if which md5 > /dev/null 2>&1; 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
}

View File

@ -1,26 +0,0 @@
# 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)

View File

@ -1,44 +0,0 @@
#!/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/scheduler/go
cp -R --preserve=mode $RELEASE_BASE/src/go/* /srv/salt/scheduler/go
mkdir -p /srv/salt/kubelet/go
cp -R --preserve=mode $RELEASE_BASE/src/go/* /srv/salt/kubelet/go

View File

@ -1,86 +0,0 @@
#!/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
gsutil_version=$(gsutil version | awk '{split($0,a," "); print a[3]}')
# Warning! uses lexical comparison. This really only works for major versions, or minor versions up to x.9
min_gsutil_version="4.0"
if [[ "$gsutil_version" < "$min_gsutil_version" ]]; then
echo "gsutil version $min_gsutil_version or greater is required, please run 'gcloud components upgrade'"
exit 1
fi
SCRIPT_DIR=$(CDPATH="" cd $(dirname $0); pwd)
source $SCRIPT_DIR/config.sh
KUBE_REPO_ROOT="$(cd "$(dirname "$0")/../" && pwd -P)"
source "${KUBE_REPO_ROOT}/cluster/kube-env.sh"
source $(dirname ${BASH_SOURCE})/../cluster/${KUBERNETES_PROVIDER}/${KUBE_CONFIG_FILE-"config-default.sh"}
cd $SCRIPT_DIR/..
$SCRIPT_DIR/build-release.sh $INSTANCE_PREFIX
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 kubecfg tool.
# echo " Launch with:"
# echo
# echo " curl -s -L ${RELEASE_FULL_PATH/gs:\/\//http://storage.googleapis.com/}/launch-kubernetes.sh | bash"
# echo