1.准备
- 下载kubernetes版本:1.4.0
- https://github.com/kubernetes/kubernetes/releases
[在master节点]
1.1.解压二进制包
tar xf kubernetesv1.4.0.tar.gz
cd kubernetes/server/
1.2.解压master所需的安装包
tar xf kubernetes-server-linux-amd64.tar.gz
cd kubernetes/server/bin/
1.3.把master需要的程序,拷贝到/usr/bin下,也可以设置环境变量达到相同目的
cp kube-apiserver kube-controller-manager kubectl kube-scheduler /usr/bin/
1.4.把minion需要的程序,scp发送到minion上
scp kubelet kube-proxy k8s_minion_ip:/usr/bin/
2.部署
[在master节点]
2.1.创建脚本
vim start_k8s_master.sh
#!/bin/bash
#firstly, start etcd
systemctl restart etcd
#secondly, start flanneld
systemctl restart flanneld
#then, start docker
systemctl restart docker
#start the main server of k8s master
nohup kube-apiserver --insecure-bind-address=0.0.0.0 --insecure-port=8080 --cors_allowed_origins=.* --etcd_servers=http://127.0.0.1:2379 --v=1 --logtostderr=false --log_dir=/var/log/k8s/apiserver --service-cluster-ip-range=172.100.0.0/16 &
nohup kube-controller-manager --master=k8s_master_ip:8080 --enable-hostpath-provisioner=false --v=1 --logtostderr=false --log_dir=/var/log/k8s/controller-manager &
nohup kube-scheduler --master=k8s_master_ip:8080 --v=1 --logtostderr=false --log_dir=/var/log/k8s/scheduler &
2.2.授权
chmod a+x start_k8s_master.sh
2.3.创建日志目录
mkdir -p /var/log/k8s/apiserver
mkdir -p /var/log/k8s/controller-manager
mkdir -p /var/log/k8s/scheduler
[在minion节点]
2.4.创建脚本
vim start_k8s_minion.sh
#!/bin/bash
#firstly, start etcd
systemctl restart etcd
#secondly, start flanneld
systemctl restart flanneld
#then, start docker
systemctl restart docker
#start the minion
nohup kubelet --address=0.0.0.0 --port=10250 --v=1 --log_dir=/var/log/k8s/kubelet --hostname_override=k8s_minion_ip --api_servers=http://k8s_master_ip:8080 --logtostderr=false &
nohup kube-proxy --master=k8s_master_ip:8080 --log_dir=/var/log/k8s/proxy --v=1 --logtostderr=false &
2.5.授权
chmod a+x start_k8s_minion.sh
2.6.创建日志目录
mkdir -p /var/log/k8s/kubelet
mkdir -p /var/log/k8s/proxy
3.运行k8s
[在master节点]
./start_k8s_master.sh
[在minion节点]
./start_k8s_minion.sh