forked from kubernetes/kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finish the multinode ubuntu k8s setup script and guide ,tested ok
- Loading branch information
1 parent
1d97b72
commit aeeebe2
Showing
29 changed files
with
1,435 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,5 @@ network_closure.sh | |
|
||
# also ignore etcd installed by hack/install-etcd.sh | ||
/third_party/etcd* | ||
|
||
.tags* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2015 Google Inc. 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 @resouer | ||
set -e | ||
|
||
# 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 | ||
|
||
# kuber | ||
echo "Download kubernetes release ..." | ||
if [ ! -f kubernetes.tar.gz ] ; then | ||
curl -L https://github.com/GoogleCloudPlatform/kubernetes/releases/download/v0.10.1/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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2015 Google Inc. 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 | ||
|
||
function cpMaster(){ | ||
# copy /etc/init files | ||
cp init_conf/etcd.conf /etc/init/ | ||
cp init_conf/kube-apiserver.conf /etc/init/ | ||
cp init_conf/kube-controller-manager.conf /etc/init/ | ||
cp init_conf/kube-scheduler.conf /etc/init/ | ||
|
||
# copy /etc/initd/ files | ||
cp initd_scripts/etcd /etc/init.d/ | ||
cp initd_scripts/kube-apiserver /etc/init.d/ | ||
cp initd_scripts/kube-controller-manager /etc/init.d/ | ||
cp initd_scripts/kube-scheduler /etc/init.d/ | ||
|
||
# copy default configs | ||
cp default_scripts/etcd /etc/default/ | ||
cp default_scripts/kube-apiserver /etc/default/ | ||
cp default_scripts/kube-scheduler /etc/default/ | ||
cp default_scripts/kube-controller-manager /etc/default/ | ||
} | ||
|
||
function cpMinion(){ | ||
# copy /etc/init files | ||
cp init_conf/etcd.conf /etc/init/ | ||
cp init_conf/kubelet.conf /etc/init/ | ||
cp init_conf/flanneld.conf /etc/init/ | ||
cp init_conf/kube-proxy.conf /etc/init/ | ||
|
||
# copy /etc/initd/ files | ||
cp initd_scripts/etcd /etc/init.d/ | ||
cp initd_scripts/flanneld /etc/init.d/ | ||
cp initd_scripts/kubelet /etc/init.d/ | ||
cp initd_scripts/kube-proxy /etc/init.d/ | ||
|
||
# copy default configs | ||
cp default_scripts/etcd /etc/default/ | ||
cp default_scripts/flanneld /etc/default/ | ||
cp default_scripts/kube-proxy /etc/default | ||
cp 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\" > 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 | ||
|
||
|
||
# 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 | ||
else | ||
cluster="$cluster,$item" | ||
if [ "$ii" -gt 2 ]; then | ||
minionIPs="$minionIPs,$i" | ||
else | ||
minionIPs="$i" | ||
fi | ||
fi | ||
mm[$i]=$name | ||
let ii++ | ||
done | ||
echo | ||
|
||
# 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 | ||
[2] ) | ||
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" default_scripts/kube-controller-manager | ||
cpMaster | ||
break | ||
;; | ||
[3] ) | ||
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" default_scripts/kubelet | ||
cpMinion | ||
break | ||
;; | ||
[1] ) | ||
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" default_scripts/kubelet | ||
|
||
# For master set MINION IPs in kube-controller-manager | ||
minionIPs="$minionIPs,$myIP" | ||
sed -i "s/MINION_IPS/${minionIPs}/g" default_scripts/kube-controller-manager | ||
|
||
cpMaster | ||
cpMinion | ||
break | ||
;; | ||
* ) | ||
echo "Please choose 1 or 2 or 3." | ||
;; | ||
esac | ||
done | ||
|
||
echo -e "\e[0;32mConfigure Success\033[0m" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# 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="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# 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 |
11 changes: 11 additions & 0 deletions
11
cluster/ubuntu-cluster/default_scripts/kube-controller-manager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# 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="--etcd_servers=http://127.0.0.1:4001 \ | ||
--logtostderr=true" | ||
|
||
# Add more envionrment settings used by kube-apiserver here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# 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 \ | ||
--etcd_servers=http://127.0.0.1:4001 \ | ||
--logtostderr=true" | ||
|
||
# Add more envionrment settings used by kube-scheduler here |
Oops, something went wrong.