kubernetes部署Master组件
程序员文章站
2022-07-13 22:24:34
...
在部署Kubernetes Master之前一定要确保etcd、flannel、docker是正常工作的,否则先解决问题再继续。
Master组件组要包括kube-apiserver,kube-scheduler,kube-controller-manager。
1、下载解压kubernetes server二进制包这里是v1.14:
tar -zxvf kubernetes-server-linux-amd64.tar.gz
cd kubernetes/server/bin/
cp kube-scheduler kube-apiserver kube-controller-manager kubectl /opt/k8s/bin/
安装APIserver组件
2.部署kube-apiserver组件 创建TLS Bootstrapping Token
#自动生成token:
head -c 16 /dev/urandom | od -An -t x | tr -d ' '
vim /opt/k8s/token.csv
16位token,kubelet-bootstrap,10001,"system:kubelet-bootstrap"
3、创建Apiserver配置文件
vim /opt/k8s/cfg/kube-apiserver.conf
KUBE_APISERVER_OPTS="--logtostderr=true \
--v=4 \
--etcd-servers=https://192.168.122.134:2379,https://192.168.122.135:2379,https://192.168.122.136:2379 \
--bind-address=192.168.122.134 \
--secure-port=6443 \
--advertise-address=192.168.122.134 \
--allow-privileged=true \
--service-cluster-ip-range=10.10.10.0/24 \
--enable-admission-plugins=NamespaceLifecycle,LimitRanger,ServiceAccount,ResourceQuota,NodeRestriction \
--authorization-mode=RBAC,Node \
--enable-bootstrap-token-auth \
--token-auth-file=/opt/k8s/cfg/token.csv \
--service-node-port-range=30000-50000 \
--tls-cert-file=/opt/k8s/ssl/server.pem \
--tls-private-key-file=/opt/k8s/ssl/server-key.pem \
--client-ca-file=/opt/k8s/ssl/ca.pem \
--service-account-key-file=/opt/k8s/ssl/ca-key.pem \
--etcd-cafile=/opt/k8s/ssl/ca.pem \
--etcd-certfile=/opt/k8s/ssl/server.pem \
--etcd-keyfile=/opt/k8s/ssl/server-key.pem"
创建service:
vim /usr/lib/systemd/system/kube-apiserver.service
[Unit]
Description=Kubernetes API Server
Documentation=https://github.com/kubernetes/kubernetes
[Service]
EnvironmentFile=-/opt/k8s/cfg/kube-apiserver.conf
ExecStart=/opt/k8s/bin/kube-apiserver $KUBE_APISERVER_OPTS
Restart=on-failure
[Install]
WantedBy=multi-user.target
启动服务:
systemctl daemon-reload
systemctl enable kube-apiserver
systemctl start kube-apiserver
安装scheduler组件:
配置scheduler:
vim /opt/k8s/cfg/kube-scheduler.conf
KUBE_SCHEDULER_OPTS="--logtostderr=true --v=4 --master=127.0.0.1:8080 --leader-elect"
创建service:
vim /usr/lib/systemd/system/kube-scheduler.service
[Unit]
Description=Kubernetes Scheduler
Documentation=https://github.com/kubernetes/kubernetes
[Service]
EnvironmentFile=-/opt/k8s/cfg/kube-scheduler.conf
ExecStart=/opt/k8s/bin/kube-scheduler $KUBE_SCHEDULER_OPTS
Restart=on-failure
[Install]
WantedBy=multi-user.target
启动服务:
systemctl daemon-reload
systemctl enable kube-scheduler
systemctl start kube-scheduler
安装controller-manager组件
配置kube-controller-manager文件:
vim /opt/k8s/cfg/kube-controller-manager.conf
KUBE_CONTROLLER_MANAGER_OPTS="--logtostderr=true \
--v=4 \
--master=127.0.0.1:8080 \
--leader-elect=true \
--address=127.0.0.1 \
--service-cluster-ip-range=10.10.10.0/24 \
--cluster-name=kubernetes \
--cluster-signing-cert-file=/opt/k8s/ssl/ca.pem \
--cluster-signing-key-file=/opt/k8s/ssl/ca-key.pem \
--root-ca-file=/opt/k8s/ssl/ca.pem \
--service-account-private-key-file=/opt/k8s/ssl/ca-key.pem"
创建service:
vim /usr/lib/systemd/system/kube-controller-manager.service
[Unit]
Description=Kubernetes Controller Manager
Documentation=https://github.com/kubernetes/kubernetes
[Service]
EnvironmentFile=-/opt/k8s/cfg/kube-controller-manager.conf
ExecStart=/opt/k8s/bin/kube-controller-manager $KUBE_CONTROLLER_MANAGER_OPTS
Restart=on-failure
[Install]
WantedBy=multi-user.target
启动服务
systemctl daemon-reload
systemctl enable kube-controller-manager
systemctl start kube-controller-manager
查看个服务状态
在/opt/k8s目录下运行:
bin/kubectl get cs
推荐阅读
-
使用Kubeadm在CentOS7.2上部署Kubernetes集群的方法
-
附012.Kubeadm部署高可用Kubernetes
-
在 Kubernetes 集群快速部署 KubeSphere 容器平台
-
使用KubeAdm部署Kubernetes集群——如何访问google代码仓库及Yum源
-
浅谈surging服务引擎中的rabbitmq组件和容器化部署
-
kubernetes系列03—kubeadm安装部署K8S集群
-
009.Kubernetes二进制部署kube-apiserver
-
012.Kubernetes二进制部署worker节点Flannel
-
详解Openstack组件部署 — Overview和前期环境准备
-
003.Kubernetes二进制部署准备