1. 将 kube-apiserver, kube-controller-manager, kube-scheduler,kubectl 拷贝到/usr/bin目录下
2. 安装etcd
- sudo apt-get install etcd
- 版本 2.2.5
- 修改/usr/lib/systemd/system/etcd.service文件,配置etcd单机版模式
[Unit]Description=etcd serverDocumentation=https://github.com/coreos/etcdDocumentation=man:etcdAfter=network.targetWants=network-online.target[Service]WorkingDirectory=/var/lib/etcd/EnvironmentFile=-/etc/etcd/etcd.confType=notifyUser=etcdPermissionsStartOnly=trueExecStart=/usr/bin/etcdRestart=on-failure#RestartSec=10sLimitNOFILE=65536[Install]WantedBy=multi-user.targetAlias=etcd2.service~
- 修改配置文件etc/etcd/etcd.conf
ETCD_ME=defaultETCD_DATA_DIR="/var/lib/etcd/default.etcd"ETCD_LISTEN_CLIENT_URLS="http://109.105.46.94:2379,http://127.0.0.1:2379"ETCD_LISTEN_PEER_URLS="http://109.105.46.94:2380"ETCD_ADVERTISE_CLIENT_URLS="http://109.105.46.94:2379"
- 启动服务 systemctl start etcd
-
检查是否工作
etcdctl set hello world
etcdctl get hello
- 创建网络,后面flannel会使用
etcdctl mk /flannel/network/config
'{"Network":"172.17.0.0/16"}'
3. apiserver 配置
- 创建kubernetes API server的配置文件/usr/lib/systemd/system/kube-apiserver.service
[Unit]After=etcd.serviceConditionFileIsExecutable=/usr/bin/kube-apiserverDescription=Kubernetes API ServerDocumentation=https://github.com/GoogleCloudPlatform/kubernetesWants=etcd.service[Service]ExecStart=/usr/bin/kube-apiserver \--insecure-bind-address=0.0.0.0 \--insecure-port=8080 \--bind-address=0.0.0.0 \--secure-port=6443 \--etcd_servers=http://109.105.46.94:2379 \--service-cluster-ip-range=192.168.0.0/16 \ --service-node-port-range=30000-32767 \--logtostderr=true \--v=0 \--log-dir=/home/nwlab/kubernetes/logsRestart=alwaysRestartSec=10[Install]WantedBy=multi-user.target
- 启动服务
systemctl daemon-reloadsystemctl start kube-apiserversystemctl status kube-apiserver(or journalctl -xe)
4. controller-manager配置
- 创建配置文件 /usr/lib/systemd/system/kube-controller-manager.service
[Unit]After=etcd.serviceConditionFileIsExecutable=/usr/bin/kube-controller-managerDescription=Kubernetes Controller ManagerDocumentation=https://github.com/GoogleCloudPlatform/kubernetesWants=etcd.service[Service]ExecStart=/usr/bin/kube-controller-manager \--master=109.105.46.94:8080 \--logtostderr=true \--v=0 \--log-dir=/home/nwlab/kubernetes/logsRestart=alwaysRestartSec=10[Install]WantedBy=multi-user.target
- 启动服务
systemctl daemon-reloadsystemctl start kube-controller-managersystemctl status kube-controller-manager(or journalctl -xe)
5. scheduler配置
- 创建配置文件 /usr/lib/systemd/system/kube-scheduler.service
[Unit]After=etcd.serviceConditionFileIsExecutable=/usr/bin/kube-schedulerDescription=Kubernetes SchedulerDocumentation=https://github.com/GoogleCloudPlatform/kubernetesWants=etcd.service[Service]ExecStart=/usr/bin/kube-scheduler \--master=109.105.46.94:8080 \--address=0.0.0.0 \--logtostderr=true\--v=0 \ --log-dir=/home/nwlab/kubernetes/logsRestart=alwaysRestartSec=10[Install]WantedBy=multi-user.target
- 启动服务
systemctl daemon-reloadsystemctl restart kube-schedulersystemctl status kube-scheduler(or journalctl -xe)
6.检查 kubectl get componentstatuses