下载master节点需要的二进制文件
https://storage.googleapis.com/kubernetes-release/release/v1.6.0/kubernetes-server-linux-amd64.tar.gz
下载后解压,拷贝所有文件
cp -r server/bin/{kube-apiserver,kube-controller-manager,kube-scheduler,kubectl,kube-proxy,kubelet} /usr/local/bin/
按照网传其他文档都设置有其配置的配置文档,其中部分配置参数是错误的或者过时的,可自行参考kube-apiserver --help等,当然安装过程出错能让人更好的理解其组件关系,参数验证可直接拿systemd里的命令加参数运行进行验证。本文都直接添加到systemd启动文件中。
root@ubuntu132:/etc/systemd/system# cat kube-apiserver.service
[Unit]
Description=Kubernetes API Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=network.target
[Service]
User=root
ExecStart=/usr/local/bin/kube-apiserver \
--admission-control=NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,ResourceQuota \
--advertise-address=192.168.15.132 \
--logtostderr=false \
--allow-privileged=true \
--apiserver-count=3 \
--audit-log-maxage=30 \
--audit-log-maxbackup=3 \
--audit-log-maxsize=100 \
--audit-log-path=/var/lib/audit.log \
--log-dir=/var/log/kubernetes \
--authorization-mode=RBAC \
--bind-address=192.168.15.132 \
--client-ca-file=/etc/kubernetes/ssl/ca.pem \
--enable-swagger-ui=true \
--etcd-cafile=/etc/kubernetes/ssl/ca.pem \
--etcd-certfile=/etc/kubernetes/ssl/kubernetes.pem \
--etcd-keyfile=/etc/kubernetes/ssl/kubernetes-key.pem \
--etcd-servers=https://192.168.15.132:2379,https://192.168.15.133:2379,https://192.168.15.134:2379 \
--event-ttl=1h \
--kubelet-https=true \
--insecure-bind-address=192.168.15.132 \
--runtime-config=rbac.authorization.k8s.io/v1alpha1 \
--service-account-key-file=/etc/kubernetes/ssl/ca-key.pem \
--service-cluster-ip-range=10.254.0.0/16 \
--service-node-port-range=8400-9000 \
--tls-cert-file=/etc/kubernetes/ssl/kubernetes.pem \
--tls-private-key-file=/etc/kubernetes/ssl/kubernetes-key.pem \
--experimental-bootstrap-token-auth \
--token-auth-file=/etc/kubernetes/token.csv \
--v=2
Restart=on-failure
RestartSec=5
Type=notify
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
root@ubuntu132:/etc/systemd/system# cat kube-controller-manager.service
[Unit]
Description=Kubernetes Controller Manager
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
[Service]
ExecStart=/usr/local/bin/kube-controller-manager \
--address=127.0.0.1 \
--allocate-node-cidrs=true \
--cluster-cidr=172.30.0.0/16 \
--cluster-name=kubernetes \
--cluster-signing-cert-file=/etc/kubernetes/ssl/ca.pem \
--cluster-signing-key-file=/etc/kubernetes/ssl/ca-key.pem \
--leader-elect=true \
--log-dir=/var/log/kubernetes \
--master=http://192.168.15.132:8080 \
--root-ca-file=/etc/kubernetes/ssl/ca.pem \
--service-account-private-key-file=/etc/kubernetes/ssl/ca-key.pem \
--service-cluster-ip-range=10.254.0.0/16 \
--logtostderr=false
--alsologtostderr=false
--allow-privileged=true
--v=2
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
root@ubuntu132:/etc/systemd/system# cat kube-scheduler.service
[Unit]
Description=Kubernetes Scheduler
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
[Service]
ExecStart=/usr/local/bin/kube-scheduler \
--leader-elect=true \
--master=http://192.168.15.132:8080 \
--address=127.0.0.1 \
--logtostderr=true \
--log-dir=/var/log/kubernetes \
--v=2
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
依次启动kube master节点的所有组件
systemctl daemon-reload
systemctl enable kube-apiserver
systemctl start kube-apiserver
systemctl status kube-apiserver
systemctl enable kube-controller-manager
systemctl start kube-controller-manager
systemctl enable kube-scheduler
systemctl start kube-scheduler
验证master节点
root@ubuntu132:/etc/systemd/system# kubectl get componentstatuses (cs)
NAME STATUS MESSAGE ERROR
scheduler Healthy ok
controller-manager Healthy ok
etcd-0 Healthy {"health": "true"}
etcd-2 Healthy {"health": "true"}
etcd-1 Healthy {"health": "true"}
转载于:https://blog.51cto.com/11448017/2048620