mirror of https://github.com/k3s-io/k3s
Ubuntu cluster: run flannel on master
parent
f4e7b5480d
commit
09a274a7a5
|
@ -36,6 +36,7 @@ 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/master
|
||||
cp flannel-${FLANNEL_VERSION}/flanneld binaries/minion
|
||||
|
||||
# ectd
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
description "Flannel service"
|
||||
author "@chenxingyu"
|
||||
|
||||
# respawn
|
||||
|
||||
# start in conjunction with etcd
|
||||
start on started etcd
|
||||
stop on stopping etcd
|
||||
|
||||
pre-start script
|
||||
FLANNEL=/opt/bin/$UPSTART_JOB
|
||||
if [ -f /etc/default/$UPSTART_JOB ]; then
|
||||
. /etc/default/$UPSTART_JOB
|
||||
fi
|
||||
if [ -f $FLANNEL ]; then
|
||||
exit 0
|
||||
fi
|
||||
exit 22
|
||||
end script
|
||||
|
||||
script
|
||||
# modify these in /etc/default/$UPSTART_JOB (/etc/default/docker)
|
||||
FLANNEL=/opt/bin/$UPSTART_JOB
|
||||
FLANNEL_OPTS=""
|
||||
if [ -f /etc/default/$UPSTART_JOB ]; then
|
||||
. /etc/default/$UPSTART_JOB
|
||||
fi
|
||||
exec "$FLANNEL" $FLANNEL_OPTS
|
||||
end script
|
|
@ -0,0 +1,99 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: flannel
|
||||
# Required-Start: $etcd
|
||||
# Required-Stop:
|
||||
# Should-Start:
|
||||
# Should-Stop:
|
||||
# Default-Start:
|
||||
# Default-Stop:
|
||||
# Short-Description: Start flannel networking service
|
||||
# Description:
|
||||
# https://github.com/coreos/flannel
|
||||
### END INIT INFO
|
||||
|
||||
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/opt/bin:
|
||||
|
||||
BASE=$(basename $0)
|
||||
|
||||
# modify these in /etc/default/$BASE (/etc/default/flannel)
|
||||
FLANNEL=/opt/bin/$BASE
|
||||
# This is the pid file managed by kube-apiserver itself
|
||||
FLANNEL_PIDFILE=/var/run/$BASE.pid
|
||||
FLANNEL_LOGFILE=/var/log/$BASE.log
|
||||
FLANNEL_OPTS=""
|
||||
FLANNEL_DESC="Flannel"
|
||||
|
||||
# Get lsb functions
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
if [ -f /etc/default/$BASE ]; then
|
||||
. /etc/default/$BASE
|
||||
fi
|
||||
|
||||
# see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it)
|
||||
if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; then
|
||||
log_failure_msg "$FLANNEL_DESC is managed via upstart, try using service $BASE $1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check flanneld is present
|
||||
if [ ! -x $FLANNEL ]; then
|
||||
log_failure_msg "$FLANNEL not present or not executable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fail_unless_root() {
|
||||
if [ "$(id -u)" != '0' ]; then
|
||||
log_failure_msg "$FLANNEL_DESC must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
FLANNEL_START="start-stop-daemon \
|
||||
--start \
|
||||
--background \
|
||||
--quiet \
|
||||
--exec $FLANNEL \
|
||||
--make-pidfile --pidfile $FLANNEL_PIDFILE \
|
||||
-- $FLANNEL_OPTS \
|
||||
>> $FLANNEL_LOGFILE 2>&1"
|
||||
|
||||
FLANNEL_STOP="start-stop-daemon \
|
||||
--stop \
|
||||
--pidfile $FLANNEL_PIDFILE"
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
fail_unless_root
|
||||
log_begin_msg "Starting $FLANNEL_DESC: $BASE"
|
||||
$KUBE_APISERVER_START
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
stop)
|
||||
fail_unless_root
|
||||
log_begin_msg "Stopping $FLANNEL_DESC: $BASE"
|
||||
$KUBE_APISERVER_STOP
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
restart | force-reload)
|
||||
fail_unless_root
|
||||
log_begin_msg "Stopping $FLANNEL_DESC: $BASE"
|
||||
$KUBE_APISERVER_STOP
|
||||
$KUBE_APISERVER_START
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
status)
|
||||
status_of_proc -p "$FLANNEL_DESC" "$FLANNEL" "$FLANNEL_DESC"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
|
@ -364,6 +364,7 @@ function provision-master() {
|
|||
create-kube-apiserver-opts "${SERVICE_CLUSTER_IP_RANGE}"; \
|
||||
create-kube-controller-manager-opts "${MINION_IPS}"; \
|
||||
create-kube-scheduler-opts; \
|
||||
create-flanneld-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;"
|
||||
|
|
Loading…
Reference in New Issue