Update docker-multinode instructions and version. Also run kube-proxy in a pod in the docker-multnode manifest

This commit is contained in:
Lucas Käldström
2016-01-11 16:45:56 +02:00
parent a45c87864e
commit 7d497441b3
7 changed files with 191 additions and 127 deletions

View File

@@ -14,8 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# A scripts to install k8s worker node.
# Author @wizard_cxy @reouser
# A script to the k8s worker in docker containers.
# Authors @wizard_cxy @resouer
set -e
@@ -26,12 +26,9 @@ if ( ! ps -ef | grep "/usr/bin/docker" | grep -v 'grep' &> /dev/null ); then
fi
# Make sure k8s version env is properly set
if [ -z ${K8S_VERSION} ]; then
K8S_VERSION="1.0.7"
echo "K8S_VERSION is not set, using default: ${K8S_VERSION}"
else
echo "k8s version is set to: ${K8S_VERSION}"
fi
K8S_VERSION=${K8S_VERSION:-"1.1.3"}
FLANNEL_VERSION=${FLANNEL_VERSION:-"0.5.5"}
FLANNEL_IFACE=${FLANNEL_IFACE:-"eth0"}
# Run as root
if [ "$(id -u)" != "0" ]; then
@@ -43,10 +40,13 @@ fi
if [ -z ${MASTER_IP} ]; then
echo "Please export MASTER_IP in your env"
exit 1
else
echo "k8s master is set to: ${MASTER_IP}"
fi
echo "K8S_VERSION is set to: ${K8S_VERSION}"
echo "FLANNEL_VERSION is set to: ${FLANNEL_VERSION}"
echo "FLANNEL_IFACE is set to: ${FLANNEL_IFACE}"
echo "MASTER_IP is set to: ${MASTER_IP}"
# Check if a command is valid
command_exists() {
command -v "$@" > /dev/null 2>&1
@@ -96,17 +96,15 @@ detect_lsb() {
# Start the bootstrap daemon
bootstrap_daemon() {
sudo -b \
docker \
-d \
docker -d \
-H unix:///var/run/docker-bootstrap.sock \
-p /var/run/docker-bootstrap.pid \
--iptables=false \
--ip-masq=false \
--bridge=none \
--graph=/var/lib/docker-bootstrap \
2> /var/log/docker-bootstrap.log \
1> /dev/null
2> /var/log/docker-bootstrap.log \
1> /dev/null &
sleep 5
}
@@ -116,24 +114,22 @@ DOCKER_CONF=""
# Start k8s components in containers
start_k8s() {
# Start flannel
flannelCID=$(sudo \
docker \
-H unix:///var/run/docker-bootstrap.sock \
run \
flannelCID=$(docker -H unix:///var/run/docker-bootstrap.sock run \
-d \
--restart=always \
--net=host \
--privileged \
-v /dev/net:/dev/net \
quay.io/coreos/flannel:0.5.5 \
quay.io/coreos/flannel:${FLANNEL_VERSION} \
/opt/bin/flanneld \
--ip-masq \
--etcd-endpoints=http://${MASTER_IP}:4001 -iface="eth0")
--ip-masq \
--etcd-endpoints=http://${MASTER_IP}:4001 \
--iface="${FLANNEL_IFACE}")
sleep 8
# Copy flannel env out and source it on the host
sudo docker -H unix:///var/run/docker-bootstrap.sock \
docker -H unix:///var/run/docker-bootstrap.sock \
cp ${flannelCID}:/run/flannel/subnet.env .
source subnet.env
@@ -141,7 +137,7 @@ start_k8s() {
case "${lsb_dist}" in
centos)
DOCKER_CONF="/etc/sysconfig/docker"
echo "OPTIONS=\"\$OPTIONS --mtu=${FLANNEL_MTU} --bip=${FLANNEL_SUBNET}\"" | sudo tee -a ${DOCKER_CONF}
echo "OPTIONS=\"\$OPTIONS --mtu=${FLANNEL_MTU} --bip=${FLANNEL_SUBNET}\"" | tee -a ${DOCKER_CONF}
if ! command_exists ifconfig; then
yum -y -q install net-tools
fi
@@ -150,13 +146,13 @@ start_k8s() {
;;
amzn)
DOCKER_CONF="/etc/sysconfig/docker"
echo "OPTIONS=\"\$OPTIONS --mtu=${FLANNEL_MTU} --bip=${FLANNEL_SUBNET}\"" | sudo tee -a ${DOCKER_CONF}
echo "OPTIONS=\"\$OPTIONS --mtu=${FLANNEL_MTU} --bip=${FLANNEL_SUBNET}\"" | tee -a ${DOCKER_CONF}
ifconfig docker0 down
yum -y -q install bridge-utils && brctl delbr docker0 && service docker restart
;;
ubuntu|debian)
DOCKER_CONF="/etc/default/docker"
echo "DOCKER_OPTS=\"\$DOCKER_OPTS --mtu=${FLANNEL_MTU} --bip=${FLANNEL_SUBNET}\"" | sudo tee -a ${DOCKER_CONF}
echo "DOCKER_OPTS=\"\$DOCKER_OPTS --mtu=${FLANNEL_MTU} --bip=${FLANNEL_SUBNET}\"" | tee -a ${DOCKER_CONF}
ifconfig docker0 down
apt-get install bridge-utils
brctl delbr docker0
@@ -191,11 +187,15 @@ start_k8s() {
-v /var/lib/docker/:/var/lib/docker:rw \
-v /var/lib/kubelet/:/var/lib/kubelet:rw \
gcr.io/google_containers/hyperkube:v${K8S_VERSION} \
/hyperkube kubelet --api-servers=http://${MASTER_IP}:8080 \
--v=2 --address=0.0.0.0 --enable-server \
--cluster-dns=10.0.0.10 \
--cluster-domain=cluster.local \
--containerized
/hyperkube kubelet \
--allow-privileged=true \
--api-servers=http://${MASTER_IP}:8080 \
--address=0.0.0.0 \
--enable-server \
--cluster-dns=10.0.0.10 \
--cluster-domain=cluster.local \
--containerized \
--v=2
docker run \
-d \
@@ -203,8 +203,9 @@ start_k8s() {
--privileged \
--restart=always \
gcr.io/google_containers/hyperkube:v${K8S_VERSION} \
/hyperkube proxy --master=http://${MASTER_IP}:8080 \
--v=2
/hyperkube proxy \
--master=http://${MASTER_IP}:8080 \
--v=2
}
echo "Detecting your OS distro ..."