标签:
Kubernetes介绍:http://kubernetes.io/docs/getting-started-guides/
github地址:https://github.com/kubernetes/kubernetes
在ubuntu上安装文档官方地址:http://kubernetes.io/docs/getting-started-guides/ubuntu/
需要在三个节点上安装docker和ssh,安装ssh:
$ sudo apt-get install openssh-server
$ sudo service ssh start
安装docker:
sudo apt-get install docker-engine
1、在Master上,首先创建一个工作目录,执行:
$ git clone https://github.com/kubernetes/kubernetes.git
2、下载完后,进入kubernetes目录,修改kubernetes/cluster/ubuntu/config-default.sh文件:
root@192.168.127.135 root@192.168.27.136 root@192.168.27.137
3、安装kubernetes:
$ cd kubernetes/cluster
$ KUBERNETES_PROVIDER=ubuntu ./kube-up.sh
成功安装的截图如下:
访问页面:
1、重启master节点,如何恢复?
这个问题弄了我至少3小时才搞定,因为我是准备直接重新执行一遍上面步骤的第三步,也就是再执行一次kube-up.sh,然而我发现每次该脚本都会从github上下载etcd、flanneld和kubernetes包,这个包有1.4G大小,可想而知要耽误多少时间。然后我就只能慢慢找这段脚本在哪执行的,最后发现在kubernetes/cluster/ubuntu/下的download-release.sh,也就是下图中的文件。所以我就把文件的内容改了,改成下面代码中的样子,目的是不让它每次都下。随后呢,我的做法是把第一次成功安装的文件备份一下,也就是把kubernetes/cluster/ubuntu/binaries这个目录备份起来,然后直接拷到重启后的master的对应目录。然后再执行kube-up.sh,之后就OK啦!
#!/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 pushd $(dirname $0) mkdir -p binaries/master mkdir -p binaries/minion # flannel FLANNEL_VERSION=${FLANNEL_VERSION:-"0.5.5"} echo "Prepare flannel ${FLANNEL_VERSION} release ..." grep -q "^${FLANNEL_VERSION}\$" binaries/.flannel 2>/dev/null || { # 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 # cp flannel-${FLANNEL_VERSION}/flanneld binaries/master # cp flannel-${FLANNEL_VERSION}/flanneld binaries/minion echo ${FLANNEL_VERSION} > binaries/.flannel } # ectd ETCD_VERSION=${ETCD_VERSION:-"2.3.1"} ETCD="etcd-v${ETCD_VERSION}-linux-amd64" echo "Prepare etcd ${ETCD_VERSION} release ..." grep -q "^${ETCD_VERSION}\$" binaries/.etcd 2>/dev/null || { # curl -L https://github.com/coreos/etcd/releases/download/v${ETCD_VERSION}/${ETCD}.tar.gz -o etcd.tar.gz # tar xzf etcd.tar.gz # cp ${ETCD}/etcd ${ETCD}/etcdctl binaries/master echo ${ETCD_VERSION} > binaries/.etcd } function get_latest_version_number { local -r latest_url="https://storage.googleapis.com/kubernetes-release/release/stable.txt" if [[ $(which wget) ]]; then wget -qO- ${latest_url} elif [[ $(which curl) ]]; then curl -Ss ${latest_url} else echo "Couldn‘t find curl or wget. Bailing out." >&2 exit 4 fi } KUBE_VERSION=$(get_latest_version_number | sed ‘s/^v//‘) # k8s echo "Prepare kubernetes ${KUBE_VERSION} release ..." grep -q "^${KUBE_VERSION}\$" binaries/.kubernetes 2>/dev/null || { # curl -L https://github.com/kubernetes/kubernetes/releases/download/v${KUBE_VERSION}/kubernetes.tar.gz -o kubernetes.tar.gz # tar xzf kubernetes.tar.gz # 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 # cp kubernetes/server/kubernetes/server/bin/kubectl binaries/ echo ${KUBE_VERSION} > binaries/.kubernetes } #rm -rf flannel* kubernetes* etcd* echo "Done! All your binaries locate in kubernetes/cluster/ubuntu/binaries directory" popd
【kubernetes】ubuntu14.04 64位 搭建kubernetes过程
标签:
原文地址:http://www.cnblogs.com/puyangsky/p/5635751.html