diff --git a/cluster/mesos/docker/.gitignore b/cluster/mesos/docker/.gitignore deleted file mode 100644 index 22ca77e7db7..00000000000 --- a/cluster/mesos/docker/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -certs -logs diff --git a/cluster/mesos/docker/OWNERS b/cluster/mesos/docker/OWNERS deleted file mode 100644 index 35011544349..00000000000 --- a/cluster/mesos/docker/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -assignees: - - karlkfi diff --git a/cluster/mesos/docker/common/bin/await-file b/cluster/mesos/docker/common/bin/await-file deleted file mode 100755 index 11b906cf948..00000000000 --- a/cluster/mesos/docker/common/bin/await-file +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2015 The Kubernetes Authors. -# -# 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. - -# Wait for a file to exist in the filesystem. -# Block up to the timeout duration in seconds (default: 10). -# Usage: await-file [-t=]
-# Requires: timeout, file - -set -o errexit -set -o nounset -set -o pipefail - -duration=10 -if [[ "${1:-}" == "-t="* ]]; then - duration="${1:3}" - [ -z "${duration}" ] && echo "Invalid duration supplied" && exit 1 - shift -fi - -file="$1" -[ -z "$file" ] && echo "No file supplied" && exit 1 - -echo "Waiting (up to ${duration}s) for ${file} to exist" -if ! timeout "${duration}" bash -c "while [ ! -f \"${file}\" ]; do sleep 0.5; done"; then - echo "Timed out" - exit 1 -fi - -echo "File ${file} exists now!" diff --git a/cluster/mesos/docker/common/bin/await-health-check b/cluster/mesos/docker/common/bin/await-health-check deleted file mode 100755 index 5e0504e5a92..00000000000 --- a/cluster/mesos/docker/common/bin/await-health-check +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2015 The Kubernetes Authors. -# -# 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. - -# Wait for a service to accept connections. -# Block up to the timeout duration in seconds (default: 10). -# Usage: await-health-check [-t=]
-# Requires: timeout, health-check - -set -o errexit -set -o nounset -set -o pipefail - -duration=10 -if [[ "${1:-}" == "-t="* ]]; then - duration="${1:3}" - [ -z "${duration}" ] && echo "Invalid duration supplied" && exit 1 - shift -fi - -address=${1:-} -[ -z "${address}" ] && echo "No address supplied" && exit 1 - -bin=$(cd "$(dirname ${BASH_SOURCE})" && pwd -P) - -echo "Waiting (up to ${duration}s) for ${address} to be healthy" -if ! timeout "${duration}" bash -c "while ! ${bin}/health-check ${address}; do sleep 0.5; done"; then - echo "Timed out" - exit 1 -fi - -echo "Health check of ${address} succeeded!" diff --git a/cluster/mesos/docker/common/bin/health-check b/cluster/mesos/docker/common/bin/health-check deleted file mode 100755 index aee95f3192b..00000000000 --- a/cluster/mesos/docker/common/bin/health-check +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2015 The Kubernetes Authors. -# -# 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. - -# Curl an endpoint and expect it to respond with status 200. -# Usage: health-check
- -set -o errexit -set -o nounset -set -o pipefail - -address=${1:-} -[ -z "${address}" ] && echo "No address supplied" && exit 1 - -status=$(curl -s -o /dev/null -w '%{http_code}' ${address}) -if [[ "${status}" == '200' ]]; then - exit 0 -fi -if [[ "${status}" == '000' ]]; then - exit 7 -fi - -exit 1 diff --git a/cluster/mesos/docker/config-default.sh b/cluster/mesos/docker/config-default.sh deleted file mode 100755 index e32086b545b..00000000000 --- a/cluster/mesos/docker/config-default.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash - -# Copyright 2015 The Kubernetes Authors. -# -# 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 the mesos/docker cluster - -NUM_NODES=${NUM_NODES:-2} -INSTANCE_PREFIX="${INSTANCE_PREFIX:-kubernetes}" -MASTER_NAME="${INSTANCE_PREFIX}-master" -NODE_NAMES=($(eval echo ${INSTANCE_PREFIX}-minion-{1..${NUM_NODES}})) - -SERVICE_CLUSTER_IP_RANGE=10.10.10.0/24 - -# Extra options to set on the Docker command line. This is useful for setting -# --insecure-registry for local registries. -DOCKER_OPTS="" - -# Optional: Deploy cluster DNS. -#ENABLE_CLUSTER_DNS=false -ENABLE_CLUSTER_DNS=true -DNS_SERVER_IP="10.10.10.10" -DNS_DOMAIN="cluster.local" - -# Optional: Enable DNS horizontal autoscaler -ENABLE_DNS_HORIZONTAL_AUTOSCALER="${KUBE_ENABLE_DNS_HORIZONTAL_AUTOSCALER:-false}" - -# Optional: Deploy cluster web interface. -ENABLE_CLUSTER_UI=true - -# Timeout (in seconds) to wait for ssl certs to be generated -KUBE_KEYGEN_TIMEOUT="${KUBE_KEYGEN_TIMEOUT:-60}" - -# Timeout (in seconds) to wait for Etcd to come up -MESOS_DOCKER_ETCD_TIMEOUT="${MESOS_DOCKER_ETCD_TIMEOUT:-60}" - -# Timeout (in seconds) to wait for the Mesos Master to come up -MESOS_DOCKER_MESOS_TIMEOUT="${MESOS_DOCKER_MESOS_TIMEOUT:-60}" - -# Timeout (in seconds) to wait for the API Server to come up -MESOS_DOCKER_API_TIMEOUT="${MESOS_DOCKER_API_TIMEOUT:-180}" - -# Timeout (in seconds) to wait for each addon to come up -MESOS_DOCKER_ADDON_TIMEOUT="${MESOS_DOCKER_ADDON_TIMEOUT:-180}" - -# Path to directory on the host to use as the root for multiple docker volumes. -# ${MESOS_DOCKER_WORK_DIR}/log - storage of component logs (written on deploy failure) -# ${MESOS_DOCKER_WORK_DIR}/auth - storage of SSL certs/keys/tokens -# ${MESOS_DOCKER_WORK_DIR}//mesos - storage of mesos slave work (e.g. task logs) -# If using docker-machine or Docker for Mac, should be under /Users (which is mounted from the host into the docker vm). -# If running in a container, $HOME should be resolved outside of the container. -MESOS_DOCKER_WORK_DIR="${MESOS_DOCKER_WORK_DIR:-${HOME}/tmp/kubernetes}" - -# Arguments to pass to docker-engine running on the mesos-slave-dind containers. -DOCKER_DAEMON_ARGS="${DOCKER_DAEMON_ARGS:---log-level=error}" - -# Force a dump of the logs into ${MESOS_DOCKER_WORK_DIR}/log on kube-down.sh. By -# default this only happens when kube-up.sh fails. -MESOS_DOCKER_DUMP_LOGS="${MESOS_DOCKER_DUMP_LOGS:-false}" - -# Skip rebuilding the involved docker containers on kube-up.sh. -MESOS_DOCKER_SKIP_BUILD="${MESOS_DOCKER_SKIP_BUILD:-false}" diff --git a/cluster/mesos/docker/config-test.sh b/cluster/mesos/docker/config-test.sh deleted file mode 100644 index 0706e171b1a..00000000000 --- a/cluster/mesos/docker/config-test.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# Copyright 2015 The Kubernetes Authors. -# -# 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 the docker-compose cluster in test mode -#Set NUM_NODES to minimum required for testing. -NUM_NODES=2 - -KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../../.. -source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/config-default.sh" diff --git a/cluster/mesos/docker/deploy-addons.sh b/cluster/mesos/docker/deploy-addons.sh deleted file mode 100755 index 488e8355761..00000000000 --- a/cluster/mesos/docker/deploy-addons.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -# Copyright 2015 The Kubernetes Authors. -# -# 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. - -# Deploy the addon services after the cluster is available -# TODO: integrate with or use /cluster/saltbase/salt/kube-addons/kube-addons.sh -# Requires: -# ENABLE_CLUSTER_DNS (Optional) - 'Y' to deploy kube-dns -# KUBE_SERVER (Optional) - url to the api server for configuring kube-dns - -set -o errexit -set -o nounset -set -o pipefail -set -o errtrace - -KUBE_ROOT=$(cd "$(dirname "${BASH_SOURCE}")/../../.." && pwd) -source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/${KUBE_CONFIG_FILE-"config-default.sh"}" -kubectl="${KUBE_ROOT}/cluster/kubectl.sh" -bin="$(cd "$(dirname "${BASH_SOURCE}")" && pwd -P)" - -# create the kube-system and static-pods namespaces -"${kubectl}" create -f "${KUBE_ROOT}/cluster/mesos/docker/kube-system-ns.yaml" -"${kubectl}" create -f "${KUBE_ROOT}/cluster/mesos/docker/static-pods-ns.yaml" - -if [ "${ENABLE_CLUSTER_DNS}" == "true" ]; then - echo "Deploying DNS Addon" 1>&2 - "${KUBE_ROOT}/third_party/intemp/intemp.sh" -t 'kube-dns' "${bin}/deploy-dns.sh" -fi - -if [ "${ENABLE_CLUSTER_UI}" == "true" ]; then - echo "Deploying UI Addon" 1>&2 - "${bin}/deploy-ui.sh" -fi diff --git a/cluster/mesos/docker/deploy-dns.sh b/cluster/mesos/docker/deploy-dns.sh deleted file mode 100755 index f21a489bfd0..00000000000 --- a/cluster/mesos/docker/deploy-dns.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash - -# Copyright 2016 The Kubernetes Authors. -# -# 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. - -# Deploy the Kube-DNS addon - -set -o errexit -set -o nounset -set -o pipefail -set -o errtrace - -KUBE_ROOT=$(cd "$(dirname "${BASH_SOURCE}")/../../.." && pwd) -source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/${KUBE_CONFIG_FILE-"config-default.sh"}" -kubectl="${KUBE_ROOT}/cluster/kubectl.sh" - -workspace=$(pwd) - -# Process salt pillar templates manually -sed -e "s/{{ pillar\['dns_domain'\] }}/${DNS_DOMAIN}/g" "${KUBE_ROOT}/cluster/addons/dns/kubedns-controller.yaml.in" > "${workspace}/kubedns-controller.yaml" -sed -e "s/{{ pillar\['dns_server'\] }}/${DNS_SERVER_IP}/g" "${KUBE_ROOT}/cluster/addons/dns/kubedns-svc.yaml.in" > "${workspace}/kubedns-svc.yaml" - -# Federation specific values. -if [[ "${FEDERATION:-}" == "true" ]]; then - FEDERATIONS_DOMAIN_MAP="${FEDERATIONS_DOMAIN_MAP:-}" - if [[ -z "${FEDERATIONS_DOMAIN_MAP}" && -n "${FEDERATION_NAME:-}" && -n "${DNS_ZONE_NAME:-}" ]]; then - FEDERATIONS_DOMAIN_MAP="${FEDERATION_NAME}=${DNS_ZONE_NAME}" - fi - if [[ -n "${FEDERATIONS_DOMAIN_MAP}" ]]; then - sed -i -e "s/{{ pillar\['federations_domain_map'\] }}/- --federations=${FEDERATIONS_DOMAIN_MAP}/g" "${workspace}/kubedns-controller.yaml" - else - sed -i -e "/{{ pillar\['federations_domain_map'\] }}/d" "${workspace}/kubedns-controller.yaml" - fi -else - sed -i -e "/{{ pillar\['federations_domain_map'\] }}/d" "${workspace}/kubedns-controller.yaml" -fi - -# Use kubectl to create kube-dns controller and service -"${kubectl}" create -f "${workspace}/kubedns-controller.yaml" -"${kubectl}" create -f "${workspace}/kubedns-svc.yaml" diff --git a/cluster/mesos/docker/deploy-ui.sh b/cluster/mesos/docker/deploy-ui.sh deleted file mode 100755 index 0c51f782f35..00000000000 --- a/cluster/mesos/docker/deploy-ui.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -# Copyright 2016 The Kubernetes Authors. -# -# 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. - -# Deploy the Kube-UI addon - -set -o errexit -set -o nounset -set -o pipefail -set -o errtrace - -KUBE_ROOT=$(cd "$(dirname "${BASH_SOURCE}")/../../.." && pwd) -source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/${KUBE_CONFIG_FILE-"config-default.sh"}" -kubectl="${KUBE_ROOT}/cluster/kubectl.sh" - -"${kubectl}" create -f "${KUBE_ROOT}/cluster/addons/dashboard/dashboard-controller.yaml" -"${kubectl}" create -f "${KUBE_ROOT}/cluster/addons/dashboard/dashboard-service.yaml" diff --git a/cluster/mesos/docker/docker-compose.yml b/cluster/mesos/docker/docker-compose.yml deleted file mode 100644 index 1f7d5c0be0e..00000000000 --- a/cluster/mesos/docker/docker-compose.yml +++ /dev/null @@ -1,169 +0,0 @@ -ambassador: - image: cpuguy83/docker-grand-ambassador:0.9.1 - volumes: - - /var/run/docker.sock:/var/run/docker.sock - command: "-name docker_apiserver_1" -etcd: - hostname: etcd - image: quay.io/coreos/etcd:v2.2.1 - ports: [ "4001:4001" ] - command: > - --listen-client-urls 'http://etcd:4001' - --advertise-client-urls 'http://etcd:4001' - --initial-cluster-state new -mesosmaster1: - hostname: mesosmaster1 - image: mesosphere/mesos:0.26.0-0.2.145.ubuntu1404 - entrypoint: [ "mesos-master" ] - ports: [ "5050:5050" ] - environment: - - MESOS_HOSTNAME=mesosmaster1 - - MESOS_PORT=5050 - - MESOS_LOG_DIR=/var/log/mesos - - MESOS_QUORUM=1 - - MESOS_REGISTRY=in_memory - - MESOS_WORK_DIR=/var/lib/mesos - - MESOS_ROLES=public - links: - - etcd - - "ambassador:apiserver" -mesosslave: - hostname: mesosslave - privileged: true - image: mesosphere/mesos-slave-dind:0.2.4_mesos-0.26.0_docker-1.8.2_ubuntu-14.04.3 - ports: [ "10248","10249" ] - entrypoint: - - bash - - -xc - - > - NAME=$$(cut -f2 -d/ <<<$${MESOSMASTER1_NAME}) && - N=$${NAME##*_} && - PUBLIC_RESOURCES="$$(if [ $${N} = 2 ]; then echo ";cpus(public):2;mem(public):640;ports(public):[7000-7999]"; fi)" && - DOCKER_NETWORK_OFFSET=0.0.$${N}.0 - exec wrapdocker mesos-slave - --work_dir="/var/tmp/mesos/$${N}" - --attributes="rack:$${N};gen:201$${N}" - --hostname=$$(getent hosts mesosslave | cut -d' ' -f1 | sort -u | tail -1) - --resources="cpus:4;mem:1280;disk:25600;ports:[8000-21099]$${PUBLIC_RESOURCES}" - command: [] - environment: - - MESOS_MASTER=mesosmaster1:5050 - - MESOS_PORT=5051 - - MESOS_LOG_DIR=/var/log/mesos - - MESOS_LOGGING_LEVEL=INFO - - MESOS_SWITCH_USER=0 - - MESOS_CONTAINERIZERS=docker,mesos - - MESOS_ISOLATION=cgroups/cpu,cgroups/mem - - VAR_LIB_DOCKER_SIZE=10 - - DOCKER_DAEMON_ARGS - links: - - etcd - - mesosmaster1 - - "ambassador:apiserver" -apiserver: - hostname: apiserver - image: mesosphere/kubernetes-mesos - entrypoint: - - /bin/bash - - "-ceu" - - > - echo "Hostname: $$(hostname -f) ($$(hostname -f | xargs resolveip.sh))" && - (grep "mesos-master\s*=" /opt/mesos-cloud.conf || echo " mesos-master = mesosmaster1:5050" >> /opt/mesos-cloud.conf) && - await-health-check "-t=${MESOS_DOCKER_ETCD_TIMEOUT}" http://etcd:4001/health && - await-health-check "-t=${MESOS_DOCKER_MESOS_TIMEOUT}" http://mesosmaster1:5050/health && - await-file "-t=${KUBE_KEYGEN_TIMEOUT}" /var/run/kubernetes/auth/apiserver.crt && - km apiserver - --address=$$(resolveip.sh apiserver) - --external-hostname=apiserver - --etcd-servers=http://etcd:4001 - --port=8888 - --admission-control=NamespaceLifecycle,LimitRanger,SecurityContextDeny,ServiceAccount,DefaultStorageClass,ResourceQuota - --authorization-mode=AlwaysAllow - --token-auth-file=/var/run/kubernetes/auth/token-users - --basic-auth-file=/var/run/kubernetes/auth/basic-users - --service-account-key-file=/var/run/kubernetes/auth/service-accounts.key - --service-cluster-ip-range=10.10.10.0/24 - --service-node-port-range=30000-32767 - --cloud-provider=mesos - --cloud-config=/opt/mesos-cloud.conf - --allow-privileged - --tls-cert-file=/var/run/kubernetes/auth/apiserver.crt - --tls-private-key-file=/var/run/kubernetes/auth/apiserver.key - --runtime-config=experimental/v1alpha1 - --v=4 - ports: [ "8888:8888", "6443:6443" ] - volumes: - - ${MESOS_DOCKER_WORK_DIR}/auth:/var/run/kubernetes/auth:ro - links: - - etcd - - mesosmaster1 -controller: - hostname: controller - image: mesosphere/kubernetes-mesos - entrypoint: - - /bin/bash - - "-ceu" - - > - echo "Hostname: $$(hostname -f) ($$(hostname -f | xargs resolveip.sh))" && - (grep "mesos-master\s*=" /opt/mesos-cloud.conf || echo " mesos-master = mesosmaster1:5050" >> /opt/mesos-cloud.conf) && - await-health-check "-t=${MESOS_DOCKER_MESOS_TIMEOUT}" http://mesosmaster1:5050/health && - await-health-check "-t=${MESOS_DOCKER_API_TIMEOUT}" http://apiserver:8888/healthz && - km controller-manager - --address=$$(resolveip.sh controller) - --master=http://apiserver:8888 - --cloud-config=/opt/mesos-cloud.conf - --service-account-private-key-file=/var/run/kubernetes/auth/service-accounts.key - --root-ca-file=/var/run/kubernetes/auth/root-ca.crt - --v=4 - volumes: - - ${MESOS_DOCKER_WORK_DIR}/auth:/var/run/kubernetes/auth:ro - links: - - mesosmaster1 - - apiserver -scheduler: - hostname: scheduler - image: mesosphere/kubernetes-mesos - entrypoint: - - /bin/bash - - "-ceu" - - > - echo "Hostname: $$(hostname -f) ($$(hostname -f | xargs resolveip.sh))" && - (grep "mesos-master\s*=" /opt/mesos-cloud.conf || echo " mesos-master = mesosmaster1:5050" >> /opt/mesos-cloud.conf) && - await-health-check "-t=${MESOS_DOCKER_ETCD_TIMEOUT}" http://etcd:4001/health && - await-health-check "-t=${MESOS_DOCKER_MESOS_TIMEOUT}" http://mesosmaster1:5050/health && - await-health-check "-t=${MESOS_DOCKER_API_TIMEOUT}" http://apiserver:8888/healthz && - km scheduler - --address=$$(resolveip.sh scheduler) - --hostname-override=scheduler - --etcd-servers=http://etcd:4001 - --mesos-user=root - --api-servers=http://apiserver:8888 - --mesos-master=mesosmaster1:5050 - --allow-privileged - --cluster-dns=10.10.10.10 - --cluster-domain=cluster.local - --mesos-executor-cpus=1.0 - --mesos-sandbox-overlay=/opt/sandbox-overlay.tar.gz - --static-pods-config=/opt/static-pods - --mesos-framework-roles=*,public - --mesos-default-pod-roles=*,public - --v=4 - --executor-logv=4 - --profiling=true - links: - - etcd - - mesosmaster1 - - apiserver - volumes: - - ./static-pod.json:/opt/static-pods/static-pod.json -keygen: - image: mesosphere/kubernetes-keygen:v1.0.0 - command: - - certgen - - /var/run/kubernetes/auth - - /var/run/kubernetes/auth - - apiserver - volumes: - - ${MESOS_DOCKER_WORK_DIR}/auth:/var/run/kubernetes/auth - links: - - apiserver diff --git a/cluster/mesos/docker/km/.gitignore b/cluster/mesos/docker/km/.gitignore deleted file mode 100644 index dcab3587151..00000000000 --- a/cluster/mesos/docker/km/.gitignore +++ /dev/null @@ -1 +0,0 @@ -overlay/ diff --git a/cluster/mesos/docker/km/Dockerfile b/cluster/mesos/docker/km/Dockerfile deleted file mode 100644 index 57f334979fa..00000000000 --- a/cluster/mesos/docker/km/Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2016 The Kubernetes Authors. -# -# 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. - -FROM ubuntu:14.04.3 -MAINTAINER Mesosphere - -RUN locale-gen en_US.UTF-8 -RUN dpkg-reconfigure locales -ENV LANG en_US.UTF-8 -ENV LC_ALL en_US.UTF-8 - -RUN apt-get update -qq && \ - DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -qqy \ - ca-certificates \ - wget \ - curl \ - && \ - apt-get clean - -RUN curl -o- https://raw.githubusercontent.com/karlkfi/resolveip/v1.0.2/install.sh | bash - -COPY ./bin/* /usr/local/bin/ -COPY ./opt/* /opt/ diff --git a/cluster/mesos/docker/km/build.sh b/cluster/mesos/docker/km/build.sh deleted file mode 100755 index 3339d2d9d24..00000000000 --- a/cluster/mesos/docker/km/build.sh +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/bash - -# Copyright 2015 The Kubernetes Authors. -# -# 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. - -# Builds a docker image that contains the kubernetes-mesos binaries. - -set -o errexit -set -o nounset -set -o pipefail - -IMAGE_REPO=${IMAGE_REPO:-mesosphere/kubernetes-mesos} -IMAGE_TAG=${IMAGE_TAG:-latest} - -script_dir=$(cd $(dirname "${BASH_SOURCE}") && pwd -P) -KUBE_ROOT=$(cd ${script_dir}/../../../.. && pwd -P) - -# Find a platform specific binary, whether it was cross compiled, locally built, or downloaded. -find-binary() { - local lookfor="${1}" - local platform="${2}" - local locations=( - "${KUBE_ROOT}/_output/dockerized/bin/${platform}/${lookfor}" - "${KUBE_ROOT}/_output/local/bin/${platform}/${lookfor}" - "${KUBE_ROOT}/platforms/${platform}/${lookfor}" - ) - local bin=$( (ls -t "${locations[@]}" 2>/dev/null || true) | head -1 ) - echo -n "${bin}" -} - -km_path=$(find-binary km linux/amd64) -if [ -z "$km_path" ]; then - km_path=$(find-binary km darwin/amd64) - if [ -z "$km_path" ]; then - echo "Failed to find km binary" 1>&2 - exit 1 - fi -fi -kube_bin_path=$(dirname ${km_path}) -common_bin_path=$(cd ${script_dir}/../common/bin && pwd -P) - -# download nsenter and socat -overlay_dir=${MESOS_DOCKER_OVERLAY_DIR:-${script_dir}/overlay} -mkdir -p "${overlay_dir}" -docker run --rm -v "${overlay_dir}:/target" jpetazzo/nsenter -docker run --rm -v "${overlay_dir}:/target" mesosphere/kubernetes-socat - -cd "${KUBE_ROOT}" - -# create temp workspace to place compiled binaries with image-specific scripts -# create temp workspace dir in KUBE_ROOT to avoid permission issues of TMPDIR on mac os x -workspace=$(env TMPDIR=$PWD mktemp -d -t "k8sm-workspace-XXXXXX") -echo "Workspace created: ${workspace}" - -cleanup() { - rm -rf "${workspace}" - rm -f "${overlay_dir}/*" - echo "Workspace deleted: ${workspace}" -} -trap 'cleanup' EXIT - -# setup workspace to mirror script dir (dockerfile expects /bin & /opt) -echo "Copying files to workspace" - -# binaries & scripts -mkdir -p "${workspace}/bin" - -#cp "${script_dir}/bin/"* "${workspace}/bin/" -cp "${common_bin_path}/"* "${workspace}/bin/" -cp "${kube_bin_path}/km" "${workspace}/bin/" - -# config -mkdir -p "${workspace}/opt" -cp "${script_dir}/opt/"* "${workspace}/opt/" - -# package up the sandbox overay -mkdir -p "${workspace}/overlay/bin" -cp -a "${overlay_dir}/nsenter" "${workspace}/overlay/bin" -cp -a "${overlay_dir}/socat" "${workspace}/overlay/bin" -chmod +x "${workspace}/overlay/bin/"* -cd "${workspace}/overlay" && tar -czvf "${workspace}/opt/sandbox-overlay.tar.gz" . && cd - - -# docker -cp "${script_dir}/Dockerfile" "${workspace}/" - -cd "${workspace}" - -# build docker image -echo "Building docker image ${IMAGE_REPO}:${IMAGE_TAG}" -set -o xtrace -docker build -t ${IMAGE_REPO}:${IMAGE_TAG} "$@" . -set +o xtrace -echo "Built docker image ${IMAGE_REPO}:${IMAGE_TAG}" diff --git a/cluster/mesos/docker/km/opt/mesos-cloud.conf b/cluster/mesos/docker/km/opt/mesos-cloud.conf deleted file mode 100644 index 99aa88eee22..00000000000 --- a/cluster/mesos/docker/km/opt/mesos-cloud.conf +++ /dev/null @@ -1,3 +0,0 @@ -[mesos-cloud] - http-client-timeout = 5s - state-cache-ttl = 20s diff --git a/cluster/mesos/docker/kube-system-ns.yaml b/cluster/mesos/docker/kube-system-ns.yaml deleted file mode 100644 index 7fa10361af6..00000000000 --- a/cluster/mesos/docker/kube-system-ns.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: "Namespace" -apiVersion: "v1" -metadata: - name: "kube-system" - labels: - name: "kube-system" \ No newline at end of file diff --git a/cluster/mesos/docker/socat/Dockerfile b/cluster/mesos/docker/socat/Dockerfile deleted file mode 100644 index d5bf541d3cd..00000000000 --- a/cluster/mesos/docker/socat/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2016 The Kubernetes Authors. -# -# 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. - -FROM ubuntu:14.04.3 -MAINTAINER Mesosphere - -RUN apt-get update -qq && \ - DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -qqy \ - build-essential curl \ - && \ - apt-get clean - -RUN mkdir -p /src -WORKDIR /src -RUN curl -f -osocat-1.7.2.4.tar.bz2 http://www.dest-unreach.org/socat/download/socat-1.7.2.4.tar.bz2 -RUN tar -xjvf socat-1.7.2.4.tar.bz2 && cd socat-1.7.2.4 && ./configure --disable-openssl && LDFLAGS=-static make - -VOLUME ["/target"] -CMD ["cp", "/src/socat-1.7.2.4/socat", "/target"] diff --git a/cluster/mesos/docker/socat/build.sh b/cluster/mesos/docker/socat/build.sh deleted file mode 100755 index e74a0c35fbc..00000000000 --- a/cluster/mesos/docker/socat/build.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -# Copyright 2015 The Kubernetes Authors. -# -# 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. - -# Builds a docker image that contains the kubernetes-mesos binaries. - -set -o errexit -set -o nounset -set -o pipefail - -script_dir=$(cd $(dirname "${BASH_SOURCE}") && pwd -P) - -cd "${script_dir}" - -docker build -t mesosphere/kubernetes-socat . diff --git a/cluster/mesos/docker/static-pod.json b/cluster/mesos/docker/static-pod.json deleted file mode 100644 index 46222fc9f14..00000000000 --- a/cluster/mesos/docker/static-pod.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "apiVersion": "v1", - "kind": "Pod", - "metadata": { - "name": "busybox", - "namespace": "static-pods" - }, - "spec": { - "containers": [ - { - "image": "busybox", - "command": [ - "sh", - "-c", - "exec tail -f /dev/null" - ], - "imagePullPolicy": "IfNotPresent", - "name": "busybox" - } - ], - "restartPolicy": "Always" - } -} diff --git a/cluster/mesos/docker/static-pods-ns.yaml b/cluster/mesos/docker/static-pods-ns.yaml deleted file mode 100644 index 7b155af87c9..00000000000 --- a/cluster/mesos/docker/static-pods-ns.yaml +++ /dev/null @@ -1,7 +0,0 @@ ---- -apiVersion: v1 -kind: Namespace -metadata: - name: static-pods - labels: - name: static-pods diff --git a/cluster/mesos/docker/test/Dockerfile b/cluster/mesos/docker/test/Dockerfile deleted file mode 100644 index 0900edc3e10..00000000000 --- a/cluster/mesos/docker/test/Dockerfile +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright 2016 The Kubernetes Authors. -# -# 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. - -FROM golang:1.6.0 -MAINTAINER Mesosphere - -# docker.io is suppossed to be in backports, but it's not there yet. -# https://github.com/docker/docker/issues/13253 -# http://docs.docker.com/installation/debian/#debian-jessie-80-64-bit -#RUN echo "deb http://httpredir.debian.org/debian jessie-backports main" >> /etc/apt/sources.list -#RUN echo "deb http://http.debian.net/debian jessie-backports main" >> /etc/apt/sources.list - -RUN apt-get update -qq && \ - DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -qqy \ - wget \ - curl \ - g++ \ - make \ - mercurial \ - git \ - rsync \ - patch \ - python \ - python-pip \ - apt-transport-https \ - && \ - apt-get clean - -# Install latest Docker -# RUN curl -sSL https://get.docker.com/ubuntu/ | sh - -# Install Docker 1.8.1 explicitly -RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D && \ - mkdir -p /etc/apt/sources.list.d && \ - echo deb https://apt.dockerproject.org/repo ubuntu-trusty main > /etc/apt/sources.list.d/docker.list && \ - apt-get update -qq && \ - DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -qqy \ - docker-engine=1.8.1-0~trusty \ - && \ - apt-get clean - -RUN pip install -U docker-compose==1.5.0 - -RUN go get github.com/tools/godep - -RUN mkdir -p /go/src/github.com/GoogleCloudPlatform/kubernetes -WORKDIR /go/src/github.com/GoogleCloudPlatform/kubernetes - -COPY ./bin/* /usr/local/bin/ - -RUN install-etcd.sh - -ENTRYPOINT [ "bash" ] diff --git a/cluster/mesos/docker/test/bin/install-etcd.sh b/cluster/mesos/docker/test/bin/install-etcd.sh deleted file mode 100755 index 7792a531858..00000000000 --- a/cluster/mesos/docker/test/bin/install-etcd.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -# Copyright 2015 The Kubernetes Authors. -# -# 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. - -# Installs etcd into /usr/local/bin - -set -o errexit -set -o nounset -set -o pipefail - -ETCD_VERSION=${ETCD_VERSION:-v2.2.1} - -full_name=etcd-${ETCD_VERSION}-linux-amd64 -archive_url=https://github.com/coreos/etcd/releases/download/${ETCD_VERSION}/${full_name}.tar.gz - -download_dir=/tmp/etcd-${ETCD_VERSION} - -mkdir ${download_dir} - -function cleanup { - rm -rf ${download_dir} -} - -trap cleanup EXIT - -cd ${download_dir} - -echo "Downloading etcd (${archive_url})..." -curl -s -L ${archive_url} | tar xvz - -echo "Installing etcd (/usr/local/bin/etcd)..." -mv ./${full_name}/etcd* /usr/local/bin/ diff --git a/cluster/mesos/docker/test/build.sh b/cluster/mesos/docker/test/build.sh deleted file mode 100755 index 441ae1a65df..00000000000 --- a/cluster/mesos/docker/test/build.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash - -# Copyright 2015 The Kubernetes Authors. -# -# 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 -o errexit -set -o nounset -set -o pipefail - -IMAGE_REPO=${IMAGE_REPO:-mesosphere/kubernetes-mesos-test} -IMAGE_TAG=${IMAGE_TAG:-latest} - -script_dir=$(cd $(dirname "${BASH_SOURCE}") && pwd -P) -common_bin_path=$(cd ${script_dir}/../common/bin && pwd -P) -KUBE_ROOT=$(cd ${script_dir}/../../../.. && pwd -P) - -cd "${KUBE_ROOT}" - -# create temp workspace to place common scripts with image-specific scripts -# create temp workspace dir in KUBE_ROOT to avoid permission issues of TMPDIR on mac os x -workspace=$(env TMPDIR=$PWD mktemp -d -t "k8sm-test-workspace-XXXXXX") -echo "Workspace created: ${workspace}" - -cleanup() { - rm -rf "${workspace}" - echo "Workspace deleted: ${workspace}" -} -trap 'cleanup' EXIT - -# setup workspace to mirror script dir (dockerfile expects /bin) -set -x -echo "Copying files to workspace" - -# binaries & scripts -mkdir -p "${workspace}/bin" -cp -a "${common_bin_path}/"* "${workspace}/bin/" -cp -a "${script_dir}/bin/"* "${workspace}/bin/" - -# docker -cp -a "${script_dir}/Dockerfile" "${workspace}/" - -cd "${workspace}" - -echo "Building docker image ${IMAGE_REPO}:${IMAGE_TAG}" -set -o xtrace -docker build -t ${IMAGE_REPO}:${IMAGE_TAG} "$@" . -set +o xtrace -echo "Built docker image ${IMAGE_REPO}:${IMAGE_TAG}" diff --git a/cluster/mesos/docker/util.sh b/cluster/mesos/docker/util.sh deleted file mode 100644 index c2f85f82206..00000000000 --- a/cluster/mesos/docker/util.sh +++ /dev/null @@ -1,407 +0,0 @@ -#!/bin/bash - -# Copyright 2015 The Kubernetes Authors. -# -# 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. - -# Example: -# export KUBERNETES_PROVIDER=mesos/docker -# go run hack/e2e.go -v -up -check_cluster_size=false -# go run hack/e2e.go -v -test -check_version_skew=false -# go run hack/e2e.go -v -down - -set -o errexit -set -o nounset -set -o pipefail -set -o errtrace - -KUBE_ROOT=$(cd "$(dirname "${BASH_SOURCE}")/../../.." && pwd) -provider_root="${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}" - -source "${provider_root}/${KUBE_CONFIG_FILE-"config-default.sh"}" -source "${KUBE_ROOT}/cluster/common.sh" - -# Execute a docker-compose command with the default environment and compose file. -function cluster::mesos::docker::docker_compose { - local params="$@" - - # All vars required to be set - declare -a env_vars=( - "KUBE_KEYGEN_TIMEOUT" - "MESOS_DOCKER_ETCD_TIMEOUT" - "MESOS_DOCKER_MESOS_TIMEOUT" - "MESOS_DOCKER_API_TIMEOUT" - "MESOS_DOCKER_ADDON_TIMEOUT" - "MESOS_DOCKER_WORK_DIR" - "DOCKER_DAEMON_ARGS" - ) - - ( - for var_name in "${env_vars[@]}"; do - export ${var_name}="${!var_name}" - done - - docker-compose -f "${provider_root}/docker-compose.yml" ${params} - ) -} - -# Pull the images from a docker compose file, if they're not already cached. -# This avoid slow remote calls from `docker-compose pull` which delegates -# to `docker pull` which always hits the remote docker repo, even if the image -# is already cached. -function cluster::mesos::docker::docker_compose_lazy_pull { - for img in $(grep '^\s*image:\s' "${provider_root}/docker-compose.yml" | sed 's/[ \t]*image:[ \t]*//'); do - read repo tag <<<$(echo "${img} "| sed 's/:/ /') - if [ -z "${tag}" ]; then - tag="latest" - fi - if ! docker images "${repo}" | awk '{print $2;}' | grep -q "${tag}"; then - docker pull "${img}" - fi - done -} - -# Run kubernetes scripts inside docker. -# This bypasses the need to set up network routing when running docker in a VM (e.g. docker-machine). -# Trap signals and kills the docker container for better signal handing -function cluster::mesos::docker::run_in_docker_test { - local entrypoint="$1" - if [[ "${entrypoint}" = "./"* ]]; then - # relative to project root - entrypoint="/go/src/github.com/GoogleCloudPlatform/kubernetes/${entrypoint}" - fi - shift - local args="$@" - - # only mount KUBECONFIG if it exists, otherwise the directory will be created/owned by root - kube_config_mount="" - if [ -n "${KUBECONFIG:-}" ] && [ -e "${KUBECONFIG}" ]; then - kube_config_mount="-v \"$(dirname ${KUBECONFIG}):/root/.kube\"" - fi - - docker run \ - --rm \ - -t $(tty &>/dev/null && echo "-i") \ - -e "KUBERNETES_PROVIDER=${KUBERNETES_PROVIDER}" \ - -v "${KUBE_ROOT}:/go/src/github.com/GoogleCloudPlatform/kubernetes" \ - ${kube_config_mount} \ - -v "/var/run/docker.sock:/var/run/docker.sock" \ - --link docker_mesosmaster1_1:mesosmaster1 \ - --link docker_apiserver_1:apiserver \ - --entrypoint="${entrypoint}" \ - mesosphere/kubernetes-mesos-test \ - ${args} - - return "$?" -} - -# Run kube-cagen.sh inside docker. -# Creating and signing in the same environment avoids a subject comparison string_mask issue. -function cluster::mesos::docker::run_in_docker_cagen { - local out_dir="$1" - - docker run \ - --rm \ - -t $(tty &>/dev/null && echo "-i") \ - -v "${out_dir}:/var/run/kubernetes/auth" \ - mesosphere/kubernetes-keygen:v1.0.0 \ - "cagen" \ - "/var/run/kubernetes/auth" - - return "$?" -} - -# Run kube-keygen.sh inside docker. -function cluster::mesos::docker::run_in_docker_keygen { - local out_file_path="$1" - local out_dir="$(dirname "${out_file_path}")" - local out_file="$(basename "${out_file_path}")" - - docker run \ - --rm \ - -t $(tty &>/dev/null && echo "-i") \ - -v "${out_dir}:/var/run/kubernetes/auth" \ - mesosphere/kubernetes-keygen:v1.0.0 \ - "keygen" \ - "/var/run/kubernetes/auth/${out_file}" - - return "$?" -} - -# Generate kubeconfig data for the created cluster. -function create-kubeconfig { - local -r auth_dir="${MESOS_DOCKER_WORK_DIR}/auth" - local kubectl="${KUBE_ROOT}/cluster/kubectl.sh" - - export CONTEXT="${KUBERNETES_PROVIDER}" - export KUBECONFIG=${KUBECONFIG:-$DEFAULT_KUBECONFIG} - # KUBECONFIG determines the file we write to, but it may not exist yet - if [[ ! -e "${KUBECONFIG}" ]]; then - mkdir -p $(dirname "${KUBECONFIG}") - touch "${KUBECONFIG}" - fi - - local token="$(cut -d, -f1 ${auth_dir}/token-users)" - "${kubectl}" config set-cluster "${CONTEXT}" --server="${KUBE_SERVER}" --certificate-authority="${auth_dir}/root-ca.crt" - "${kubectl}" config set-context "${CONTEXT}" --cluster="${CONTEXT}" --user="cluster-admin" - "${kubectl}" config set-credentials cluster-admin --token="${token}" - "${kubectl}" config use-context "${CONTEXT}" --cluster="${CONTEXT}" - - echo "Wrote config for ${CONTEXT} to ${KUBECONFIG}" 1>&2 -} - -# Perform preparations required to run e2e tests -function prepare-e2e { - echo "TODO: prepare-e2e" 1>&2 -} - -# Execute prior to running tests to build a release if required for env -function test-build-release { - # Make a release - export KUBE_RELEASE_RUN_TESTS=N - "${KUBE_ROOT}/build-tools/release.sh" -} - -# Must ensure that the following ENV vars are set -function detect-master { - # echo "KUBE_MASTER: $KUBE_MASTER" 1>&2 - - local docker_id=$(docker ps --filter="name=docker_apiserver" --quiet) - if [[ "${docker_id}" == *'\n'* ]]; then - echo "ERROR: Multiple API Servers running" 1>&2 - return 1 - fi - - master_ip=$(docker inspect --format="{{.NetworkSettings.IPAddress}}" "${docker_id}") - master_port=6443 - - KUBE_MASTER_IP="${master_ip}:${master_port}" - KUBE_SERVER="https://${KUBE_MASTER_IP}" - - echo "KUBE_MASTER_IP: $KUBE_MASTER_IP" 1>&2 -} - -# Get minion IP addresses and store in KUBE_NODE_IP_ADDRESSES[] -# These Mesos slaves MAY host Kubelets, -# but might not have a Kubelet running unless a kubernetes task has been scheduled on them. -function detect-nodes { - local docker_ids=$(docker ps --filter="name=docker_mesosslave" --quiet) - if [ -z "${docker_ids}" ]; then - echo "ERROR: Mesos slave(s) not running" 1>&2 - return 1 - fi - while read -r docker_id; do - local minion_ip=$(docker inspect --format="{{.NetworkSettings.IPAddress}}" "${docker_id}") - KUBE_NODE_IP_ADDRESSES+=("${minion_ip}") - done <<< "$docker_ids" - echo "KUBE_NODE_IP_ADDRESSES: [${KUBE_NODE_IP_ADDRESSES[*]}]" 1>&2 -} - -# Verify prereqs on host machine -function verify-prereqs { - echo "Verifying required commands" 1>&2 - hash docker 2>/dev/null || { echo "Missing required command: docker" 1>&2; exit 1; } - hash docker 2>/dev/null || { echo "Missing required command: docker-compose" 1>&2; exit 1; } -} - -# Initialize -function cluster::mesos::docker::init_auth { - local -r auth_dir="${MESOS_DOCKER_WORK_DIR}/auth" - - #TODO(karlkfi): reuse existing credentials/certs/keys - # Nuke old auth - echo "Creating Auth Dir: ${auth_dir}" 1>&2 - mkdir -p "${auth_dir}" - rm -rf "${auth_dir}"/* - - echo "Creating Certificate Authority" 1>&2 - cluster::mesos::docker::buffer_output cluster::mesos::docker::run_in_docker_cagen "${auth_dir}" - echo "Certificate Authority Key: ${auth_dir}/root-ca.key" 1>&2 - echo "Certificate Authority Cert: ${auth_dir}/root-ca.crt" 1>&2 - - echo "Creating Service Account RSA Key" 1>&2 - cluster::mesos::docker::buffer_output cluster::mesos::docker::run_in_docker_keygen "${auth_dir}/service-accounts.key" - echo "Service Account Key: ${auth_dir}/service-accounts.key" 1>&2 - - echo "Creating User Accounts" 1>&2 - cluster::mesos::docker::create_token_user "cluster-admin" > "${auth_dir}/token-users" - echo "Token Users: ${auth_dir}/token-users" 1>&2 - cluster::mesos::docker::create_basic_user "admin" "admin" > "${auth_dir}/basic-users" - echo "Basic-Auth Users: ${auth_dir}/basic-users" 1>&2 -} - -# Instantiate a kubernetes cluster. -function kube-up { - # Nuke old mesos-slave workspaces - local work_dir="${MESOS_DOCKER_WORK_DIR}/mesosslave" - echo "Creating Mesos Work Dir: ${work_dir}" 1>&2 - mkdir -p "${work_dir}" - rm -rf "${work_dir}"/* - - # Nuke old logs - local -r log_dir="${MESOS_DOCKER_WORK_DIR}/log" - mkdir -p "${log_dir}" - rm -rf "${log_dir}"/* - - # Pull before `docker-compose up` to avoid timeouts caused by slow pulls during deployment. - echo "Pulling Docker images" 1>&2 - cluster::mesos::docker::docker_compose_lazy_pull - - if [ "${MESOS_DOCKER_SKIP_BUILD}" != "true" ]; then - echo "Building Docker images" 1>&2 - # TODO: version images (k8s version, git sha, and dirty state) to avoid re-building them every time. - "${provider_root}/km/build.sh" - "${provider_root}/test/build.sh" - fi - - cluster::mesos::docker::init_auth - - # Dump logs on premature exit (errexit triggers exit). - # Trap EXIT instead of ERR, because ERR can trigger multiple times with errtrace enabled. - trap "cluster::mesos::docker::dump_logs '${log_dir}'" EXIT - - echo "Starting ${KUBERNETES_PROVIDER} cluster" 1>&2 - cluster::mesos::docker::docker_compose up -d - echo "Scaling ${KUBERNETES_PROVIDER} cluster to ${NUM_NODES} slaves" - cluster::mesos::docker::docker_compose scale mesosslave=${NUM_NODES} - - # await-health-check requires GNU timeout - # apiserver hostname resolved by docker - cluster::mesos::docker::run_in_docker_test await-health-check "-t=${MESOS_DOCKER_API_TIMEOUT}" http://apiserver:8888/healthz - - detect-master - detect-nodes - create-kubeconfig - - echo "Deploying Addons" 1>&2 - KUBE_SERVER=${KUBE_SERVER} "${provider_root}/deploy-addons.sh" - - # Wait for addons to deploy - cluster::mesos::docker::await_ready "kube-dns" "${MESOS_DOCKER_ADDON_TIMEOUT}" - cluster::mesos::docker::await_ready "kubernetes-dashboard" "${MESOS_DOCKER_ADDON_TIMEOUT}" - - trap - EXIT -} - -function validate-cluster { - echo "Validating ${KUBERNETES_PROVIDER} cluster" 1>&2 - - # Do not validate cluster size. There will be zero k8s minions until a pod is created. - # TODO(karlkfi): use componentstatuses or equivalent when it supports non-localhost core components - - # Validate immediate cluster reachability and responsiveness - echo "KubeDNS: $(cluster::mesos::docker::addon_status 'kube-dns')" - echo "Kubernetes Dashboard: $(cluster::mesos::docker::addon_status 'kubernetes-dashboard')" -} - -# Delete a kubernetes cluster -function kube-down { - if [ "${MESOS_DOCKER_DUMP_LOGS}" == "true" ]; then - cluster::mesos::docker::dump_logs "${MESOS_DOCKER_WORK_DIR}/log" - fi - echo "Stopping ${KUBERNETES_PROVIDER} cluster" 1>&2 - # Since restoring a stopped cluster is not yet supported, use the nuclear option - cluster::mesos::docker::docker_compose kill - cluster::mesos::docker::docker_compose rm -f -} - -function test-setup { - echo "test-setup" 1>&2 - "${KUBE_ROOT}/cluster/kube-up.sh" -} - -# Execute after running tests to perform any required clean-up -function test-teardown { - echo "test-teardown" 1>&2 - kube-down -} - -## Below functions used by hack/e2e-suite/services.sh - -# SSH to a node by name or IP ($1) and run a command ($2). -function ssh-to-node { - echo "TODO: ssh-to-node" 1>&2 -} - -# Waits for a kube-system pod (of the provided name) to have the phase/status "Running". -function cluster::mesos::docker::await_ready { - local pod_name="$1" - local max_attempts="$2" - local phase="Unknown" - echo -n "${pod_name}: " - local n=0 - until [ ${n} -ge ${max_attempts} ]; do - phase=$(cluster::mesos::docker::addon_status "${pod_name}") - if [ "${phase}" == "Running" ]; then - break - fi - echo -n "." - n=$[$n+1] - sleep 1 - done - echo "${phase}" - return $([ "${phase}" == "Running" ]; echo $?) -} - -# Prints the status of the kube-system pod specified -function cluster::mesos::docker::addon_status { - local pod_name="$1" - local kubectl="${KUBE_ROOT}/cluster/kubectl.sh" - local phase=$("${kubectl}" get pods --namespace=kube-system -l k8s-app=${pod_name} -o template --template="{{(index .items 0).status.phase}}" 2>/dev/null) - phase="${phase:-Unknown}" - echo "${phase}" -} - -function cluster::mesos::docker::dump_logs { - local out_dir="$1" - echo "Dumping logs to '${out_dir}'" 1>&2 - mkdir -p "${out_dir}" - while read name; do - docker logs "${name}" &> "${out_dir}/${name}.log" - done < <(cluster::mesos::docker::docker_compose ps -q | xargs docker inspect --format '{{.Name}}') -} - -# Creates a k8s token auth user file. -# See /docs/admin/authentication.md -function cluster::mesos::docker::create_token_user { - local user_name="$1" - echo "$(openssl rand -hex 32),${user_name},${user_name}" -} - -# Creates a k8s basic auth user file. -# See /docs/admin/authentication.md -function cluster::mesos::docker::create_basic_user { - local user_name="$1" - local password="$2" - echo "${password},${user_name},${user_name}" -} - -# Buffers command output to file, prints output on failure. -function cluster::mesos::docker::buffer_output { - local cmd="$@" - local tempfile="$(mktemp "${TMPDIR:-/tmp}/buffer.XXXXXX")" - trap "kill -TERM \${PID}; rm '${tempfile}'" TERM INT - set +e - ${cmd} &> "${tempfile}" & - PID=$! - wait ${PID} - trap - TERM INT - wait ${PID} - local exit_status="$?" - set -e - if [ "${exit_status}" != 0 ]; then - cat "${tempfile}" 1>&2 - fi - rm "${tempfile}" - return "${exit_status}" -}