Skip to content

Commit

Permalink
Merge pull request kubernetes#25125 from colhom/federation-e2e
Browse files Browse the repository at this point in the history
e2e tests for federated-apiserver
  • Loading branch information
alex-mohr committed May 26, 2016
2 parents 60c2ab4 + a092fd2 commit 6b169ea
Show file tree
Hide file tree
Showing 34 changed files with 926 additions and 48 deletions.
9 changes: 9 additions & 0 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,27 +98,31 @@ kube::build::get_docker_wrapped_binaries() {
kube-controller-manager,busybox
kube-scheduler,busybox
kube-proxy,gcr.io/google_containers/debian-iptables-amd64:v3
federation-apiserver,busybox
);;
"arm")
local targets=(
kube-apiserver,armel/busybox
kube-controller-manager,armel/busybox
kube-scheduler,armel/busybox
kube-proxy,gcr.io/google_containers/debian-iptables-arm:v3
federation-apiserver,armel/busybox
);;
"arm64")
local targets=(
kube-apiserver,aarch64/busybox
kube-controller-manager,aarch64/busybox
kube-scheduler,aarch64/busybox
kube-proxy,gcr.io/google_containers/debian-iptables-arm64:v3
federation-apiserver,aarch64/busybox
);;
"ppc64le")
local targets=(
kube-apiserver,ppc64le/busybox
kube-controller-manager,ppc64le/busybox
kube-scheduler,ppc64le/busybox
kube-proxy,gcr.io/google_containers/debian-iptables-ppc64le:v3
federation-apiserver,ppc64le/busybox
);;
esac

Expand Down Expand Up @@ -1002,6 +1006,11 @@ function kube::release::package_full_tarball() {
mkdir -p "${release_stage}/third_party"
cp -R "${KUBE_ROOT}/third_party/htpasswd" "${release_stage}/third_party/htpasswd"

# Include only federation/cluster and federation/manifests
mkdir "${release_stage}/federation"
cp -R "${KUBE_ROOT}/federation/cluster" "${release_stage}/federation/"
cp -R "${KUBE_ROOT}/federation/manifests" "${release_stage}/federation/"

cp -R "${KUBE_ROOT}/examples" "${release_stage}/"
cp -R "${KUBE_ROOT}/docs" "${release_stage}/"
cp "${KUBE_ROOT}/README.md" "${release_stage}/"
Expand Down
29 changes: 14 additions & 15 deletions build/push-ci-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,10 @@ set -o errexit
set -o nounset
set -o pipefail

# TODO(zmerlynn): Blech, this belongs in build/common.sh, probably,
# but common.sh sets up its readonly variables when its sourced, so
# there's a chicken/egg issue getting it there and using it for
# KUBE_GCE_RELEASE_PREFIX.
function kube::release::semantic_version() {
# This takes:
# Client Version: version.Info{Major:"1", Minor:"1+", GitVersion:"v1.1.0-alpha.0.2328+3c0a05de4a38e3", GitCommit:"3c0a05de4a38e355d147dbfb4d85bad6d2d73bb9", GitTreeState:"clean"}
# and spits back the GitVersion piece in a way that is somewhat
# resilient to the other fields changing (we hope)
${KUBE_ROOT}/cluster/kubectl.sh version -c | sed "s/, */\\
/g" | egrep "^GitVersion:" | cut -f2 -d: | cut -f2 -d\"
}

KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..

source "${KUBE_ROOT}/build/util.sh"

LATEST=$(kube::release::semantic_version)

KUBE_GCS_NO_CACHING='n'
Expand All @@ -44,7 +34,7 @@ KUBE_GCS_DELETE_EXISTING='y'
KUBE_GCS_RELEASE_PREFIX="ci/${LATEST}"
KUBE_GCS_PUBLISH_VERSION="${LATEST}"

source "$KUBE_ROOT/build/common.sh"
source "${KUBE_ROOT}/build/common.sh"

MAX_ATTEMPTS=3
attempt=0
Expand All @@ -53,4 +43,13 @@ while [[ ${attempt} -lt ${MAX_ATTEMPTS} ]]; do
attempt=$((attempt + 1))
sleep 5
done
[[ ${attempt} -lt ${MAX_ATTEMPTS} ]] || exit 1
if [[ ! ${attempt} -lt ${MAX_ATTEMPTS} ]];then
kube::log::error "Max attempts reached. Will exit."
exit 1
fi

if [[ "${FEDERATION:-}" == "true" ]];then
source "${KUBE_ROOT}/federation/cluster/common.sh"
# Docker compatiblity
FEDERATION_IMAGE_TAG="$(kube::release::semantic_image_tag_version)" push-federated-images
fi
8 changes: 8 additions & 0 deletions build/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ if [[ $KUBE_RELEASE_RUN_TESTS =~ ^[yY]$ ]]; then
kube::build::run_build_command hack/test-integration.sh
fi

if [[ "${FEDERATION:-}" == "true" ]];then
(
source "${KUBE_ROOT}/build/util.sh"
# Write federated docker image tag to workspace
kube::release::semantic_image_tag_version > "${KUBE_ROOT}/federation/manifests/federated-image.tag"
)
fi

kube::build::copy_output
kube::release::package_tarballs
kube::release::package_hyperkube
32 changes: 32 additions & 0 deletions build/util.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# Copyright 2016 The Kubernetes Authors 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.

# Common utility functions for build scripts

KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..

function kube::release::semantic_version() {
# This takes:
# Client Version: version.Info{Major:"1", Minor:"1+", GitVersion:"v1.1.0-alpha.0.2328+3c0a05de4a38e3", GitCommit:"3c0a05de4a38e355d147dbfb4d85bad6d2d73bb9", GitTreeState:"clean"}
# and spits back the GitVersion piece in a way that is somewhat
# resilient to the other fields changing (we hope)
${KUBE_ROOT}/cluster/kubectl.sh version -c | sed "s/, */\\
/g" | egrep "^GitVersion:" | cut -f2 -d: | cut -f2 -d\"
}

function kube::release::semantic_image_tag_version() {
printf "$(kube::release::semantic_version)" | tr + _
}
17 changes: 15 additions & 2 deletions cluster/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ KUBE_RELEASE_VERSION_REGEX="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*
# kube::release::parse_and_validate_ci_version()
KUBE_CI_VERSION_REGEX="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)-(beta|alpha)\\.(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*)\\+[-0-9a-z]*)?$"


# Generate kubeconfig data for the created cluster.
# Assumed vars:
# KUBE_USER
Expand All @@ -50,12 +49,23 @@ KUBE_CI_VERSION_REGEX="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)-(be
# If the apiserver supports bearer auth, also provide:
# KUBE_BEARER_TOKEN
#
# If the kubeconfig context being created should NOT be set as the current context
# SECONDARY_KUBECONFIG=true
#
# To explicitly name the context being created, use OVERRIDE_CONTEXT
#
# The following can be omitted for --insecure-skip-tls-verify
# KUBE_CERT
# KUBE_KEY
# CA_CERT
function create-kubeconfig() {
local kubectl="${KUBE_ROOT}/cluster/kubectl.sh"
SECONDARY_KUBECONFIG=${SECONDARY_KUBECONFIG:-}
OVERRIDE_CONTEXT=${OVERRIDE_CONTEXT:-}

if [[ "$OVERRIDE_CONTEXT" != "" ]];then
CONTEXT=$OVERRIDE_CONTEXT
fi

export KUBECONFIG=${KUBECONFIG:-$DEFAULT_KUBECONFIG}
# KUBECONFIG determines the file we write to, but it may not exist yet
Expand Down Expand Up @@ -99,7 +109,10 @@ function create-kubeconfig() {
"${kubectl}" config set-credentials "${CONTEXT}" "${user_args[@]}"
fi
"${kubectl}" config set-context "${CONTEXT}" --cluster="${CONTEXT}" --user="${CONTEXT}"
"${kubectl}" config use-context "${CONTEXT}" --cluster="${CONTEXT}"

if [[ "${SECONDARY_KUBECONFIG}" != "true" ]];then
"${kubectl}" config use-context "${CONTEXT}" --cluster="${CONTEXT}"
fi

# If we have a bearer token, also create a credential entry with basic auth
# so that it is easy to discover the basic auth password for your cluster
Expand Down
30 changes: 30 additions & 0 deletions cluster/kube-util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,33 @@ PROVIDER_UTILS="${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
if [ -f ${PROVIDER_UTILS} ]; then
source "${PROVIDER_UTILS}"
fi

# Federation utils

# Should NOT be called within the global scope, unless setting the desired global zone vars
# This function is currently NOT USED in the global scope
function set-federated-zone-vars {
zone="$1"
export OVERRIDE_CONTEXT="federation-e2e-${KUBERNETES_PROVIDER}-$zone"
echo "Setting zone vars to: $OVERRIDE_CONTEXT"
if [[ "$KUBERNETES_PROVIDER" == "gce" ]];then

export KUBE_GCE_ZONE="$zone"
# gcloud has a 61 character limit, and for firewall rules this
# prefix gets appended to itslef, with some extra information
# need tot keep it short
export KUBE_GCE_INSTANCE_PREFIX="${USER}-${zone}"

elif [[ "$KUBERNETES_PROVIDER" == "gke" ]];then

export CLUSTER_NAME="${USER}-${zone}"

elif [[ "$KUBERNETES_PROVIDER" == "aws" ]];then

export KUBE_AWS_ZONE="$zone"
export KUBE_AWS_INSTANCE_PREFIX="${USER}-${zone}"
else
echo "Provider \"${KUBERNETES_PROVIDER}\" is not supported"
exit 1
fi
}
2 changes: 1 addition & 1 deletion cluster/vagrant/provision-master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ if ! which /usr/libexec/cockpit-ws &>/dev/null; then

pushd /etc/yum.repos.d
curl -OL https://copr.fedorainfracloud.org/coprs/g/cockpit/cockpit-preview/repo/fedora-23/msuchy-cockpit-preview-fedora-23.repo
dnf install -y cockpit cockpit-kubernetes
dnf install -y cockpit cockpit-kubernetes socat ethtool
dnf update -y docker
popd

Expand Down
2 changes: 2 additions & 0 deletions cluster/vagrant/provision-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,5 @@ add-volume-support

run-salt

dnf install -y socat ethtool
dnf update -y docker
Loading

0 comments on commit 6b169ea

Please sign in to comment.