mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-09 21:21:14 +00:00
Merge the old single-node and multi-node ubuntu deployment into one better approach and update the guidance
This commit is contained in:
70
cluster/ubuntu/build.sh
Executable file
70
cluster/ubuntu/build.sh
Executable file
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2015 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.
|
||||
|
||||
# Download the etcd, flannel, and K8s binaries automatically and stored in binaries directory
|
||||
# Run as root only
|
||||
|
||||
# author @resouer @WIZARD-CXY
|
||||
set -e
|
||||
|
||||
function cleanup {
|
||||
# cleanup work
|
||||
rm -rf flannel* kubernetes* etcd* binaries
|
||||
}
|
||||
trap cleanup SIGHUP SIGINT SIGTERM
|
||||
|
||||
mkdir -p binaries/master
|
||||
mkdir -p binaries/minion
|
||||
|
||||
# flannel
|
||||
echo "Download flannel release ..."
|
||||
FLANNEL_VERSION="0.4.0"
|
||||
if [ ! -f flannel.tar.gz ] ; then
|
||||
curl -L https://github.com/coreos/flannel/releases/download/v${FLANNEL_VERSION}/flannel-${FLANNEL_VERSION}-linux-amd64.tar.gz -o flannel.tar.gz
|
||||
tar xzf flannel.tar.gz
|
||||
fi
|
||||
cp flannel-${FLANNEL_VERSION}/flanneld binaries/minion
|
||||
|
||||
# ectd
|
||||
echo "Download etcd release ..."
|
||||
ETCD_VERSION="v2.0.0"
|
||||
ETCD="etcd-${ETCD_VERSION}-linux-amd64"
|
||||
if [ ! -f etcd.tar.gz ] ; then
|
||||
curl -L https://github.com/coreos/etcd/releases/download/${ETCD_VERSION}/${ETCD}.tar.gz -o etcd.tar.gz
|
||||
tar xzf etcd.tar.gz
|
||||
fi
|
||||
cp $ETCD/etcd $ETCD/etcdctl binaries/master
|
||||
cp $ETCD/etcd $ETCD/etcdctl binaries/minion
|
||||
|
||||
# k8s
|
||||
echo "Download kubernetes release ..."
|
||||
K8S_VERSION="v0.15.0"
|
||||
if [ ! -f kubernetes.tar.gz ] ; then
|
||||
curl -L https://github.com/GoogleCloudPlatform/kubernetes/releases/download/${K8S_VERSION}/kubernetes.tar.gz -o kubernetes.tar.gz
|
||||
tar xzf kubernetes.tar.gz
|
||||
fi
|
||||
pushd kubernetes/server
|
||||
tar xzf kubernetes-server-linux-amd64.tar.gz
|
||||
popd
|
||||
cp kubernetes/server/kubernetes/server/bin/kube-apiserver \
|
||||
kubernetes/server/kubernetes/server/bin/kube-controller-manager \
|
||||
kubernetes/server/kubernetes/server/bin/kube-scheduler binaries/master
|
||||
|
||||
cp kubernetes/server/kubernetes/server/bin/kubelet \
|
||||
kubernetes/server/kubernetes/server/bin/kube-proxy binaries/minion
|
||||
|
||||
rm -rf flannel* kubernetes* etcd*
|
||||
echo "Done! All your commands locate in ./binaries dir"
|
61
cluster/ubuntu/config-default.sh
Executable file
61
cluster/ubuntu/config-default.sh
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2015 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.
|
||||
|
||||
## Contains configuration values for the Ubuntu cluster
|
||||
|
||||
# Define all your cluster nodes, MASTER node comes first"
|
||||
# And separated with blank space like <user_1@ip_1> <user_2@ip_2> <user_3@ip_3>
|
||||
export nodes="vcap@10.10.103.250 vcap@10.10.103.162 vcap@10.10.103.223"
|
||||
# Define all your nodes role: a(master) or i(minion) or ai(both master and minion), must be the order same
|
||||
export roles=("ai" "i" "i")
|
||||
# Define minion numbers
|
||||
export NUM_MINIONS=${NUM_MINIONS:-3}
|
||||
# define the IP range used for service portal.
|
||||
# according to rfc 1918 ref: https://tools.ietf.org/html/rfc1918 choose a private ip range here.
|
||||
export PORTAL_NET=192.168.3.0/24
|
||||
# define the IP range used for flannel overlay network, should not conflict with above PORTAL_NET range
|
||||
export FLANNEL_NET=172.16.0.0/16
|
||||
|
||||
# Admission Controllers to invoke prior to persisting objects in cluster
|
||||
ADMISSION_CONTROL=NamespaceLifecycle,NamespaceAutoProvision,LimitRanger,ResourceQuota
|
||||
|
||||
# Optional: Install node monitoring.
|
||||
ENABLE_NODE_MONITORING=true
|
||||
|
||||
# Optional: Enable node logging.
|
||||
ENABLE_NODE_LOGGING=false
|
||||
LOGGING_DESTINATION=elasticsearch
|
||||
|
||||
# Optional: When set to true, Elasticsearch and Kibana will be setup as part of the cluster bring up.
|
||||
ENABLE_CLUSTER_LOGGING=false
|
||||
ELASTICSEARCH_LOGGING_REPLICAS=1
|
||||
|
||||
# Optional: When set to true, heapster, Influxdb and Grafana will be setup as part of the cluster bring up.
|
||||
ENABLE_CLUSTER_MONITORING="${KUBE_ENABLE_CLUSTER_MONITORING:-true}"
|
||||
|
||||
# Extra options to set on the Docker command line. This is useful for setting
|
||||
# --insecure-registry for local registries.
|
||||
DOCKER_OPTS=""
|
||||
|
||||
# Optional: Install cluster DNS.
|
||||
ENABLE_CLUSTER_DNS=true
|
||||
# DNS_SERVER_IP must be a IP in PORTAL_NET range
|
||||
DNS_SERVER_IP="192.168.3.10"
|
||||
DNS_DOMAIN="kubernetes.local"
|
||||
DNS_REPLICAS=1
|
||||
|
||||
# Optional: Enable setting flags for kube-apiserver to turn on behavior in active-dev
|
||||
#RUNTIME_CONFIG=""
|
19
cluster/ubuntu/config-test.sh
Normal file
19
cluster/ubuntu/config-test.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2015 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.
|
||||
|
||||
## Contains configuration values for interacting with the Ubuntu cluster in test mode
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||
source "${KUBE_ROOT}/cluster/ubuntu/config-default.sh"
|
@@ -1,9 +0,0 @@
|
||||
# Etcd Upstart and SysVinit configuration file
|
||||
|
||||
# Customize etcd location
|
||||
# ETCD="/opt/bin/etcd"
|
||||
|
||||
# Use ETCD_OPTS to modify the start/restart options
|
||||
ETCD_OPTS="-listen-client-urls=http://127.0.0.1:4001"
|
||||
|
||||
# Add more envionrment settings used by etcd here
|
@@ -1,13 +0,0 @@
|
||||
# Kube-Apiserver Upstart and SysVinit configuration file
|
||||
|
||||
# Customize kube-apiserver binary location
|
||||
# KUBE_APISERVER="/opt/bin/kube-apiserver"
|
||||
|
||||
# Use KUBE_APISERVER_OPTS to modify the start/restart options
|
||||
KUBE_APISERVER_OPTS="--address=127.0.0.1 \
|
||||
--port=8080 \
|
||||
--etcd_servers=http://127.0.0.1:4001 \
|
||||
--logtostderr=true \
|
||||
--portal_net=11.1.1.0/24"
|
||||
|
||||
# Add more envionrment settings used by kube-apiserver here
|
@@ -1,11 +0,0 @@
|
||||
# Kube-Controller-Manager Upstart and SysVinit configuration file
|
||||
|
||||
# Customize kube-controller-manager binary location
|
||||
# KUBE_CONTROLLER_MANAGER="/opt/bin/kube-controller-manager"
|
||||
|
||||
# Use KUBE_CONTROLLER_MANAGER_OPTS to modify the start/restart options
|
||||
KUBE_CONTROLLER_MANAGER_OPTS="--master=127.0.0.1:8080 \
|
||||
--machines=127.0.0.1 \
|
||||
--logtostderr=true"
|
||||
|
||||
# Add more envionrment settings used by kube-controller-manager here
|
@@ -1,10 +0,0 @@
|
||||
# Kube-Proxy Upstart and SysVinit configuration file
|
||||
|
||||
# Customize kube-proxy binary location
|
||||
# KUBE_PROXY="/opt/bin/kube-proxy"
|
||||
|
||||
# Use KUBE_PROXY_OPTS to modify the start/restart options
|
||||
KUBE_PROXY_OPTS="--master=http://127.0.0.1:8080 \
|
||||
--logtostderr=true"
|
||||
|
||||
# Add more environment settings used by kube-proxy here
|
@@ -1,10 +0,0 @@
|
||||
# Kube-Scheduler Upstart and SysVinit configuration file
|
||||
|
||||
# Customize kube-apiserver binary location
|
||||
# KUBE_SCHEDULER="/opt/bin/kube-scheduler"
|
||||
|
||||
# Use KUBE_SCHEDULER_OPTS to modify the start/restart options
|
||||
KUBE_SCHEDULER_OPTS="--logtostderr=true \
|
||||
--master=127.0.0.1:8080"
|
||||
|
||||
# Add more envionrment settings used by kube-scheduler here
|
@@ -1,13 +0,0 @@
|
||||
# Kubelet Upstart and SysVinit configuration file
|
||||
|
||||
# Customize kubelet binary location
|
||||
# KUBELET="/opt/bin/kubelet"
|
||||
|
||||
# Use KUBELET_OPTS to modify the start/restart options
|
||||
KUBELET_OPTS="--address=127.0.0.1 \
|
||||
--port=10250 \
|
||||
--hostname_override=127.0.0.1 \
|
||||
--api_servers=http://127.0.0.1:8080 \
|
||||
--logtostderr=true"
|
||||
|
||||
# Add more envionrment settings used by kube-scheduler here
|
32
cluster/ubuntu/deployAddons.sh
Executable file
32
cluster/ubuntu/deployAddons.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2015 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.
|
||||
|
||||
# deploy the add-on services after the cluster is available
|
||||
|
||||
set -e
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||
source "config-default.sh"
|
||||
|
||||
if [ "${ENABLE_CLUSTER_DNS}" == true ]; then
|
||||
echo "Deploying DNS on kubernetes"
|
||||
sed -e "s/{{ pillar\['dns_replicas'\] }}/${DNS_REPLICAS}/g;s/{{ pillar\['dns_domain'\] }}/${DNS_DOMAIN}/g" ../../cluster/addons/dns/skydns-rc.yaml.in > skydns-rc.yaml
|
||||
sed -e "s/{{ pillar\['dns_server'\] }}/${DNS_SERVER_IP}/g" ../../cluster/addons/dns/skydns-svc.yaml.in > skydns-svc.yaml
|
||||
# use kubectl to create skydns rc and service
|
||||
"${KUBE_ROOT}/cluster/kubectl.sh" create -f skydns-rc.yaml
|
||||
"${KUBE_ROOT}/cluster/kubectl.sh" create -f skydns-svc.yaml
|
||||
|
||||
fi
|
@@ -1,10 +1,6 @@
|
||||
description "Etcd service"
|
||||
author "@jainvipin"
|
||||
|
||||
# start after docker starts, stop before docker stops
|
||||
start on started docker
|
||||
stop on stopping docker
|
||||
|
||||
respawn
|
||||
|
||||
pre-start script
|
@@ -1,12 +1,12 @@
|
||||
description "Kube-Apiserver service"
|
||||
author "@jainvipin"
|
||||
|
||||
# respawn
|
||||
|
||||
# start in conjunction with etcd
|
||||
start on started etcd
|
||||
stop on stopping etcd
|
||||
|
||||
# respawn
|
||||
|
||||
pre-start script
|
||||
# see also https://github.com/jainvipin/kubernetes-start
|
||||
KUBE_APISERVER=/opt/bin/$UPSTART_JOB
|
@@ -1,12 +1,12 @@
|
||||
description "Kube-Controller-Manager service"
|
||||
author "@jainvipin"
|
||||
|
||||
# respawn
|
||||
|
||||
# start in conjunction with etcd
|
||||
start on started etcd
|
||||
stop on stopping etcd
|
||||
|
||||
# respawn
|
||||
|
||||
pre-start script
|
||||
# see also https://github.com/jainvipin/kubernetes-ubuntu-start
|
||||
KUBE_CONTROLLER_MANAGER=/opt/bin/$UPSTART_JOB
|
@@ -1,12 +1,12 @@
|
||||
description "Kube-Scheduler service"
|
||||
author "@jainvipin"
|
||||
|
||||
# respawn
|
||||
|
||||
# start in conjunction with etcd
|
||||
start on started etcd
|
||||
stop on stopping etcd
|
||||
|
||||
# respawn
|
||||
|
||||
pre-start script
|
||||
# see also https://github.com/jainvipin/kubernetes-start
|
||||
KUBE_SCHEDULER=/opt/bin/$UPSTART_JOB
|
@@ -9,7 +9,7 @@ set -e
|
||||
# Should-Stop:
|
||||
# Default-Start:
|
||||
# Default-Stop:
|
||||
# Short-Description: Start distrubted key/value pair service
|
||||
# Short-Description: Start kube-apiserver service
|
||||
# Description:
|
||||
# http://www.github.com/GoogleCloudPlatform/Kubernetes
|
||||
### END INIT INFO
|
@@ -9,7 +9,7 @@ set -e
|
||||
# Should-Stop:
|
||||
# Default-Start:
|
||||
# Default-Stop:
|
||||
# Short-Description: Start distrubted key/value pair service
|
||||
# Short-Description: Start kube-controller-managerservice
|
||||
# Description:
|
||||
# http://www.github.com/GoogleCloudPlatform/Kubernetes
|
||||
### END INIT INFO
|
||||
@@ -59,7 +59,7 @@ KUBE_CONTROLLER_MANAGER_START="start-stop-daemon
|
||||
--make-pidfile \
|
||||
--pidfile $KUBE_CONTROLLER_MANAGER_PIDFILE \
|
||||
-- $KUBE_CONTROLLER_MANAGER_OPTS \
|
||||
>> $KUBE_CONTROLLER_MANAGER_LOGFILE" 2>&1
|
||||
>> "$KUBE_CONTROLLER_MANAGER_LOGFILE" 2>&1
|
||||
|
||||
KUBE_CONTROLLER_MANAGER_STOP="start-stop-daemon \
|
||||
--stop \
|
@@ -9,7 +9,7 @@ set -e
|
||||
# Should-Stop:
|
||||
# Default-Start:
|
||||
# Default-Stop:
|
||||
# Short-Description: Start distrubted key/value pair service
|
||||
# Short-Description: Start kube-scheduler service
|
||||
# Description:
|
||||
# http://www.github.com/GoogleCloudPlatform/Kubernetes
|
||||
### END INIT INFO
|
27
cluster/ubuntu/minion/init_conf/etcd.conf
Normal file
27
cluster/ubuntu/minion/init_conf/etcd.conf
Normal file
@@ -0,0 +1,27 @@
|
||||
description "Etcd service"
|
||||
author "@jainvipin"
|
||||
|
||||
respawn
|
||||
|
||||
pre-start script
|
||||
# see also https://github.com/jainvipin/kubernetes-ubuntu-start
|
||||
ETCD=/opt/bin/$UPSTART_JOB
|
||||
if [ -f /etc/default/$UPSTART_JOB ]; then
|
||||
. /etc/default/$UPSTART_JOB
|
||||
fi
|
||||
if [ -f $ETCD ]; then
|
||||
exit 0
|
||||
fi
|
||||
echo "$ETCD binary not found, exiting"
|
||||
exit 22
|
||||
end script
|
||||
|
||||
script
|
||||
# modify these in /etc/default/$UPSTART_JOB (/etc/default/docker)
|
||||
ETCD=/opt/bin/$UPSTART_JOB
|
||||
ETCD_OPTS=""
|
||||
if [ -f /etc/default/$UPSTART_JOB ]; then
|
||||
. /etc/default/$UPSTART_JOB
|
||||
fi
|
||||
exec "$ETCD" $ETCD_OPTS
|
||||
end script
|
29
cluster/ubuntu/minion/init_conf/flanneld.conf
Normal file
29
cluster/ubuntu/minion/init_conf/flanneld.conf
Normal file
@@ -0,0 +1,29 @@
|
||||
description "Flannel service"
|
||||
author "@chenxingyu"
|
||||
|
||||
# respawn
|
||||
|
||||
# start in conjunction with etcd
|
||||
start on started etcd
|
||||
stop on stopping etcd
|
||||
|
||||
pre-start script
|
||||
FLANNEL=/opt/bin/$UPSTART_JOB
|
||||
if [ -f /etc/default/$UPSTART_JOB ]; then
|
||||
. /etc/default/$UPSTART_JOB
|
||||
fi
|
||||
if [ -f $FLANNEL ]; then
|
||||
exit 0
|
||||
fi
|
||||
exit 22
|
||||
end script
|
||||
|
||||
script
|
||||
# modify these in /etc/default/$UPSTART_JOB (/etc/default/docker)
|
||||
FLANNEL=/opt/bin/$UPSTART_JOB
|
||||
FLANNEL_OPTS=""
|
||||
if [ -f /etc/default/$UPSTART_JOB ]; then
|
||||
. /etc/default/$UPSTART_JOB
|
||||
fi
|
||||
exec "$FLANNEL" $FLANNEL_OPTS
|
||||
end script
|
@@ -1,12 +1,12 @@
|
||||
description "Kube-Proxy service"
|
||||
author "@jainvipin"
|
||||
|
||||
# respawn
|
||||
|
||||
# start in conjunction with etcd
|
||||
start on started etcd
|
||||
stop on stopping etcd
|
||||
|
||||
# respawn
|
||||
|
||||
pre-start script
|
||||
# see also https://github.com/jainvipin/kubernetes-start
|
||||
KUBE_PROXY=/opt/bin/$UPSTART_JOB
|
@@ -1,12 +1,12 @@
|
||||
description "Kubelet service"
|
||||
author "@jainvipin"
|
||||
|
||||
# respawn
|
||||
|
||||
# start in conjunction with etcd
|
||||
start on started etcd
|
||||
stop on stopping etcd
|
||||
|
||||
# respawn
|
||||
|
||||
pre-start script
|
||||
# see also https://github.com/jainvipin/kubernetes-ubuntu-start
|
||||
KUBELET=/opt/bin/$UPSTART_JOB
|
100
cluster/ubuntu/minion/init_scripts/etcd
Executable file
100
cluster/ubuntu/minion/init_scripts/etcd
Executable file
@@ -0,0 +1,100 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: etcd
|
||||
# Required-Start: $docker
|
||||
# Required-Stop:
|
||||
# Should-Start:
|
||||
# Should-Stop:
|
||||
# Default-Start:
|
||||
# Default-Stop:
|
||||
# Short-Description: Start distrubted key/value pair service
|
||||
# Description:
|
||||
# http://www.github.com/coreos/etcd
|
||||
### END INIT INFO
|
||||
|
||||
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/opt/bin:
|
||||
|
||||
BASE=$(basename $0)
|
||||
|
||||
# modify these in /etc/default/$BASE (/etc/default/etcd)
|
||||
ETCD=/opt/bin/$BASE
|
||||
# This is the pid file managed by etcd itself
|
||||
ETCD_PIDFILE=/var/run/$BASE.pid
|
||||
ETCD_LOGFILE=/var/log/$BASE.log
|
||||
ETCD_OPTS=""
|
||||
ETCD_DESC="Etcd"
|
||||
|
||||
# Get lsb functions
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
if [ -f /etc/default/$BASE ]; then
|
||||
. /etc/default/$BASE
|
||||
fi
|
||||
|
||||
# see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it)
|
||||
if false && [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; then
|
||||
log_failure_msg "$ETCD_DESC is managed via upstart, try using service $BASE $1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check etcd is present
|
||||
if [ ! -x $ETCD ]; then
|
||||
log_failure_msg "$ETCD not present or not executable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fail_unless_root() {
|
||||
if [ "$(id -u)" != '0' ]; then
|
||||
log_failure_msg "$ETCD_DESC must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
ETCD_START="start-stop-daemon \
|
||||
--start \
|
||||
--background \
|
||||
--quiet \
|
||||
--exec $ETCD \
|
||||
--make-pidfile \
|
||||
--pidfile $ETCD_PIDFILE \
|
||||
-- $ETCD_OPTS \
|
||||
>> $ETCD_LOGFILE 2>&1"
|
||||
|
||||
ETCD_STOP="start-stop-daemon \
|
||||
--stop \
|
||||
--pidfile $ETCD_PIDFILE"
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
fail_unless_root
|
||||
log_begin_msg "Starting $ETCD_DESC: $BASE"
|
||||
$ETCD_START
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
stop)
|
||||
fail_unless_root
|
||||
log_begin_msg "Stopping $ETCD_DESC: $BASE"
|
||||
$ETCD_STOP
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
restart | force-reload)
|
||||
fail_unless_root
|
||||
log_begin_msg "Restarting $ETCD_DESC: $BASE"
|
||||
$ETCD_STOP
|
||||
$ETCD_START
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
status)
|
||||
status_of_proc -p "$ETCD_PIDFILE" "$ETCD" "$ETCD_DESC"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
99
cluster/ubuntu/minion/init_scripts/flanneld
Executable file
99
cluster/ubuntu/minion/init_scripts/flanneld
Executable file
@@ -0,0 +1,99 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: flannel
|
||||
# Required-Start: $etcd
|
||||
# Required-Stop:
|
||||
# Should-Start:
|
||||
# Should-Stop:
|
||||
# Default-Start:
|
||||
# Default-Stop:
|
||||
# Short-Description: Start flannel networking service
|
||||
# Description:
|
||||
# https://github.com/coreos/flannel
|
||||
### END INIT INFO
|
||||
|
||||
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/opt/bin:
|
||||
|
||||
BASE=$(basename $0)
|
||||
|
||||
# modify these in /etc/default/$BASE (/etc/default/flannel)
|
||||
FLANNEL=/opt/bin/$BASE
|
||||
# This is the pid file managed by kube-apiserver itself
|
||||
FLANNEL_PIDFILE=/var/run/$BASE.pid
|
||||
FLANNEL_LOGFILE=/var/log/$BASE.log
|
||||
FLANNEL_OPTS=""
|
||||
FLANNEL_DESC="Flannel"
|
||||
|
||||
# Get lsb functions
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
if [ -f /etc/default/$BASE ]; then
|
||||
. /etc/default/$BASE
|
||||
fi
|
||||
|
||||
# see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it)
|
||||
if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; then
|
||||
log_failure_msg "$FLANNEL_DESC is managed via upstart, try using service $BASE $1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check flanneld is present
|
||||
if [ ! -x $FLANNEL ]; then
|
||||
log_failure_msg "$FLANNEL not present or not executable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fail_unless_root() {
|
||||
if [ "$(id -u)" != '0' ]; then
|
||||
log_failure_msg "$FLANNEL_DESC must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
FLANNEL_START="start-stop-daemon \
|
||||
--start \
|
||||
--background \
|
||||
--quiet \
|
||||
--exec $FLANNEL \
|
||||
--make-pidfile --pidfile $FLANNEL_PIDFILE \
|
||||
-- $FLANNEL_OPTS \
|
||||
>> $FLANNEL_LOGFILE 2>&1"
|
||||
|
||||
FLANNEL_STOP="start-stop-daemon \
|
||||
--stop \
|
||||
--pidfile $FLANNEL_PIDFILE"
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
fail_unless_root
|
||||
log_begin_msg "Starting $FLANNEL_DESC: $BASE"
|
||||
$KUBE_APISERVER_START
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
stop)
|
||||
fail_unless_root
|
||||
log_begin_msg "Stopping $FLANNEL_DESC: $BASE"
|
||||
$KUBE_APISERVER_STOP
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
restart | force-reload)
|
||||
fail_unless_root
|
||||
log_begin_msg "Stopping $FLANNEL_DESC: $BASE"
|
||||
$KUBE_APISERVER_STOP
|
||||
$KUBE_APISERVER_START
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
status)
|
||||
status_of_proc -p "$FLANNEL_DESC" "$FLANNEL" "$FLANNEL_DESC"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
@@ -9,7 +9,7 @@ set -e
|
||||
# Should-Stop:
|
||||
# Default-Start:
|
||||
# Default-Stop:
|
||||
# Short-Description: Start distrubted key/value pair service
|
||||
# Short-Description: Start kube-proxy service
|
||||
# Description:
|
||||
# http://www.github.com/GoogleCloudPlatform/Kubernetes
|
||||
### END INIT INFO
|
@@ -9,7 +9,7 @@ set -e
|
||||
# Should-Stop:
|
||||
# Default-Start:
|
||||
# Default-Stop:
|
||||
# Short-Description: Start distrubted key/value pair service
|
||||
# Short-Description: Start kubelet service
|
||||
# Description:
|
||||
# http://www.github.com/GoogleCloudPlatform/Kubernetes
|
||||
### END INIT INFO
|
53
cluster/ubuntu/reconfDocker.sh
Executable file
53
cluster/ubuntu/reconfDocker.sh
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2015 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.
|
||||
|
||||
# reconfigure docker network setting
|
||||
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo >&2 "Please run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source ~/kube/config-default.sh
|
||||
|
||||
attempt=0
|
||||
while true; do
|
||||
/opt/bin/etcdctl get /coreos.com/network/config
|
||||
if [[ "$?" == 0 ]]; then
|
||||
break
|
||||
else
|
||||
# enough timeout??
|
||||
if (( attempt > 600 )); then
|
||||
echo "timeout for waiting network config" > ~/kube/err.log
|
||||
exit 2
|
||||
fi
|
||||
|
||||
/opt/bin/etcdctl mk /coreos.com/network/config "{\"Network\":\"${FLANNEL_NET}\"}"
|
||||
attempt=$((attempt+1))
|
||||
sleep 3
|
||||
fi
|
||||
done
|
||||
|
||||
#wait some secs for /run/flannel/subnet.env ready
|
||||
sleep 15
|
||||
sudo ip link set dev docker0 down
|
||||
sudo brctl delbr docker0
|
||||
|
||||
source /run/flannel/subnet.env
|
||||
|
||||
echo DOCKER_OPTS=\"-H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock \
|
||||
--bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU}\" > /etc/default/docker
|
||||
sudo service docker restart
|
66
cluster/ubuntu/skydns-rc.yaml
Normal file
66
cluster/ubuntu/skydns-rc.yaml
Normal file
@@ -0,0 +1,66 @@
|
||||
apiVersion: v1beta3
|
||||
kind: ReplicationController
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: kube-dns
|
||||
kubernetes.io/cluster-service: "true"
|
||||
name: kube-dns
|
||||
namespace: default
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
k8s-app: kube-dns
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: kube-dns
|
||||
kubernetes.io/cluster-service: "true"
|
||||
name: kube-dns
|
||||
spec:
|
||||
containers:
|
||||
- name: etcd
|
||||
image: gcr.io/google_containers/etcd:2.0.9
|
||||
command:
|
||||
- /usr/local/bin/etcd
|
||||
- --addr
|
||||
- 127.0.0.1:4001
|
||||
- --bind-addr
|
||||
- 127.0.0.1:4001
|
||||
- -initial-cluster-token=skydns-etcd
|
||||
- name: kube2sky
|
||||
image: gcr.io/google_containers/kube2sky:1.4
|
||||
args:
|
||||
# entrypoint = "/kube2sky"
|
||||
- -domain=kubernetes.local
|
||||
- -kubecfg_file=/etc/dns_token/kubeconfig
|
||||
volumeMounts:
|
||||
- mountPath: /etc/dns_token
|
||||
name: dns-token
|
||||
readOnly: true
|
||||
- name: skydns
|
||||
image: gcr.io/google_containers/skydns:2015-03-11-001
|
||||
args:
|
||||
# entrypoint = "/skydns"
|
||||
- -machines=http://localhost:4001
|
||||
- -addr=0.0.0.0:53
|
||||
- -domain=kubernetes.local.
|
||||
ports:
|
||||
- containerPort: 53
|
||||
name: dns
|
||||
protocol: UDP
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
- "/bin/sh"
|
||||
- "-c"
|
||||
# The health check succeeds by virtue of not hanging. It'd be nice
|
||||
# to also check local services are known, but if that's broken then
|
||||
# etcd or kube2sky has to be restarted, not skydns.
|
||||
- "nslookup foobar 127.0.0.1 &> /dev/null; echo ok"
|
||||
initialDelaySeconds: 30
|
||||
timeoutSeconds: 5
|
||||
dnsPolicy: Default # Don't use cluster DNS.
|
||||
volumes:
|
||||
- name: dns-token
|
||||
secret:
|
||||
secretName: token-system-dns
|
14
cluster/ubuntu/skydns-svc.yaml
Normal file
14
cluster/ubuntu/skydns-svc.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
kind: Service
|
||||
apiVersion: v1beta1
|
||||
id: kube-dns
|
||||
namespace: default
|
||||
protocol: UDP
|
||||
port: 53
|
||||
portalIP: 192.168.3.10
|
||||
containerPort: 53
|
||||
labels:
|
||||
k8s-app: kube-dns
|
||||
name: kube-dns
|
||||
kubernetes.io/cluster-service: "true"
|
||||
selector:
|
||||
k8s-app: kube-dns
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2014 The Kubernetes Authors All rights reserved.
|
||||
# Copyright 2015 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.
|
||||
@@ -14,30 +14,414 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# attempt to warn user about kube and etcd binaries
|
||||
PATH=$PATH:/opt/bin:
|
||||
# A library of helper functions that each provider hosting Kubernetes must implement to use cluster/kube-*.sh scripts.
|
||||
set -e
|
||||
|
||||
if ! $(grep Ubuntu /etc/lsb-release > /dev/null 2>&1)
|
||||
then
|
||||
echo "warning: not detecting a ubuntu system"
|
||||
fi
|
||||
SSH_OPTS="-oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -oLogLevel=ERROR"
|
||||
|
||||
if ! $(which etcd > /dev/null)
|
||||
then
|
||||
echo "warning: etcd binary is not found in the PATH: $PATH"
|
||||
fi
|
||||
# use an array to record name and ip
|
||||
declare -A mm
|
||||
CLUSTER=""
|
||||
MASTER=""
|
||||
MASTER_IP=""
|
||||
MINION_IPS=""
|
||||
|
||||
if ! $(which kube-apiserver > /dev/null) && ! $(which kubelet > /dev/null)
|
||||
then
|
||||
echo "warning: kube binaries are not found in the $PATH"
|
||||
fi
|
||||
# From user input set the necessary k8s and etcd configuration infomation
|
||||
function setClusterInfo() {
|
||||
ii=0
|
||||
for i in $nodes
|
||||
do
|
||||
name="infra"$ii
|
||||
nodeIP=${i#*@}
|
||||
|
||||
# copy /etc/init files
|
||||
cp init_conf/* /etc/init/
|
||||
item="$name=http://$nodeIP:2380"
|
||||
if [ "$ii" == 0 ]; then
|
||||
CLUSTER=$item
|
||||
else
|
||||
CLUSTER="$CLUSTER,$item"
|
||||
fi
|
||||
mm[$nodeIP]=$name
|
||||
|
||||
# copy /etc/initd/ files
|
||||
cp initd_scripts/* /etc/init.d/
|
||||
if [ "${roles[${ii}]}" == "ai" ]; then
|
||||
MASTER_IP=$nodeIP
|
||||
MASTER=$i
|
||||
MINION_IPS="$nodeIP"
|
||||
elif [ "${roles[${ii}]}" == "a" ]; then
|
||||
MASTER_IP=$nodeIP
|
||||
MASTER=$i
|
||||
elif [ "${roles[${ii}]}" == "i" ]; then
|
||||
if [ -z "${MINION_IPS}" ];then
|
||||
MINION_IPS="$nodeIP"
|
||||
else
|
||||
MINION_IPS="$MINION_IPS,$nodeIP"
|
||||
fi
|
||||
else
|
||||
echo "unsupported role for ${i}. please check"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# copy default configs
|
||||
cp default_scripts/* /etc/default/
|
||||
((ii=ii+1))
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Verify ssh prereqs
|
||||
function verify-prereqs {
|
||||
# Expect at least one identity to be available.
|
||||
if ! ssh-add -L 1> /dev/null 2> /dev/null; then
|
||||
echo "Could not find or add an SSH identity."
|
||||
echo "Please start ssh-agent, add your identity, and retry."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check prereqs on every k8s node
|
||||
function check-prereqs {
|
||||
PATH=$PATH:/opt/bin/
|
||||
# use ubuntu
|
||||
if ! $(grep Ubuntu /etc/lsb-release > /dev/null 2>&1)
|
||||
then
|
||||
echo "warning: not detecting a ubuntu system"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check etcd
|
||||
if ! $(which etcd > /dev/null)
|
||||
then
|
||||
echo "warning: etcd binary is not found in the PATH: $PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# detect the etcd version, we support only etcd 2.0.
|
||||
etcdVersion=$(/opt/bin/etcd --version | awk '{print $3}')
|
||||
|
||||
if [ "$etcdVersion" != "2.0.0" ]; then
|
||||
echo "We only support 2.0.0 version of etcd"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function verify-cluster {
|
||||
ii=0
|
||||
|
||||
for i in ${nodes}
|
||||
do
|
||||
if [ "${roles[${ii}]}" == "a" ]; then
|
||||
verify-master
|
||||
elif [ "${roles[${ii}]}" == "i" ]; then
|
||||
verify-minion $i
|
||||
elif [ "${roles[${ii}]}" == "ai" ]; then
|
||||
verify-master
|
||||
verify-minion $i
|
||||
else
|
||||
echo "unsupported role for ${i}. please check"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
((ii=ii+1))
|
||||
done
|
||||
|
||||
echo
|
||||
echo "Kubernetes cluster is running. The master is running at:"
|
||||
echo
|
||||
echo " http://${MASTER_IP}"
|
||||
echo
|
||||
|
||||
}
|
||||
|
||||
function verify-master(){
|
||||
# verify master has all required daemons
|
||||
echo "Validating master"
|
||||
local -a required_daemon=("kube-apiserver" "kube-controller-manager" "kube-scheduler")
|
||||
local validated="1"
|
||||
until [[ "$validated" == "0" ]]; do
|
||||
validated="0"
|
||||
local daemon
|
||||
for daemon in "${required_daemon[@]}"; do
|
||||
ssh "$MASTER" "pgrep -f ${daemon}" >/dev/null 2>&1 || {
|
||||
printf "."
|
||||
validated="1"
|
||||
sleep 2
|
||||
}
|
||||
done
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
function verify-minion(){
|
||||
# verify minion has all required daemons
|
||||
echo "Validating ${1}"
|
||||
local -a required_daemon=("kube-proxy" "kubelet" "docker")
|
||||
local validated="1"
|
||||
until [[ "$validated" == "0" ]]; do
|
||||
validated="0"
|
||||
local daemon
|
||||
for daemon in "${required_daemon[@]}"; do
|
||||
ssh "$1" "pgrep -f $daemon" >/dev/null 2>&1 || {
|
||||
printf "."
|
||||
validated="1"
|
||||
sleep 2
|
||||
}
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
function create-etcd-opts(){
|
||||
cat <<EOF > ~/kube/default/etcd
|
||||
ETCD_OPTS="-name $1 \
|
||||
-initial-advertise-peer-urls http://$2:2380 \
|
||||
-listen-peer-urls http://$2:2380 \
|
||||
-initial-cluster-token etcd-cluster-1 \
|
||||
-initial-cluster $3 \
|
||||
-initial-cluster-state new"
|
||||
EOF
|
||||
}
|
||||
|
||||
function create-kube-apiserver-opts(){
|
||||
cat <<EOF > ~/kube/default/kube-apiserver
|
||||
KUBE_APISERVER_OPTS="--address=0.0.0.0 \
|
||||
--port=8080 \
|
||||
--etcd_servers=http://127.0.0.1:4001 \
|
||||
--logtostderr=true \
|
||||
--portal_net=${1}"
|
||||
EOF
|
||||
}
|
||||
|
||||
function create-kube-controller-manager-opts(){
|
||||
cat <<EOF > ~/kube/default/kube-controller-manager
|
||||
KUBE_CONTROLLER_MANAGER_OPTS="--master=127.0.0.1:8080 \
|
||||
--machines=$1 \
|
||||
--logtostderr=true"
|
||||
EOF
|
||||
|
||||
}
|
||||
|
||||
function create-kube-scheduler-opts(){
|
||||
cat <<EOF > ~/kube/default/kube-scheduler
|
||||
KUBE_SCHEDULER_OPTS="--logtostderr=true \
|
||||
--master=127.0.0.1:8080"
|
||||
EOF
|
||||
|
||||
}
|
||||
|
||||
function create-kubelet-opts(){
|
||||
cat <<EOF > ~/kube/default/kubelet
|
||||
KUBELET_OPTS="--address=0.0.0.0 \
|
||||
--port=10250 \
|
||||
--hostname_override=$1 \
|
||||
--api_servers=http://$2:8080 \
|
||||
--logtostderr=true \
|
||||
--cluster_dns=$3 \
|
||||
--cluster_domain=$4"
|
||||
EOF
|
||||
|
||||
}
|
||||
|
||||
function create-kube-proxy-opts(){
|
||||
cat <<EOF > ~/kube/default/kube-proxy
|
||||
KUBE_PROXY_OPTS="--master=http://${1}:8080 \
|
||||
--logtostderr=true"
|
||||
EOF
|
||||
|
||||
}
|
||||
|
||||
function create-flanneld-opts(){
|
||||
cat <<EOF > ~/kube/default/flanneld
|
||||
FLANNEL_OPTS=""
|
||||
EOF
|
||||
}
|
||||
|
||||
# Ensure that we have a password created for validating to the master. Will
|
||||
# read from $HOME/.kubernetes_auth if available.
|
||||
#
|
||||
# Vars set:
|
||||
# KUBE_USER
|
||||
# KUBE_PASSWORD
|
||||
function get-password {
|
||||
local file="$HOME/.kubernetes_auth"
|
||||
if [[ -r "$file" ]]; then
|
||||
KUBE_USER=$(cat "$file" | python -c 'import json,sys;print json.load(sys.stdin)["User"]')
|
||||
KUBE_PASSWORD=$(cat "$file" | python -c 'import json,sys;print json.load(sys.stdin)["Password"]')
|
||||
return
|
||||
fi
|
||||
KUBE_USER=admin
|
||||
KUBE_PASSWORD=$(python -c 'import string,random; print "".join(random.SystemRandom().choice(string.ascii_letters + string.digits) for _ in range(16))')
|
||||
|
||||
# Store password for reuse.
|
||||
cat << EOF > "$file"
|
||||
{
|
||||
"User": "$KUBE_USER",
|
||||
"Password": "$KUBE_PASSWORD"
|
||||
}
|
||||
EOF
|
||||
chmod 0600 "$file"
|
||||
}
|
||||
|
||||
# Detect the IP for the master
|
||||
#
|
||||
# Assumed vars:
|
||||
# MASTER_NAME
|
||||
# Vars set:
|
||||
# KUBE_MASTER
|
||||
# KUBE_MASTER_IP
|
||||
function detect-master {
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||
source "${KUBE_ROOT}/cluster/ubuntu/${KUBE_CONFIG_FILE-"config-default.sh"}"
|
||||
setClusterInfo
|
||||
KUBE_MASTER=$MASTER
|
||||
KUBE_MASTER_IP=$MASTER_IP
|
||||
echo "Using master $MASTER_IP"
|
||||
}
|
||||
|
||||
# Detect the information about the minions
|
||||
#
|
||||
# Assumed vars:
|
||||
# nodes
|
||||
# Vars set:
|
||||
# KUBE_MINION_IP_ADDRESS (array)
|
||||
function detect-minions {
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||
source "${KUBE_ROOT}/cluster/ubuntu/${KUBE_CONFIG_FILE-"config-default.sh"}"
|
||||
|
||||
KUBE_MINION_IP_ADDRESSES=()
|
||||
setClusterInfo
|
||||
|
||||
ii=0
|
||||
for i in ${nodes}
|
||||
do
|
||||
if [ "${roles[${ii}]}" == "i" ] || [ "${roles[${ii}]}" == "ai" ]; then
|
||||
KUBE_MINION_IP_ADDRESSES+=("${i#*@}")
|
||||
fi
|
||||
|
||||
((ii=ii+1))
|
||||
done
|
||||
|
||||
if [[ -z "${KUBE_MINION_IP_ADDRESSES[@]}" ]]; then
|
||||
echo "Could not detect Kubernetes minion nodes. Make sure you've launched a cluster with 'kube-up.sh'" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Instantiate a kubernetes cluster on ubuntu
|
||||
function kube-up {
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||
source "${KUBE_ROOT}/cluster/ubuntu/${KUBE_CONFIG_FILE-"config-default.sh"}"
|
||||
|
||||
# ensure the binaries are downloaded
|
||||
if [ ! -f "ubuntu/binaries/master/kube-apiserver" ]; then
|
||||
echo "warning: not enough binaries to build k8s, please run build.sh in cluster/ubuntu first"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
setClusterInfo
|
||||
ii=0
|
||||
|
||||
for i in ${nodes}
|
||||
do
|
||||
{
|
||||
if [ "${roles[${ii}]}" == "a" ]; then
|
||||
provision-master
|
||||
elif [ "${roles[${ii}]}" == "i" ]; then
|
||||
provision-minion $i
|
||||
elif [ "${roles[${ii}]}" == "ai" ]; then
|
||||
provision-masterandminion
|
||||
else
|
||||
echo "unsupported role for ${i}. please check"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
((ii=ii+1))
|
||||
|
||||
done
|
||||
wait
|
||||
|
||||
verify-cluster
|
||||
}
|
||||
|
||||
function provision-master() {
|
||||
# copy the binaries and scripts to the ~/kube directory on the master
|
||||
echo "Deploying master on machine ${MASTER_IP}"
|
||||
echo
|
||||
ssh $SSH_OPTS $MASTER "mkdir -p ~/kube/default"
|
||||
scp -r $SSH_OPTS ubuntu/config-default.sh ubuntu/util.sh ubuntu/master/* ubuntu/binaries/master/ "${MASTER}:~/kube"
|
||||
|
||||
# remote login to MASTER and use sudo to configue k8s master
|
||||
ssh $SSH_OPTS -t $MASTER "source ~/kube/util.sh; \
|
||||
setClusterInfo; \
|
||||
create-etcd-opts "${mm[${MASTER_IP}]}" "${MASTER_IP}" "${CLUSTER}"; \
|
||||
create-kube-apiserver-opts "${PORTAL_NET}"; \
|
||||
create-kube-controller-manager-opts "${MINION_IPS}"; \
|
||||
create-kube-scheduler-opts; \
|
||||
sudo -p '[sudo] password to copy files and start master: ' cp ~/kube/default/* /etc/default/ && sudo cp ~/kube/init_conf/* /etc/init/ && sudo cp ~/kube/init_scripts/* /etc/init.d/ \
|
||||
&& sudo mkdir -p /opt/bin/ && sudo cp ~/kube/master/* /opt/bin/; \
|
||||
sudo service etcd start;"
|
||||
}
|
||||
|
||||
function provision-minion() {
|
||||
# copy the binaries and scripts to the ~/kube directory on the minion
|
||||
echo "Deploying minion on machine ${1#*@}"
|
||||
echo
|
||||
ssh $SSH_OPTS $1 "mkdir -p ~/kube/default"
|
||||
scp -r $SSH_OPTS ubuntu/config-default.sh ubuntu/util.sh ubuntu/reconfDocker.sh ubuntu/minion/* ubuntu/binaries/minion "${1}:~/kube"
|
||||
|
||||
# remote login to MASTER and use sudo to configue k8s master
|
||||
ssh $SSH_OPTS -t $1 "source ~/kube/util.sh; \
|
||||
setClusterInfo; \
|
||||
create-etcd-opts "${mm[${1#*@}]}" "${1#*@}" "${CLUSTER}"; \
|
||||
create-kubelet-opts "${1#*@}" "${MASTER_IP}" "${DNS_SERVER_IP}" "${DNS_DOMAIN}";
|
||||
create-kube-proxy-opts "${MASTER_IP}"; \
|
||||
create-flanneld-opts; \
|
||||
sudo -p '[sudo] password to copy files and start minion: ' cp ~/kube/default/* /etc/default/ && sudo cp ~/kube/init_conf/* /etc/init/ && sudo cp ~/kube/init_scripts/* /etc/init.d/ \
|
||||
&& sudo mkdir -p /opt/bin/ && sudo cp ~/kube/minion/* /opt/bin; \
|
||||
sudo service etcd start; \
|
||||
sudo -b ~/kube/reconfDocker.sh"
|
||||
}
|
||||
|
||||
function provision-masterandminion() {
|
||||
# copy the binaries and scripts to the ~/kube directory on the master
|
||||
echo "Deploying master and minion on machine ${MASTER_IP}"
|
||||
echo
|
||||
ssh $SSH_OPTS $MASTER "mkdir -p ~/kube/default"
|
||||
scp -r $SSH_OPTS ubuntu/config-default.sh ubuntu/util.sh ubuntu/master/* ubuntu/reconfDocker.sh ubuntu/minion/* ubuntu/binaries/master/ ubuntu/binaries/minion "${MASTER}:~/kube"
|
||||
|
||||
# remote login to the node and use sudo to configue k8s
|
||||
ssh $SSH_OPTS -t $MASTER "source ~/kube/util.sh; \
|
||||
setClusterInfo; \
|
||||
create-etcd-opts "${mm[${MASTER_IP}]}" "${MASTER_IP}" "${CLUSTER}"; \
|
||||
create-kube-apiserver-opts "${PORTAL_NET}"; \
|
||||
create-kube-controller-manager-opts "${MINION_IPS}"; \
|
||||
create-kube-scheduler-opts; \
|
||||
create-kubelet-opts "${MASTER_IP}" "${MASTER_IP}" "${DNS_SERVER_IP}" "${DNS_DOMAIN}";
|
||||
create-kube-proxy-opts "${MASTER_IP}";\
|
||||
create-flanneld-opts; \
|
||||
sudo -p '[sudo] password to copy files and start node: ' cp ~/kube/default/* /etc/default/ && sudo cp ~/kube/init_conf/* /etc/init/ && sudo cp ~/kube/init_scripts/* /etc/init.d/ \
|
||||
&& sudo mkdir -p /opt/bin/ && sudo cp ~/kube/master/* /opt/bin/ && sudo cp ~/kube/minion/* /opt/bin/; \
|
||||
sudo service etcd start; \
|
||||
sudo -b ~/kube/reconfDocker.sh"
|
||||
}
|
||||
|
||||
# Delete a kubernetes cluster
|
||||
function kube-down {
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||
source "${KUBE_ROOT}/cluster/ubuntu/${KUBE_CONFIG_FILE-"config-default.sh"}"
|
||||
|
||||
for i in ${nodes}; do
|
||||
{
|
||||
echo "Cleaning on node ${i#*@}"
|
||||
ssh -t $i 'pgrep etcd && sudo -p "[sudo] password for cleaning etcd data: " service etcd stop && sudo rm -rf /infra*'
|
||||
}
|
||||
done
|
||||
wait
|
||||
}
|
||||
|
||||
# Update a kubernetes cluster with latest source
|
||||
function kube-push {
|
||||
echo "not implemented"
|
||||
}
|
||||
|
||||
# Perform preparations required to run e2e tests
|
||||
function prepare-e2e() {
|
||||
echo "Ubuntu doesn't need special preparations for e2e tests" 1>&2
|
||||
}
|
Reference in New Issue
Block a user