Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

探索Kubernetes - 快速部署 #13

Open
zhouhaibing089 opened this issue May 21, 2016 · 0 comments
Open

探索Kubernetes - 快速部署 #13

zhouhaibing089 opened this issue May 21, 2016 · 0 comments
Labels

Comments

@zhouhaibing089
Copy link
Owner

zhouhaibing089 commented May 21, 2016

我想将这写成一个系列, 通过从部署一个kubernetes集群开始, 我们将一步一步来探索其中的奥秘. 是的, 官方repo中有很多文档来描述如何来尽可能自动化地部署, 但是要完全遵从, 那确实也挺难的, 但是如果作为一个由浅入深的教程, 我相信阅读本文一定会带给你更愉悦的体验.

设置环境

我假设你已经设置好了go语言的环境, 以下是我的环境变量设置:

export GOPATH=~/gopath
export GOROOT=~/go

下载源代码

$ mkdir -p $GOPATH/src/k8s.io
$ cd $GOPATH/src/k8s.io
$ git clone https://github.com/kubernetes/kubernetes.git

编译

这一步取决于你的工作环境, 我假设你用的是linux环境, 如果不是的话, 需要做一些交叉编译的准备工作.

$ ./hack/build-go.sh \
    cmd/kube-apiserver \
    cmd/kube-controller-manager \
    cmd/kube-scheduler \
    cmd/kube-proxy \
    cmd/kubectl \
    cmd/kubelet

启两个虚拟机

这里只有三个个要求, 一是因为我们要下载一些东西, 这两台虚拟机要能访问外网, 二是这两台虚拟机之间要能互通, 三是他们必须是Linux环境. 这是个自由选项, 下面是我申请的两台VM的信息.

dns ip
master 10.9.243.142
node-1 10.9.195.103

设置

  1. 安装docker
$ curl -fsSL https://get.docker.com/ | sh
$ sudo usermod -aG docker ${USER}
  1. 安装weave
$ sudo curl -L git.io/weave -o /usr/bin/weave
$ sudo chmod a+x /usr/bin/weave
  1. 运行weave
# mkdir -p /opt/cni/bin
# mkdir -p /etc/cni/net.d
# weave launch 10.9.195.103
# weave expose

weave launch 10.9.195.103中的ip是node-1的ip. 在设置node-1的时候要设置master的ip.
4. 安装etcd

这个只在master上.

$ curl -L  https://github.com/coreos/etcd/releases/download/v2.3.4/etcd-v2.3.4-linux-amd64.tar.gz -o etcd-v2.3.4-linux-amd64.tar.gz
$ tar xzvf etcd-v2.3.4-linux-amd64.tar.gz
$ cd etcd-v2.3.4-linux-amd64
$ sudo cp etcd /usr/bin
$ sudo cp etcdctl /usr/bin
  1. 运行etcd

这个只在master上.

# etcd 1>>/var/log/etcd.log 2>&1 &
  1. 运行kube-apiserver

这个只在master上.

# kube-apiserver \
    --admission-control=AlwaysAdmit \
    --authorization-mode=AlwaysAllow \
    --etcd-servers=http://127.0.0.1:2379 \
    --insecure-bind-address=0.0.0.0 \
    --service-cluster-ip-range=192.168.0.0/16 \
    1>>/var/log/kube-apiserver.log 2>&1 &
  1. 运行kube-controller-manager

这个只在master上.

# kube-controller-manager \
    --master=http://master:8080 \
    1>>/var/log/kube-controller-manager.log 2>&1 &
  1. 运行kube-scheduler

这个只在master上.

# kube-scheduler \
    --master=http://master:8080 \
    1>>/var/log/kube-scheduler.log 2>&1 &
  1. 运行kube-proxy
# kube-proxy \
    --master=http://master:8080 \
    1>>/var/log/kube-proxy.log 2>&1 &
  1. 运行kubelet

    # kubelet \
        --api-servers=http://master:8080 \
        --network-plugin=cni \
        --network-plugin-dir=/etc/cni/net.d \
        1>>/var/log/kubelet.log 2>&1 &
@zhouhaibing089 zhouhaibing089 added blog and removed blog labels Dec 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant