Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b12ef5c

Browse files
committed
Merge pull request #10049 from mesosphere/docker-compose
mesos/docker automated local cluster deployment
2 parents 13258e8 + f5fa688 commit b12ef5c

22 files changed

+1494
-1
lines changed

cluster/mesos/docker/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
certs
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2015 The Kubernetes Authors All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Wait for a file to exist in the filesystem.
18+
# Block up to the timeout duration in seconds (default: 10).
19+
# Usage: await-health-check [-t=<duration>] <address>
20+
# Requires: timeout, file
21+
22+
set -o errexit
23+
set -o nounset
24+
set -o pipefail
25+
26+
duration=10
27+
if [[ "${1:-}" == "-t="* ]]; then
28+
duration="${1:3}"
29+
[ -z "${duration}" ] && echo "Invalid duration supplied" && exit 1
30+
shift
31+
fi
32+
33+
file="$1"
34+
[ -z "$file" ] && echo "No file supplied" && exit 1
35+
36+
echo "Waiting (up to ${duration}s) for ${file} to exist"
37+
if ! timeout "${duration}" bash -c "while [ ! -f \"${file}\" ]; do sleep 0.5; done"; then
38+
echo "Timed out"
39+
exit 1
40+
fi
41+
42+
echo "File ${file} exists now!"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2015 The Kubernetes Authors All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Wait for a service to accept connections.
18+
# Block up to the timeout duration in seconds (default: 10).
19+
# Usage: await-health-check [-t=<duration>] <address>
20+
# Requires: timeout, health-check
21+
22+
set -o errexit
23+
set -o nounset
24+
set -o pipefail
25+
26+
duration=10
27+
if [[ "${1:-}" == "-t="* ]]; then
28+
duration="${1:3}"
29+
[ -z "${duration}" ] && echo "Invalid duration supplied" && exit 1
30+
shift
31+
fi
32+
33+
address=${1:-}
34+
[ -z "${address}" ] && echo "No address supplied" && exit 1
35+
36+
bin=$(cd $(dirname $0) && pwd -P)
37+
38+
echo "Waiting (up to ${duration}s) for ${address} to be healthy"
39+
if ! timeout "${duration}" bash -c "while ! ${bin}/health-check ${address}; do sleep 0.5; done"; then
40+
echo "Timed out"
41+
exit 1
42+
fi
43+
44+
echo "Health check of ${address} succeeded!"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2015 The Kubernetes Authors All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Curl an endpoint and expect it to respond with status 200.
18+
# Usage: health-check <address>
19+
20+
set -o errexit
21+
set -o nounset
22+
set -o pipefail
23+
24+
address=${1:-}
25+
[ -z "${address}" ] && echo "No address supplied" && exit 1
26+
27+
status=$(curl -s -o /dev/null -w '%{http_code}' ${address})
28+
if [[ "${status}" == '200' ]]; then
29+
exit 0
30+
fi
31+
if [[ "${status}" == '000' ]]; then
32+
exit 7
33+
fi
34+
35+
exit 1
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2015 The Kubernetes Authors All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Resolve an IP from a hostname (using getent)
18+
# Usage: resolveip <hostname>
19+
# Requires: getent
20+
# TODO: Mac support
21+
22+
set -o errexit
23+
set -o nounset
24+
set -o pipefail
25+
26+
hostname=$1
27+
[ -z "${hostname}" ] && echo "No hostname supplied" && exit 1
28+
29+
getent hosts "${hostname}" | cut -d' ' -f1 | sort -u | tail -1
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
# Copyright 2015 The Kubernetes Authors All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
## Contains configuration values for interacting with the mesos/docker cluster
18+
19+
NUM_MINIONS=${NUM_MINIONS:-2}
20+
INSTANCE_PREFIX="${INSTANCE_PREFIX:-kubernetes}"
21+
MASTER_NAME="${INSTANCE_PREFIX}-master"
22+
MINION_NAMES=($(eval echo ${INSTANCE_PREFIX}-minion-{1..${NUM_MINIONS}}))
23+
24+
SERVICE_CLUSTER_IP_RANGE=10.10.10.0/24
25+
26+
# Extra options to set on the Docker command line. This is useful for setting
27+
# --insecure-registry for local registries.
28+
DOCKER_OPTS=""
29+
30+
# Optional: Deploy cluster DNS.
31+
#ENABLE_CLUSTER_DNS=false
32+
ENABLE_CLUSTER_DNS=true
33+
DNS_SERVER_IP="10.10.10.10"
34+
DNS_DOMAIN="cluster.local"
35+
DNS_REPLICAS=1
36+
37+
# Optional: Deploy cluster web interface.
38+
ENABLE_CLUSTER_UI=true
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
# Copyright 2015 The Kubernetes Authors All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
## Contains configuration values for interacting with the docker-compose cluster in test mode
18+
#Set NUM_MINIONS to minimum required for testing.
19+
NUM_MINIONS=2
20+
21+
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../../..
22+
source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/config-default.sh"
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
3+
# Copyright 2015 The Kubernetes Authors All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Deploy the addon services after the cluster is available
18+
# TODO: integrate with or use /cluster/saltbase/salt/kube-addons/kube-addons.sh
19+
# Requires:
20+
# ENABLE_CLUSTER_DNS (Optional) - 'Y' to deploy kube-dns
21+
# KUBE_SERVER (Optional) - url to the api server for configuring kube-dns
22+
23+
set -o errexit
24+
set -o nounset
25+
set -o pipefail
26+
27+
KUBE_ROOT=$(cd "$(dirname "${BASH_SOURCE}")/../../.." && pwd)
28+
source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/${KUBE_CONFIG_FILE-"config-default.sh"}"
29+
source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/util-temp-dir.sh"
30+
kubectl="${KUBE_ROOT}/cluster/kubectl.sh"
31+
32+
33+
function deploy_dns {
34+
echo "Deploying DNS Addon" 1>&2
35+
local workspace=$(pwd)
36+
37+
# Process salt pillar templates manually
38+
sed -e "s/{{ pillar\['dns_replicas'\] }}/${DNS_REPLICAS}/g;s/{{ pillar\['dns_domain'\] }}/${DNS_DOMAIN}/g" "${KUBE_ROOT}/cluster/addons/dns/skydns-rc.yaml.in" > "${workspace}/skydns-rc.yaml"
39+
sed -e "s/{{ pillar\['dns_server'\] }}/${DNS_SERVER_IP}/g" "${KUBE_ROOT}/cluster/addons/dns/skydns-svc.yaml.in" > "${workspace}/skydns-svc.yaml"
40+
41+
# Use kubectl to create skydns rc and service
42+
"${kubectl}" create -f "${workspace}/skydns-rc.yaml"
43+
"${kubectl}" create -f "${workspace}/skydns-svc.yaml"
44+
}
45+
46+
function deploy_ui {
47+
echo "Deploying UI Addon" 1>&2
48+
49+
# Use kubectl to create ui rc and service
50+
"${kubectl}" create -f "${KUBE_ROOT}/cluster/addons/kube-ui/kube-ui-rc.yaml"
51+
"${kubectl}" create -f "${KUBE_ROOT}/cluster/addons/kube-ui/kube-ui-svc.yaml"
52+
}
53+
54+
# create the kube-system namespace
55+
"${kubectl}" create -f "${KUBE_ROOT}/cluster/mesos/docker/kube-system-ns.yaml"
56+
57+
if [ "${ENABLE_CLUSTER_DNS}" == true ]; then
58+
cluster::mesos::docker::run_in_temp_dir 'k8sm-dns' 'deploy_dns'
59+
fi
60+
61+
if [ "${ENABLE_CLUSTER_UI}" == true ]; then
62+
deploy_ui
63+
fi

0 commit comments

Comments
 (0)