mirror of https://github.com/k3s-io/k3s
Merge the old single-node and multi-node ubuntu deployment into one better approach and update the guidance
parent
7adaaa4c64
commit
595345c6a6
|
@ -107,6 +107,11 @@ if [[ "$KUBERNETES_PROVIDER" == "gke" ]]; then
|
|||
"--kubeconfig=${HOME}/.config/gcloud/kubernetes/kubeconfig"
|
||||
"--context=gke_${PROJECT}_${ZONE}_${CLUSTER_NAME}"
|
||||
)
|
||||
elif [[ "$KUBERNETES_PROVIDER" == "ubuntu" ]]; then
|
||||
detect-master > /dev/null
|
||||
config=(
|
||||
"--server=http://${KUBE_MASTER_IP}:8080"
|
||||
)
|
||||
fi
|
||||
|
||||
echo "current-context: \"$(${kubectl} "${config[@]:+${config[@]}}" config view -o template --template='{{index . "current-context"}}')\"" >&2
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
#!/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
|
||||
# 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
|
||||
|
||||
# check root
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo >&2 "Please run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p binaries
|
||||
|
||||
# flannel
|
||||
echo "Download & build flanneld ..."
|
||||
apt-get install linux-libc-dev
|
||||
if [ ! -d flannel ] ; then
|
||||
echo "flannel does not exsit, cloning ..."
|
||||
git clone https://github.com/coreos/flannel.git
|
||||
fi
|
||||
|
||||
pushd flannel
|
||||
docker run -v `pwd`:/opt/flannel -i -t google/golang /bin/bash -c "cd /opt/flannel && ./build"
|
||||
popd
|
||||
cp flannel/bin/flanneld binaries/
|
||||
|
||||
# ectd
|
||||
echo "Download etcd release ..."
|
||||
ETCD_V="v2.0.0"
|
||||
ETCD="etcd-${ETCD_V}-linux-amd64"
|
||||
if [ ! -f etcd.tar.gz ] ; then
|
||||
curl -L https://github.com/coreos/etcd/releases/download/$ETCD_V/$ETCD.tar.gz -o etcd.tar.gz
|
||||
tar xzf etcd.tar.gz
|
||||
fi
|
||||
cp $ETCD/etcd $ETCD/etcdctl binaries
|
||||
|
||||
# k8s
|
||||
echo "Download kubernetes release ..."
|
||||
|
||||
K8S_V="v0.12.0"
|
||||
if [ ! -f kubernetes.tar.gz ] ; then
|
||||
curl -L https://github.com/GoogleCloudPlatform/kubernetes/releases/download/$K8S_V/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/* binaries/
|
||||
|
||||
rm -rf flannel kubernetes* etcd*
|
||||
echo "Done! All your commands locate in ./binaries dir"
|
|
@ -1,257 +0,0 @@
|
|||
#!/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.
|
||||
|
||||
# simple use the sed to replace some ip settings on user's demand
|
||||
# Run as root only
|
||||
|
||||
# author @WIZARD-CXY @resouer
|
||||
|
||||
set -e
|
||||
|
||||
|
||||
# get the full path of configure dir and set $PWD to it.
|
||||
CONFIG_DIR=`dirname "$0"`
|
||||
CONFIG_DIR=`cd "$CONFIG_DIR"; pwd`
|
||||
cd $CONFIG_DIR
|
||||
|
||||
#clean all init/init.d/configs
|
||||
function do_backup_clean() {
|
||||
#backup all config files
|
||||
init_files=`ls init_conf`
|
||||
for i in $init_files
|
||||
do
|
||||
if [ -f /etc/init/$i ]
|
||||
then
|
||||
mv /etc/init/${i} /etc/init/${i}.bak
|
||||
fi
|
||||
done
|
||||
initd_files=`ls initd_scripts`
|
||||
for i in $initd_files
|
||||
do
|
||||
if [ -f /etc/init.d/$i ]
|
||||
then
|
||||
mv /etc/init.d/${i} /etc/init.d/${i}.bak
|
||||
fi
|
||||
done
|
||||
default_files=`ls default_scripts`
|
||||
for i in $default_files
|
||||
do
|
||||
if [ -e /etc/default/$i ]
|
||||
then
|
||||
mv /etc/default/${i} /etc/default/${i}.bak
|
||||
fi
|
||||
done
|
||||
# clean work dir
|
||||
if [ ! -d ./work ]
|
||||
then
|
||||
mkdir work
|
||||
fi
|
||||
cp -rf default_scripts init_conf initd_scripts work
|
||||
}
|
||||
|
||||
function cpMaster(){
|
||||
# copy /etc/init files
|
||||
cp work/init_conf/etcd.conf /etc/init/
|
||||
cp work/init_conf/kube-apiserver.conf /etc/init/
|
||||
cp work/init_conf/kube-controller-manager.conf /etc/init/
|
||||
cp work/init_conf/kube-scheduler.conf /etc/init/
|
||||
|
||||
# copy /etc/initd/ files
|
||||
cp work/initd_scripts/etcd /etc/init.d/
|
||||
cp work/initd_scripts/kube-apiserver /etc/init.d/
|
||||
cp work/initd_scripts/kube-controller-manager /etc/init.d/
|
||||
cp work/initd_scripts/kube-scheduler /etc/init.d/
|
||||
|
||||
# copy default configs
|
||||
cp work/default_scripts/etcd /etc/default/
|
||||
cp work/default_scripts/kube-apiserver /etc/default/
|
||||
cp work/default_scripts/kube-scheduler /etc/default/
|
||||
cp work/default_scripts/kube-controller-manager /etc/default/
|
||||
}
|
||||
|
||||
function cpMinion(){
|
||||
# copy /etc/init files
|
||||
cp work/init_conf/etcd.conf /etc/init/etcd.conf
|
||||
cp work/init_conf/kubelet.conf /etc/init/kubelet.conf
|
||||
cp work/init_conf/flanneld.conf /etc/init/flanneld.conf
|
||||
cp work/init_conf/kube-proxy.conf /etc/init/
|
||||
|
||||
# copy /etc/initd/ files
|
||||
cp work/initd_scripts/etcd /etc/init.d/
|
||||
cp work/initd_scripts/flanneld /etc/init.d/
|
||||
cp work/initd_scripts/kubelet /etc/init.d/
|
||||
cp work/initd_scripts/kube-proxy /etc/init.d/
|
||||
|
||||
# copy default configs
|
||||
cp work/default_scripts/etcd /etc/default/
|
||||
cp work/default_scripts/flanneld /etc/default/
|
||||
cp work/default_scripts/kube-proxy /etc/default/
|
||||
cp work/default_scripts/kubelet /etc/default/
|
||||
}
|
||||
|
||||
# check if input IP in machine list
|
||||
function inList(){
|
||||
if [ "$#" -eq 1 ]; then
|
||||
echo -e "\e[0;31mERROR\e[0m: "$1" is not in your machine list."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# set values in ETCD_OPTS
|
||||
function configEtcd(){
|
||||
echo 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\" > work/default_scripts/etcd
|
||||
}
|
||||
|
||||
# check root
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo >&2 "Please run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Welcome to use this script to configure k8s setup"
|
||||
|
||||
echo
|
||||
|
||||
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
|
||||
|
||||
# check kube commands
|
||||
if ! $(which kube-apiserver > /dev/null) && ! $(which kubelet > /dev/null)
|
||||
then
|
||||
echo "warning: kube binaries are not found in the $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
|
||||
|
||||
do_backup_clean
|
||||
|
||||
# use an array to record name and ip
|
||||
declare -A mm
|
||||
ii=1
|
||||
# we use static etcd configuration
|
||||
# see https://github.com/coreos/etcd/blob/master/Documentation/clustering.md#static
|
||||
echo "Please enter all your cluster node ips, MASTER node comes first"
|
||||
read -p "And separated with blank space like \"<ip_1> <ip_2> <ip_3>\": " etcdIPs
|
||||
|
||||
for i in $etcdIPs
|
||||
do
|
||||
name="infra"$ii
|
||||
item="$name=http://$i:2380"
|
||||
if [ "$ii" == 1 ]; then
|
||||
cluster=$item
|
||||
#record the masterIP for later use.
|
||||
masterIP=$i
|
||||
else
|
||||
cluster="$cluster,$item"
|
||||
if [ "$ii" -gt 2 ]; then
|
||||
minionIPs="$minionIPs,$i"
|
||||
else
|
||||
minionIPs="$i"
|
||||
fi
|
||||
fi
|
||||
mm[$i]=$name
|
||||
let ii++
|
||||
done
|
||||
|
||||
# input node IPs
|
||||
while true; do
|
||||
echo "This machine acts as"
|
||||
echo -e " both MASTER and MINION: \033[1m1\033[0m"
|
||||
echo -e " only MASTER: \033[1m2\033[0m"
|
||||
echo -e " only MINION: \033[1m3\033[0m"
|
||||
read -p "Please choose a role > " option
|
||||
echo
|
||||
|
||||
case $option in
|
||||
[1] )
|
||||
# as both master and minion
|
||||
read -p "IP address of this machine > " myIP
|
||||
echo
|
||||
etcdName=${mm[$myIP]}
|
||||
inList $etcdName $myIP
|
||||
configEtcd $etcdName $myIP $cluster
|
||||
# For minion set MINION IP in default_scripts/kubelet
|
||||
sed -i "s/MY_IP/${myIP}/g" work/default_scripts/kubelet
|
||||
sed -i "s/MASTER_IP/${masterIP}/g" work/default_scripts/kubelet
|
||||
sed -i "s/MASTER_IP/${masterIP}/g" work/default_scripts/kube-proxy
|
||||
|
||||
# For master set MINION IPs in kube-controller-manager
|
||||
if [ -z "$minionIPs" ]; then
|
||||
#one node act as both minion and master role
|
||||
minionIPs="$myIP"
|
||||
else
|
||||
minionIPs="$minionIPs,$myIP"
|
||||
fi
|
||||
|
||||
sed -i "s/MINION_IPS/${minionIPs}/g" work/default_scripts/kube-controller-manager
|
||||
|
||||
cpMaster
|
||||
cpMinion
|
||||
break
|
||||
;;
|
||||
[2] )
|
||||
# as master
|
||||
read -p "IP address of this machine > " myIP
|
||||
echo
|
||||
etcdName=${mm[$myIP]}
|
||||
inList $etcdName $myIP
|
||||
configEtcd $etcdName $myIP $cluster
|
||||
# set MINION IPs in kube-controller-manager
|
||||
sed -i "s/MINION_IPS/${minionIPs}/g" work/default_scripts/kube-controller-manager
|
||||
cpMaster
|
||||
break
|
||||
;;
|
||||
[3] )
|
||||
# as minion
|
||||
read -p "IP address of this machine > " myIP
|
||||
echo
|
||||
etcdName=${mm[$myIP]}
|
||||
inList $etcdName $myIP
|
||||
configEtcd $etcdName $myIP $cluster
|
||||
# set MINION IP in default_scripts/kubelet
|
||||
sed -i "s/MY_IP/${myIP}/g" work/default_scripts/kubelet
|
||||
sed -i "s/MASTER_IP/${masterIP}/g" work/default_scripts/kubelet
|
||||
sed -i "s/MASTER_IP/${masterIP}/g" work/default_scripts/kube-proxy
|
||||
cpMinion
|
||||
break
|
||||
;;
|
||||
* )
|
||||
echo "Please choose 1 or 2 or 3."
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo -e "\e[0;32mConfigure Success\033[0m"
|
|
@ -1 +0,0 @@
|
|||
ETCD_OPTS="-name infra1 -initial-advertise-peer-urls http://10.10.103.250:2380 -listen-peer-urls http://10.10.103.250:2380 -initial-cluster-token etcd-cluster-1 -initial-cluster infra1=http://10.10.103.250:2380,infra2=http://10.10.103.223:2380,infra3=http://10.10.103.224:2380 -initial-cluster-state new"
|
|
@ -1,7 +0,0 @@
|
|||
# flannel Upstart and SysVinit configuration file
|
||||
|
||||
# Customize kube-apiserver binary location
|
||||
# FLANNEL="/opt/bin/flanneld"
|
||||
|
||||
# Use FLANNEL_OPTS to modify the start/restart options
|
||||
FLANNEL_OPTS=""
|
|
@ -1,14 +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=0.0.0.0 \
|
||||
--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=MINION_IPS \
|
||||
--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://MASTER_IP:8080 \
|
||||
--logtostderr=true"
|
||||
|
||||
# Add more envionrment settings used by kube-apiserver here
|
|
@ -1,11 +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,14 +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=0.0.0.0 \
|
||||
--port=10250 \
|
||||
--hostname_override=MY_IP \
|
||||
--api_servers=http://MASTER_IP:8080 \
|
||||
--logtostderr=true"
|
||||
|
||||
# Add more envionrment settings used by kube-scheduler here
|
|
@ -1,99 +0,0 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: kube-apiserver
|
||||
# Required-Start: $etcd
|
||||
# Required-Stop:
|
||||
# Should-Start:
|
||||
# Should-Stop:
|
||||
# Default-Start:
|
||||
# Default-Stop:
|
||||
# Short-Description: Start distrubted key/value pair service
|
||||
# Description:
|
||||
# http://www.github.com/GoogleCloudPlatform/Kubernetes
|
||||
### 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/kube-apiserver)
|
||||
KUBE_APISERVER=/opt/bin/$BASE
|
||||
# This is the pid file managed by kube-apiserver itself
|
||||
KUBE_APISERVER_PIDFILE=/var/run/$BASE.pid
|
||||
KUBE_APISERVER_LOGFILE=/var/log/$BASE.log
|
||||
KUBE_APISERVER_OPTS=""
|
||||
KUBE_APISERVER_DESC="Kube-Apiserver"
|
||||
|
||||
# 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 "$KUBE_APISERVER_DESC is managed via upstart, try using service $BASE $1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check kube-apiserver is present
|
||||
if [ ! -x $KUBE_APISERVER ]; then
|
||||
log_failure_msg "$KUBE_APISERVER not present or not executable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fail_unless_root() {
|
||||
if [ "$(id -u)" != '0' ]; then
|
||||
log_failure_msg "$KUBE_APISERVER_DESC must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
KUBE_APISERVER_START="start-stop-daemon \
|
||||
--start \
|
||||
--background \
|
||||
--quiet \
|
||||
--exec $KUBE_APISERVER \
|
||||
--make-pidfile --pidfile $KUBE_APISERVER_PIDFILE \
|
||||
-- $KUBE_APISERVER_OPTS \
|
||||
>> $KUBE_APISERVER_LOGFILE 2>&1"
|
||||
|
||||
KUBE_APISERVER_STOP="start-stop-daemon \
|
||||
--stop \
|
||||
--pidfile $KUBE_APISERVER_PIDFILE"
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
fail_unless_root
|
||||
log_begin_msg "Starting $KUBE_APISERVER_DESC: $BASE"
|
||||
$KUBE_APISERVER_START
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
stop)
|
||||
fail_unless_root
|
||||
log_begin_msg "Stopping $KUBE_APISERVER_DESC: $BASE"
|
||||
$KUBE_APISERVER_STOP
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
restart | force-reload)
|
||||
fail_unless_root
|
||||
log_begin_msg "Stopping $KUBE_APISERVER_DESC: $BASE"
|
||||
$KUBE_APISERVER_STOP
|
||||
$KUBE_APISERVER_START
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
status)
|
||||
status_of_proc -p "$KUBE_APISERVER_PIDFILE" "$KUBE_APISERVER" "$KUBE_APISERVER_DESC"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
|
@ -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"
|
|
@ -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=""
|
20
cluster/ubuntu-cluster/reconfigureDocker.sh → cluster/ubuntu/config-test.sh
Executable file → Normal file
20
cluster/ubuntu-cluster/reconfigureDocker.sh → cluster/ubuntu/config-test.sh
Executable file → Normal file
|
@ -14,20 +14,6 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# script to reconfigue the docker daemon network settings
|
||||
|
||||
# Run as root only
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo >&2 "Please run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ip link set dev docker0 down
|
||||
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
|
||||
|
||||
service docker restart
|
||||
## 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
|
|
@ -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,30 +0,0 @@
|
|||
description "Kube-Apiserver service"
|
||||
author "@jainvipin"
|
||||
|
||||
# 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
|
||||
if [ -f /etc/default/$UPSTART_JOB ]; then
|
||||
. /etc/default/$UPSTART_JOB
|
||||
fi
|
||||
if [ -f $KUBE_APISERVER ]; then
|
||||
exit 0
|
||||
fi
|
||||
exit 22
|
||||
end script
|
||||
|
||||
script
|
||||
# modify these in /etc/default/$UPSTART_JOB (/etc/default/docker)
|
||||
KUBE_APISERVER=/opt/bin/$UPSTART_JOB
|
||||
KUBE_APISERVER_OPTS=""
|
||||
if [ -f /etc/default/$UPSTART_JOB ]; then
|
||||
. /etc/default/$UPSTART_JOB
|
||||
fi
|
||||
exec "$KUBE_APISERVER" $KUBE_APISERVER_OPTS
|
||||
end script
|
|
@ -1,30 +0,0 @@
|
|||
description "Kube-Controller-Manager service"
|
||||
author "@jainvipin"
|
||||
|
||||
# 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
|
||||
if [ -f /etc/default/$UPSTART_JOB ]; then
|
||||
. /etc/default/$UPSTART_JOB
|
||||
fi
|
||||
if [ -f $KUBE_CONTROLLER_MANAGER ]; then
|
||||
exit 0
|
||||
fi
|
||||
exit 22
|
||||
end script
|
||||
|
||||
script
|
||||
# modify these in /etc/default/$UPSTART_JOB (/etc/default/docker)
|
||||
KUBE_CONTROLLER_MANAGER=/opt/bin/$UPSTART_JOB
|
||||
KUBE_CONTROLLER_MANAGER_OPTS=""
|
||||
if [ -f /etc/default/$UPSTART_JOB ]; then
|
||||
. /etc/default/$UPSTART_JOB
|
||||
fi
|
||||
exec "$KUBE_CONTROLLER_MANAGER" $KUBE_CONTROLLER_MANAGER_OPTS
|
||||
end script
|
|
@ -1,30 +0,0 @@
|
|||
description "Kube-Proxy service"
|
||||
author "@jainvipin"
|
||||
|
||||
# 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
|
||||
if [ -f /etc/default/$UPSTART_JOB ]; then
|
||||
. /etc/default/$UPSTART_JOB
|
||||
fi
|
||||
if [ -f $KUBE_PROXY ]; then
|
||||
exit 0
|
||||
fi
|
||||
exit 22
|
||||
end script
|
||||
|
||||
script
|
||||
# modify these in /etc/default/$UPSTART_JOB (/etc/default/docker)
|
||||
KUBE_PROXY=/opt/bin/$UPSTART_JOB
|
||||
KUBE_PROXY_OPTS=""
|
||||
if [ -f /etc/default/$UPSTART_JOB ]; then
|
||||
. /etc/default/$UPSTART_JOB
|
||||
fi
|
||||
exec "$KUBE_PROXY" $KUBE_PROXY_OPTS
|
||||
end script
|
|
@ -1,30 +0,0 @@
|
|||
description "Kube-Scheduler service"
|
||||
author "@jainvipin"
|
||||
|
||||
# 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
|
||||
if [ -f /etc/default/$UPSTART_JOB ]; then
|
||||
. /etc/default/$UPSTART_JOB
|
||||
fi
|
||||
if [ -f $KUBE_SCHEDULER ]; then
|
||||
exit 0
|
||||
fi
|
||||
exit 22
|
||||
end script
|
||||
|
||||
script
|
||||
# modify these in /etc/default/$UPSTART_JOB (/etc/default/docker)
|
||||
KUBE_SCHEDULER=/opt/bin/$UPSTART_JOB
|
||||
KUBE_SCHEDULER_OPTS=""
|
||||
if [ -f /etc/default/$UPSTART_JOB ]; then
|
||||
. /etc/default/$UPSTART_JOB
|
||||
fi
|
||||
exec "$KUBE_SCHEDULER" $KUBE_SCHEDULER_OPTS
|
||||
end script
|
|
@ -1,30 +0,0 @@
|
|||
description "Kubelet service"
|
||||
author "@jainvipin"
|
||||
|
||||
# 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
|
||||
if [ -f /etc/default/$UPSTART_JOB ]; then
|
||||
. /etc/default/$UPSTART_JOB
|
||||
fi
|
||||
if [ -f $KUBELET ]; then
|
||||
exit 0
|
||||
fi
|
||||
exit 22
|
||||
end script
|
||||
|
||||
script
|
||||
# modify these in /etc/default/$UPSTART_JOB (/etc/default/docker)
|
||||
KUBELET=/opt/bin/$UPSTART_JOB
|
||||
KUBELET_OPTS=""
|
||||
if [ -f /etc/default/$UPSTART_JOB ]; then
|
||||
. /etc/default/$UPSTART_JOB
|
||||
fi
|
||||
exec "$KUBELET" $KUBELET_OPTS
|
||||
end script
|
|
@ -1,99 +0,0 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: kube-controller-manager
|
||||
# Required-Start: $etcd
|
||||
# Required-Stop:
|
||||
# Should-Start:
|
||||
# Should-Stop:
|
||||
# Default-Start:
|
||||
# Default-Stop:
|
||||
# Short-Description: Start distrubted key/value pair service
|
||||
# Description:
|
||||
# http://www.github.com/GoogleCloudPlatform/Kubernetes
|
||||
### 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/kube-controller-manager)
|
||||
KUBE_CONTROLLER_MANAGER=/opt/bin/$BASE
|
||||
# This is the pid file managed by kube-controller-manager itself
|
||||
KUBE_CONTROLLER_MANAGER_PIDFILE=/var/run/$BASE.pid
|
||||
KUBE_CONTROLLER_MANAGER_LOGFILE=/var/log/$BASE.log
|
||||
KUBE_CONTROLLER_MANAGER_OPTS=""
|
||||
KUBE_CONTROLLER_MANAGER_DESC="Kube-Controller-Manager"
|
||||
|
||||
# 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 "$KUBE_CONTROLLER_MANAGER_DESC is managed via upstart, try using service $BASE $1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check kube-controller-manager is present
|
||||
if [ ! -x $KUBE_CONTROLLER_MANAGER ]; then
|
||||
log_failure_msg "$KUBE_CONTROLLER_MANAGER not present or not executable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fail_unless_root() {
|
||||
if [ "$(id -u)" != '0' ]; then
|
||||
log_failure_msg "$KUBE_CONTROLLER_MANAGER_DESC must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
KUBE_CONTROLLER_MANAGER_START="start-stop-daemon
|
||||
--start --background \
|
||||
--quiet \
|
||||
--exec $KUBE_CONTROLLER_MANAGER \
|
||||
--make-pidfile \
|
||||
--pidfile $KUBE_CONTROLLER_MANAGER_PIDFILE \
|
||||
-- $KUBE_CONTROLLER_MANAGER_OPTS \
|
||||
>> $KUBE_CONTROLLER_MANAGER_LOGFILE" 2>&1
|
||||
|
||||
KUBE_CONTROLLER_MANAGER_STOP="start-stop-daemon \
|
||||
--stop \
|
||||
--pidfile $KUBE_CONTROLLER_MANAGER_PIDFILE"
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
fail_unless_root
|
||||
log_begin_msg "Starting $KUBE_CONTROLLER_MANAGER_DESC: $BASE"
|
||||
$KUBE_CONTROLLER_MANAGER_START
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
stop)
|
||||
fail_unless_root
|
||||
log_begin_msg "Stopping $KUBE_CONTROLLER_MANAGER_DESC: $BASE"
|
||||
$KUBE_CONTROLLER_MANAGER_STOP
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
restart | force-reload)
|
||||
fail_unless_root
|
||||
log_daemon_message "Restarting $KUBE_CONTROLLER_MANAGER" || true
|
||||
$KUBE_CONTROLLER_MANAGER_STOP
|
||||
$KUBE_CONTROLLER_MANAGER_START
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
status)
|
||||
status_of_proc -p "$KUBE_CONTROLLER_MANAGER_PIDFILE" "$KUBE_CONTROLLER_MANAGER" "$KUBE_CONTROLLER_MANAGER_DESC"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
|
@ -1,99 +0,0 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: kube-proxy
|
||||
# Required-Start: $etcd
|
||||
# Required-Stop:
|
||||
# Should-Start:
|
||||
# Should-Stop:
|
||||
# Default-Start:
|
||||
# Default-Stop:
|
||||
# Short-Description: Start distrubted key/value pair service
|
||||
# Description:
|
||||
# http://www.github.com/GoogleCloudPlatform/Kubernetes
|
||||
### 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/kube-proxy)
|
||||
KUBE_PROXY=/opt/bin/$BASE
|
||||
# This is the pid file managed by kube-proxy itself
|
||||
KUBE_PROXY_PIDFILE=/var/run/$BASE.pid
|
||||
KUBE_PROXY_LOGFILE=/var/log/$BASE.log
|
||||
KUBE_PROXY_OPTS=""
|
||||
KUBE_PROXY_DESC="Kube-Proxy"
|
||||
|
||||
# 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 "$KUBE_PROXY_DESC is managed via upstart, try using service $BASE $1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check kube-proxy is present
|
||||
if [ ! -x $KUBE_PROXY ]; then
|
||||
log_failure_msg "$KUBE_PROXY not present or not executable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fail_unless_root() {
|
||||
if [ "$(id -u)" != '0' ]; then
|
||||
log_failure_msg "$KUBE_PROXY_DESC must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
KUBE_PROXY_START="start-stop-daemon \
|
||||
--start \
|
||||
--background \
|
||||
--quiet \
|
||||
--exec $KUBE_PROXY \
|
||||
--make-pidfile --pidfile $KUBE_PROXY_PIDFILE \
|
||||
-- $KUBE_PROXY_OPTS \
|
||||
>> $KUBE_PROXY_LOGFILE 2>&1"
|
||||
|
||||
KUBE_PROXY_STOP="start-stop-daemon \
|
||||
--stop \
|
||||
--pidfile $KUBE_PROXY_PIDFILE"
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
fail_unless_root
|
||||
log_begin_msg "Starting $KUBE_PROXY_DESC: $BASE"
|
||||
$KUBE_PROXY_START
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
stop)
|
||||
fail_unless_root
|
||||
log_begin_msg "Stopping $KUBE_PROXY_DESC: $BASE"
|
||||
$KUBE_PROXY_STOP
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
restart | force-reload)
|
||||
fail_unless_root
|
||||
log_begin_msg "Stopping $KUBE_PROXY_DESC: $BASE"
|
||||
$KUBE_PROXY_STOP
|
||||
$KUBE_PROXY_START
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
status)
|
||||
status_of_proc -p "$KUBE_PROXY_PIDFILE" "$KUBE_PROXY" "$KUBE_PROXY_DESC"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
|
@ -1,99 +0,0 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: kube-scheduler
|
||||
# Required-Start: $etcd
|
||||
# Required-Stop:
|
||||
# Should-Start:
|
||||
# Should-Stop:
|
||||
# Default-Start:
|
||||
# Default-Stop:
|
||||
# Short-Description: Start distrubted key/value pair service
|
||||
# Description:
|
||||
# http://www.github.com/GoogleCloudPlatform/Kubernetes
|
||||
### 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/kube-scheduler)
|
||||
KUBE_SCHEDULER=/opt/bin/$BASE
|
||||
# This is the pid file managed by kube-scheduler itself
|
||||
KUBE_SCHEDULER_PIDFILE=/var/run/$BASE.pid
|
||||
KUBE_SCHEDULER_LOGFILE=/var/log/$BASE.log
|
||||
KUBE_SCHEDULER_OPTS=""
|
||||
KUBE_SCHEDULER_DESC="Kube-Scheduler"
|
||||
|
||||
# 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 "$KUBE_SCHEDULER_DESC is managed via upstart, try using service $BASE $1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check kube-scheduler is present
|
||||
if [ ! -x $KUBE_SCHEDULER ]; then
|
||||
log_failure_msg "$KUBE_SCHEDULER not present or not executable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fail_unless_root() {
|
||||
if [ "$(id -u)" != '0' ]; then
|
||||
log_failure_msg "$KUBE_SCHEDULER_DESC must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
KUBE_SCHEDULER_START="start-stop-daemon \
|
||||
--start \
|
||||
--background \
|
||||
--quiet \
|
||||
--exec $KUBE_SCHEDULER \
|
||||
--make-pidfile --pidfile $KUBE_SCHEDULER_PIDFILE \
|
||||
-- $KUBE_SCHEDULER_OPTS \
|
||||
>> $KUBE_SCHEDULER_LOGFILE 2>&1"
|
||||
|
||||
KUBE_SCHEDULER_STOP="start-stop-daemon \
|
||||
--stop \
|
||||
--pidfile $KUBE_SCHEDULER_PIDFILE"
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
fail_unless_root
|
||||
log_begin_msg "Starting $KUBE_SCHEDULER_DESC: $BASE"
|
||||
$KUBE_SCHEDULER_START
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
stop)
|
||||
fail_unless_root
|
||||
log_begin_msg "Stopping $KUBE_SCHEDULER_DESC: $BASE"
|
||||
$KUBE_SCHEDULER_STOP
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
restart | force-reload)
|
||||
fail_unless_root
|
||||
log_begin_msg "Restarting $KUBE_SCHEDULER_DESC: $BASE"
|
||||
$KUBE_SCHEDULER_STOP
|
||||
$KUBE_SCHEDULER_START
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
status)
|
||||
status_of_proc -p "$KUBE_SCHEDULER_PIDFILE" "$KUBE_SCHEDULER" "$KUBE_SCHEDULER_DESC"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
|
@ -1,99 +0,0 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: kubelet
|
||||
# Required-Start: $etcd
|
||||
# Required-Stop:
|
||||
# Should-Start:
|
||||
# Should-Stop:
|
||||
# Default-Start:
|
||||
# Default-Stop:
|
||||
# Short-Description: Start distrubted key/value pair service
|
||||
# Description:
|
||||
# http://www.github.com/GoogleCloudPlatform/Kubernetes
|
||||
### 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/kube-apiserver)
|
||||
KUBELET=/opt/bin/$BASE
|
||||
# This is the pid file managed by kube-apiserver itself
|
||||
KUBELET_PIDFILE=/var/run/$BASE.pid
|
||||
KUBELET_LOGFILE=/var/log/$BASE.log
|
||||
KUBELET_OPTS=""
|
||||
KUBELET_DESC="Kube-Apiserver"
|
||||
|
||||
# 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 "$KUBELET_DESC is managed via upstart, try using service $BASE $1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check kube-apiserver is present
|
||||
if [ ! -x $KUBELET ]; then
|
||||
log_failure_msg "$KUBELET not present or not executable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fail_unless_root() {
|
||||
if [ "$(id -u)" != '0' ]; then
|
||||
log_failure_msg "$KUBELET_DESC must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
KUBELET_START="start-stop-daemon \
|
||||
--start \
|
||||
--background \
|
||||
--quiet \
|
||||
--exec $KUBELET \
|
||||
--make-pidfile --pidfile $KUBELET_PIDFILE \
|
||||
-- $KUBELET_OPTS \
|
||||
>> $KUBELET_LOGFILE 2>&1"
|
||||
|
||||
KUBELET_STOP="start-stop-daemon \
|
||||
--stop \
|
||||
--pidfile $KUBELET_PIDFILE"
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
fail_unless_root
|
||||
log_begin_msg "Starting $KUBELET_DESC: $BASE"
|
||||
$KUBELET_START
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
stop)
|
||||
fail_unless_root
|
||||
log_begin_msg "Stopping $KUBELET_DESC: $BASE"
|
||||
$KUBELET_STOP
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
restart | force-reload)
|
||||
fail_unless_root
|
||||
log_begin_msg "Stopping $KUBELET_DESC: $BASE"
|
||||
$KUBELET_STOP
|
||||
$KUBELET_START
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
status)
|
||||
status_of_proc -p "$KUBELET_PIDFILE" "$KUBELET" "$KUBELET_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-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
|
|
@ -9,7 +9,7 @@ set -e
|
|||
# Should-Stop:
|
||||
# Default-Start:
|
||||
# Default-Stop:
|
||||
# Short-Description: Start kube-proxy service
|
||||
# Short-Description: Start kube-scheduler service
|
||||
# Description:
|
||||
# http://www.github.com/GoogleCloudPlatform/Kubernetes
|
||||
### END INIT INFO
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||
}
|
|
@ -19,7 +19,6 @@ Bare-metal | custom | Fedora | _none_ | [docs](../../docs/getting
|
|||
Bare-metal | custom | Fedora | flannel | [docs](../../docs/getting-started-guides/fedora/flannel_multi_node_cluster.md) | Community ([@aveshagarwal](https://github.com/aveshagarwal))| Tested with 0.15.0
|
||||
libvirt | custom | Fedora | flannel | [docs](../../docs/getting-started-guides/fedora/flannel_multi_node_cluster.md) | Community ([@aveshagarwal](https://github.com/aveshagarwal))| Tested with 0.15.0
|
||||
KVM | custom | Fedora | flannel | [docs](../../docs/getting-started-guides/fedora/flannel_multi_node_cluster.md) | Community ([@aveshagarwal](https://github.com/aveshagarwal))| Tested with 0.15.0
|
||||
Bare-metal | custom | Ubuntu Cluster | flannel | [docs](../../docs/getting-started-guides/ubuntu_multinodes_cluster.md) | Community (@resouer @WIZARD-CXY) | use k8s version 0.12.0
|
||||
Mesos/GCE | | | | [docs](../../docs/getting-started-guides/mesos.md) | [Community](https://github.com/mesosphere/kubernetes-mesos) ([@jdef](https://github.com/jdef)) | Uses K8s v0.11.2
|
||||
AWS | CoreOS | CoreOS | flannel | [docs](../../docs/getting-started-guides/coreos.md) | Community | Uses K8s version 0.15.0
|
||||
GCE | CoreOS | CoreOS | flannel | [docs](../../docs/getting-started-guides/coreos.md) | Community (@kelseyhightower) | Uses K8s version 0.15.0
|
||||
|
@ -34,7 +33,9 @@ Joyent | Juju | Ubuntu | flannel | [docs](../../docs/getting
|
|||
AWS | Saltstack | Ubuntu | OVS | [docs](../../docs/getting-started-guides/aws.md) | Community (@justinsb) | Uses K8s version 0.5.0
|
||||
Vmware | CoreOS | CoreOS | flannel | [docs](../../docs/getting-started-guides/coreos.md) | Community (@kelseyhightower) | Uses K8s version 0.15.0
|
||||
Azure | Saltstack | Ubuntu | OpenVPN | [docs](../../docs/getting-started-guides/azure.md) | Community |
|
||||
Bare-metal | custom | Ubuntu | _none_ | [docs](../../docs/getting-started-guides/ubuntu_single_node.md) | Community (@jainvipin) |
|
||||
Bare-metal | custom | Ubuntu | flannel | [docs](../../docs/getting-started-guides/ubuntu.md) | Community (@resouer @WIZARD-CXY) | use k8s version 0.15.0
|
||||
Docker Single Node | custom | N/A | local | [docs](docker.md) | Project (@brendandburns) | Tested @ 0.14.1 |
|
||||
Docker Multi Node | Flannel| N/A | local | [docs](docker-multinode.md) | Project (@brendandburns) | Tested @ 0.14.1 |
|
||||
Local | | | _none_ | [docs](../../docs/getting-started-guides/locally.md) | Community (@preillyme) |
|
||||
libvirt/KVM | CoreOS | CoreOS | libvirt/KVM | [docs](../../docs/getting-started-guides/libvirt-coreos.md) | Community (@lhuard1A) |
|
||||
oVirt | | | | [docs](../../docs/getting-started-guides/ovirt.md) | Community (@simon3z) |
|
||||
|
|
|
@ -0,0 +1,172 @@
|
|||
# Kubernetes deployed on ubuntu nodes
|
||||
|
||||
This document describes how to deploy kubernetes on ubuntu nodes, including 1 master node and 3 minion nodes, and people uses this approach can scale to **any number of minion nodes** by changing some settings with ease. Although there exists saltstack based ubuntu k8s installation , it may be tedious and hard for a guy that knows little about saltstack but want to build a really distributed k8s cluster. This new approach of kubernetes deployment is much more easy and automatical than the previous one.
|
||||
|
||||
[Cloud team from ZJU](https://github.com/ZJU-SEL) will keep updating this work.
|
||||
|
||||
### **Prerequisites:**
|
||||
*1 The minion nodes have installed docker version 1.2+ and bridge-utils to manipulate linux bridge*
|
||||
|
||||
*2 All machines can communicate with each other, no need to connect Internet (should use private docker registry in this case)*
|
||||
|
||||
*3 These guide is tested OK on Ubuntu 14.04 LTS 64bit server, but it should also work on most Ubuntu versions*
|
||||
|
||||
*4 Dependences of this guide: etcd-2.0.0, flannel-0.4.0, k8s-0.15.0, but it may work with higher versions*
|
||||
|
||||
*5 All the remote servers can be ssh logged in without a password by using key authentication*
|
||||
|
||||
|
||||
### **Main Steps**
|
||||
#### I. Make *kubernetes* , *etcd* and *flanneld* binaries
|
||||
|
||||
First clone the kubernetes github repo, `$ git clone git@github.com:GoogleCloudPlatform/kubernetes.git`
|
||||
then `$ cd kubernetes/cluster/ubuntu`.
|
||||
|
||||
Then run `$ ./build.sh`, this will download all the needed binaries into `./binaries`.
|
||||
|
||||
You can customize your etcd version, flannel version, k8s version by changing variable `ETCD_VERSION` , `FLANNEL_VERSION` and `K8S_VERSION` in build.sh, default etcd version is 2.0.0 , flannel version is 0.4.0 and K8s version is 0.15.0.
|
||||
|
||||
Please make sure that there are `kube-apiserver`, `kube-controller-manager`, `kube-scheduler`, `kubelet`, `kube-proxy`, `etcd`, `etcdctl` and `flannel` in the binaries/master or binaries/minion directory.
|
||||
|
||||
> We used flannel here because we want to use overlay network, but please remember it is not the only choice, and it is also not a k8s' necessary dependence. Actually you can just build up k8s cluster natively, or use flannel, Open vSwitch or any other SDN tool you like, we just choose flannel here as a example.
|
||||
|
||||
#### II. Configure and start the kubernetes cluster
|
||||
An example cluster is listed as below:
|
||||
|
||||
| IP Address|Role |
|
||||
|---------|------|
|
||||
|10.10.103.223| minion |
|
||||
|10.10.103.162| minion |
|
||||
|10.10.103.250| both master and minion|
|
||||
|
||||
First configure the cluster information in cluster/ubuntu/config-default.sh, below is a simple sample.
|
||||
|
||||
```
|
||||
export nodes="vcap@10.10.103.250 vcap@10.10.103.162 vcap@10.10.103.223"
|
||||
|
||||
export roles=("ai" "i" "i")
|
||||
|
||||
export NUM_MINIONS=${NUM_MINIONS:-3}
|
||||
|
||||
export PORTAL_NET=11.1.1.0/24
|
||||
|
||||
export FLANNEL_NET=172.16.0.0/16
|
||||
|
||||
|
||||
```
|
||||
|
||||
The first variable `nodes` defines 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> `
|
||||
|
||||
Then the `roles ` variable defines the role of above machine in the same order, "ai" stands for machine acts as both master and minion, "a" stands for master, "i" stands for minion. So they are just defined the k8s cluster as the table above described.
|
||||
|
||||
The `NUM_MINIONS` variable defines the total number of minions.
|
||||
|
||||
The `PORTAL_NET` variable defines the kubernetes service portal ip range. Please make sure that you do have a private ip range defined here.You can use below three private network range accordin to rfc1918. Besides you'd better not choose the one that conflicts with your own private network range.
|
||||
|
||||
10.0.0.0 - 10.255.255.255 (10/8 prefix)
|
||||
|
||||
172.16.0.0 - 172.31.255.255 (172.16/12 prefix)
|
||||
|
||||
192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
|
||||
|
||||
The `FLANNEL_NET` variable defines the IP range used for flannel overlay network, should not conflict with above PORTAL_NET range
|
||||
|
||||
After all the above variable being set correctly. We can use below command in cluster/ directory to bring up the whole cluster.
|
||||
|
||||
`$ KUBERNETES_PROVIDER=ubuntu ./kube-up.sh`
|
||||
|
||||
The scripts is automatically scp binaries and config files to all the machines and start the k8s service on them. The only thing you need to do is to type the sudo password when promoted. The current machine name is shown below like. So you will not type in the wrong password.
|
||||
|
||||
```
|
||||
|
||||
Deploying minion on machine 10.10.103.223
|
||||
|
||||
...
|
||||
|
||||
[sudo] password to copy files and start minion:
|
||||
|
||||
```
|
||||
|
||||
If all things goes right, you will see the below message from console
|
||||
`Cluster validation succeeded` indicating the k8s is up.
|
||||
|
||||
**All done !**
|
||||
|
||||
You can also use kubectl command to see if the newly created k8s is working correctly.
|
||||
|
||||
For example, use `$ kubectl get minions` to see if you get all your minion nodes comming up and ready. It may take some times for the minions be ready to use like below.
|
||||
|
||||
```
|
||||
NAME LABELS STATUS
|
||||
|
||||
10.10.103.162 <none> Ready
|
||||
|
||||
10.10.103.223 <none> Ready
|
||||
|
||||
10.10.103.250 <none> Ready
|
||||
|
||||
```
|
||||
|
||||
Also you can run kubernetes [guest-example](https://github.com/GoogleCloudPlatform/kubernetes/tree/master/examples/guestbook) to build a redis backend cluster on the k8s.
|
||||
|
||||
|
||||
#### IV. Deploy addons
|
||||
|
||||
After the previous parts, you will have a working k8s cluster, this part will teach you how to deploy addones like dns onto the existing cluster.
|
||||
|
||||
The configuration of dns is configured in cluster/ubuntu/config-default.sh.
|
||||
|
||||
```
|
||||
|
||||
ENABLE_CLUSTER_DNS=true
|
||||
|
||||
DNS_SERVER_IP="192.168.3.10"
|
||||
|
||||
DNS_DOMAIN="kubernetes.local"
|
||||
|
||||
DNS_REPLICAS=1
|
||||
|
||||
```
|
||||
The `DNS_SERVER_IP` is defining the ip of dns server which must be in the portal_net range.
|
||||
|
||||
The `DNS_REPLICAS` describes how many dns pod running in the cluster.
|
||||
|
||||
After all the above variable have been set. Just type the below command
|
||||
|
||||
```
|
||||
|
||||
$ cd cluster/ubuntu
|
||||
|
||||
$ KUBERNETES_PROVIDER=ubuntu ./deployAddons.sh
|
||||
|
||||
```
|
||||
|
||||
After some time, you can use `$ kubectl get pods` to see the dns pod is running in the cluster. Done!
|
||||
|
||||
|
||||
#### IV. Trouble Shooting
|
||||
|
||||
Generally, what this approach did is quite simple:
|
||||
|
||||
1. Download and copy binaries and configuration files to proper dirctories on every node
|
||||
|
||||
2. Configure `etcd` using IPs based on input from user
|
||||
|
||||
3. Create and start flannel network
|
||||
|
||||
So, if you see a problem, **check etcd configuration first**
|
||||
|
||||
Please try:
|
||||
|
||||
1. Check `/var/log/upstart/etcd.log` for suspicious etcd log
|
||||
|
||||
2. Check `/etc/default/etcd`, as we do not have much input validation, a right config should be like:
|
||||
```
|
||||
ETCD_OPTS="-name infra1 -initial-advertise-peer-urls <http://ip_of_this_node:2380> -listen-peer-urls <http://ip_of_this_node:2380> -initial-cluster-token etcd-cluster-1 -initial-cluster infra1=<http://ip_of_this_node:2380>,infra2=<http://ip_of_another_node:2380>,infra3=<http://ip_of_another_node:2380> -initial-cluster-state new"
|
||||
```
|
||||
|
||||
3. You can use below command
|
||||
`$ KUBERNETES_PROVIDER=ubuntu ./kube-down.sh` to bring down the cluster and run
|
||||
`$ KUBERNETES_PROVIDER=ubuntu ./kube-up.sh` again to start again.
|
||||
|
||||
4. You can also customize your own settings in `/etc/default/{component_name}` after configured success.
|
|
@ -1,170 +0,0 @@
|
|||
# Kubernetes deployed on multiple ubuntu nodes
|
||||
|
||||
This document describes how to deploy kubernetes on multiple ubuntu nodes, including 1 master node and 3 minion nodes, and people uses this approach can scale to **any number of minion nodes** by changing some settings with ease. Although there exists saltstack based ubuntu k8s installation , it may be tedious and hard for a guy that knows little about saltstack but want to build a really distributed k8s cluster. This approach is inspired by [k8s deploy on a single node](http://docs.k8s.io/getting-started-guides/ubuntu_single_node.md).
|
||||
|
||||
[Cloud team from ZJU](https://github.com/ZJU-SEL) will keep updating this work.
|
||||
|
||||
### **Prerequisites:**
|
||||
*1 The minion nodes have installed docker version 1.2+*
|
||||
|
||||
*2 All machines can communicate with each orther, no need to connect Internet (should use private docker registry in this case)*
|
||||
|
||||
*3 These guide is tested OK on Ubuntu 14.04 LTS 64bit server, but it should also work on most Ubuntu versions*
|
||||
|
||||
*4 Dependences of this guide: etcd-2.0.0, flannel-0.2.0, k8s-0.12.0, but it may work with higher versions*
|
||||
|
||||
|
||||
### **Main Steps**
|
||||
#### I. Make *kubernetes* , *etcd* and *flanneld* binaries
|
||||
|
||||
On your laptop, copy `cluster/ubuntu-cluster` directory to your workspace.
|
||||
|
||||
The `build.sh` will download and build all the needed binaries into `./binaries`.
|
||||
|
||||
You can customize your etcd version or K8s version in the build.sh by changing variable `ETCD_V` and `K8S_V` in build.sh, default etcd version is 2.0.0 and K8s version is 0.12.0.
|
||||
|
||||
|
||||
```
|
||||
$ cd cluster/ubuntu-cluster
|
||||
$ sudo ./build.sh
|
||||
```
|
||||
|
||||
Please copy all the files in `./binaries` into `/opt/bin` of every machine you want to run as Kubernetes cluster node.
|
||||
|
||||
|
||||
Alternatively, if your Kubernetes nodes have access to Internet, you can copy `cluster/ubuntu-cluster` directory to every node and run:
|
||||
```
|
||||
# in every node
|
||||
$ cd cluster/ubuntu-cluster
|
||||
$ sudo ./build.sh
|
||||
$ sudo cp ./binaries/* /opt/bin
|
||||
```
|
||||
|
||||
|
||||
> We used flannel here because we want to use overlay network, but please remember it is not the only choice, and it is also not a k8s' necessary dependence. Actually you can just build up k8s cluster natively, or use flannel, Open vSwitch or any other SDN tool you like, we just choose flannel here as a example.
|
||||
|
||||
#### II. Configue and install every components upstart script
|
||||
An example cluster is listed as below:
|
||||
|
||||
| IP Address|Role |
|
||||
|---------|------|
|
||||
|10.10.103.223| minion|
|
||||
|10.10.103.224| minion|
|
||||
|10.10.103.162| minion|
|
||||
|10.10.103.250| master|
|
||||
|
||||
First of all, make sure `cluster/ubuntu-cluster` exists on this node,and run `configue.sh`.
|
||||
|
||||
On master( infra1 10.10.103.250 ) node:
|
||||
|
||||
```
|
||||
# in cluster/ubuntu-cluster
|
||||
$ sudo ./configure.sh
|
||||
Welcome to use this script to configure k8s setup
|
||||
|
||||
Please enter all your cluster node ips, MASTER node comes first
|
||||
And separated with blank space like "<ip_1> <ip2> <ip3>": 10.10.103.250 10.10.103.223 10.10.103.224 10.10.103.162
|
||||
|
||||
This machine acts as
|
||||
both MASTER and MINION: 1
|
||||
only MASTER: 2
|
||||
only MINION: 3
|
||||
Please choose a role > 2
|
||||
|
||||
IP address of this machine > 10.10.103.250
|
||||
|
||||
Configure Success
|
||||
```
|
||||
|
||||
On every minion ( e.g. 10.10.103.224 ) node:
|
||||
|
||||
|
||||
```
|
||||
# in cluster/ubuntu-cluster
|
||||
$ sudo ./configure.sh
|
||||
Welcome to use this script to configure k8s setup
|
||||
|
||||
Please enter all your cluster node ips, MASTER node comes first
|
||||
And separated with blank space like "<ip_1> <ip2> <ip3>": 10.10.103.250 10.10.103.223 10.10.103.224 10.10.103.162
|
||||
|
||||
This machine acts as
|
||||
both MASTER and MINION: 1
|
||||
only MASTER: 2
|
||||
only MINION: 3
|
||||
Please choose a role > 3
|
||||
|
||||
IP address of this machine > 10.10.103.224
|
||||
|
||||
Configure Success
|
||||
```
|
||||
|
||||
If you want a node acts as **both running the master and minion**, please choose option 1.
|
||||
|
||||
#### III. Start all components
|
||||
1. On the master node:
|
||||
|
||||
`$ sudo service etcd start`
|
||||
|
||||
Then on every minion node:
|
||||
|
||||
`$ sudo service etcd start`
|
||||
|
||||
> The kubernetes commands will be started automatically after etcd
|
||||
|
||||
2. On any node:
|
||||
|
||||
`$ /opt/bin/etcdctl mk /coreos.com/network/config '{"Network":"10.0.0.0/16"}'`
|
||||
|
||||
Note the `10.0.0.0/16` is a virtual network address. It has nothing to do with master and minions IP addresses assigned by the cloud provider. In other words even if your master and minions use address from another network (e.g. 172.16.0x) you can still use `10.0.0.0/16` for your virtual network.
|
||||
|
||||
> You can use the below command on another node to confirm if the network setting is correct.
|
||||
|
||||
> `$ /opt/bin/etcdctl get /coreos.com/network/config`
|
||||
|
||||
> If you got `{"Network":"10.0.0.0/16"}`, then etcd cluster is working well.
|
||||
> If not , please check` /var/log/upstart/etcd.log` to resolve etcd problem before going forward.
|
||||
> Finally, use `ifconfig` to see if there is a new network interface named `flannel0` coming up.
|
||||
|
||||
|
||||
3. On every minion node
|
||||
|
||||
Make sure you have `brctl` installed on every minion, otherwise please run `sudo apt-get install bridge-utils`
|
||||
|
||||
`$ sudo ./reconfigureDocker.sh`
|
||||
|
||||
This will make the docker daemon aware of flannel network.
|
||||
|
||||
|
||||
**All done !**
|
||||
|
||||
#### IV. Validation
|
||||
You can use kubectl command to see if the newly created k8s is working correctly.
|
||||
|
||||
For example , `$ kubectl get minions` to see if you get all your minion nodes comming up.
|
||||
|
||||
Also you can run kubernetes [guest-example](https://github.com/GoogleCloudPlatform/kubernetes/tree/master/examples/guestbook) to build a redis backend cluster on the k8s.
|
||||
|
||||
#### V. Trouble Shooting
|
||||
|
||||
Generally, what of this guide did is quite simple:
|
||||
|
||||
1. Build and copy binaries and configuration files to proper dirctories on every node
|
||||
|
||||
2. Configure `etcd` using IPs based on input from user
|
||||
|
||||
3. Create and start flannel network
|
||||
|
||||
So, whenver you have problem, do not blame Kubernetes, **check etcd configuration first**
|
||||
|
||||
Please try:
|
||||
|
||||
1. Check `/var/log/upstart/etcd.log` for suspicisous etcd log
|
||||
|
||||
2. Check `/etc/default/etcd`, as we do not have much input validation, a right config should be like:
|
||||
```
|
||||
ETCD_OPTS="-name infra1 -initial-advertise-peer-urls <http://ip_of_this_node:2380> -listen-peer-urls <http://ip_of_this_node:2380> -initial-cluster-token etcd-cluster-1 -initial-cluster infra1=<http://ip_of_this_node:2380>,infra2=<http://ip_of_another_node:2380>,infra3=<http://ip_of_another_node:2380> -initial-cluster-state new"
|
||||
```
|
||||
|
||||
3. Remove `data-dir` of etcd and run `reconfigureDocker.sh`again, the default path of `data-dir` is /infra*.etcd/
|
||||
|
||||
4. You can also customize your own settings in `/etc/default/{component_name}` after configured success.
|
|
@ -1,50 +0,0 @@
|
|||
## Getting started on Ubuntu
|
||||
|
||||
This document describes how to get started to run kubernetes services on a single host (which is acting both as master and minion) for ubuntu systems. It consists of three steps
|
||||
|
||||
1. Make kubernetes and etcd binaries
|
||||
2. Install upstart scripts
|
||||
3. Customizing ubuntu launch
|
||||
|
||||
### 1. Make kubernetes and etcd binaries
|
||||
Either build or download the latest [kubernetes binaries] (http://docs.k8s.io/getting-started-guides/binary_release.md)
|
||||
|
||||
Copy the kube binaries into `/opt/bin` or a path of your choice
|
||||
|
||||
Similarly pull an `etcd` binary from [etcd releases](https://github.com/coreos/etcd/releases) or build the `etcd` yourself using instructions at [https://github.com/coreos/etcd](https://github.com/coreos/etcd)
|
||||
|
||||
Copy the `etcd` binary into `/opt/bin` or path of your choice
|
||||
|
||||
### 2. Install upstart scripts
|
||||
Running ubuntu/util.sh would install/copy the scripts for upstart to pick up. The script may warn you on some valid problems/conditions
|
||||
|
||||
```
|
||||
$ cd kubernetes/cluster/ubuntu
|
||||
$ sudo ./util.sh
|
||||
```
|
||||
|
||||
After this the kubernetes and `etcd` services would be up and running. You can use `service start/stop/restart/force-reload` on the services.
|
||||
|
||||
Launching and scheduling containers using kubectl can also be used at this point, as explained mentioned in the [examples](https://github.com/GoogleCloudPlatform/kubernetes/tree/master/examples/guestbook)
|
||||
|
||||
### 3. Customizing the ubuntu launch
|
||||
To customize the defaults you will need to tweak `/etc/default/kube*` files and restart the appropriate services. This is needed if the binaries are copied in a place other than `/opt/bin`. A run could look like
|
||||
|
||||
```
|
||||
$ sudo cat /etc/default/etcd
|
||||
# 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 environment settings used by etcd here
|
||||
|
||||
$ sudo service etcd status
|
||||
etcd start/running, process 834
|
||||
$ sudo service etcd restart
|
||||
etcd stop/waiting
|
||||
etcd start/running, process 29050
|
||||
```
|
Loading…
Reference in New Issue