标签:serve mkdir yun 内容 util tst inf bec 编辑
docker install
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum list docker-ce --showduplicates | sort -r
yum -y install docker-ce-18.06.1.ce-3.el7
systemctl start docker
systemctl enable docker
主机名 | 地址 | 角色 | 组件 |
---|---|---|---|
k8s-m1 | 10.16.32.85 | k8s-master | etcd、kube-apiserver、kube-controller-manager、kube-scheduler |
k8s-g1 | 10.16.32.86 | k8s-node | kubelet、docker、kube_proxy |
k8s-g2 | 10.16.32.87 | k8s-node | kubelet、docker、kube_proxy |
https://github.com/kubernetes/kubernetes/releases
https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG-1.13.md#v1130-beta2
从上边的网址中选择相应的版本,从 CHANGELOG页面 下载二进制文件,本文以1.13版本为例,
在/root/kubernetes/server/bin
路径下包含一些必须的组件 binary文件如下
https://github.com/coreos/etcd/releases/
这里选用的是最新版本v3.3.10。
将下载的etcd文件包进行解压,解压后将etcd、etcdctl二进制文件复制到/usr/bin目录。
在/usr/lib/systemd/system/目录下创建文件etcd.service,内容为:
mkdir /var/lib/etcd/
vim /usr/lib/systemd/system/etcd.service
[Unit] Description=Etcd Server [Service] Type=notify TimeoutStartSec=0 Restart=always WorkingDirectory=/var/lib/etcd/ EnvironmentFile=-/etc/etcd/etcd.conf ExecStart=/usr/bin/etcd [Install] WantedBy=multi-user.target
(3)创建配置文件/etc/etcd/etcd.conf
ETCD_NAME=ETCD Server ETCD_DATA_DIR="/var/lib/etcd/" ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379" ETCD_ADVERTISE_CLIENT_URLS="http://10.16.32.85:2379"
(4)配置开机启动并运行
systemctl daemon-reload
systemctl enable etcd.service
systemctl start etcd.service
(5)检验etcd是否安装成功
etcdctl cluster-health
将kube-apiserver、kube-controller-manager、kube-scheduler 三个可执行文件复制到/usr/bin目录
(1)新建并编辑kube-apiserver.service 文件
路径:/usr/lib/systemd/system/kube-apiserver.service
,内容为:
[Unit] Description=Kubernetes API Server After=etcd.service Wants=etcd.service [Service] EnvironmentFile=/etc/kubernetes/apiserver ExecStart=/usr/bin/kube-apiserver $KUBE_ETCD_SERVERS $KUBE_API_ADDRESS $KUBE_API_PORT $KUBE_SERVICE_ADDRESSES $KUBE_ADMISSION_CONTROL $KUBE_API_LOG $KUBE_API_ARGS Restart=on-failure Type=notify LimitNOFILE=65536 [Install] WantedBy=multi-user.target
/etc/kubernetes/apiserver
,内容为:KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0" KUBE_API_PORT="--insecure-port=8080" KUBE_ETCD_SERVERS="--etcd-servers=http://10.16.32.85:2379" KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=192.168.0.0/16" KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota" KUBE_API_LOG="--logtostderr=false --log-dir=/var/log/kubernets/apiserver --v=2" KUBE_API_ARGS=" "
(1)新建并编辑kube-controller-manager.service 文件
路径:/usr/lib/systemd/system/kube-controller-manager.service,内容为:
[Unit] Description=Kubernetes Scheduler After=kube-apiserver.service Requires=kube-apiserver.service [Service] EnvironmentFile=-/etc/kubernetes/controller-manager ExecStart=/usr/bin/kube-controller-manager $KUBE_MASTER $KUBE_CONTROLLER_MANAGER_ARGS Restart=on-failure LimitNOFILE=65536 [Install] WantedBy=multi-user.target
(2)配置文件
apiserver配置文件路径为:/etc/kubernetes/controller-manager,内容为:
KUBE_MASTER="--master=http://10.16.32.85:8080" KUBE_CONTROLLER_MANAGER_ARGS=" "
(1)新建并编辑kube-scheduler 文件
路径:/usr/lib/systemd/system/kube-scheduler.service,内容为:
[Unit] Description=Kubernetes Scheduler After=kube-apiserver.service Requires=kube-apiserver.service [Service] User=root EnvironmentFile=-/etc/kubernetes/scheduler ExecStart=/usr/bin/kube-scheduler $KUBE_MASTER $KUBE_SCHEDULER_ARGS Restart=on-failure LimitNOFILE=65536 [Install] WantedBy=multi-user.target
(2)配置文件
kube-scheduler配置文件路径为:/etc/kubernetes/scheduler,内容为:
KUBE_MASTER="--master=http://10.16.32.85:8080" KUBE_SCHEDULER_ARGS="--logtostderr=true --log-dir=/var/log/kubernetes/scheduler --v=2"
systemctl daemon-reload systemctl enable kube-apiserver.service systemctl start kube-apiserver.service systemctl enable kube-controller-manager.service systemctl start kube-controller-manager.service systemctl enable kube-scheduler.service systemctl start kube-scheduler.service
运行命令 kubectl get cs
Node节点上安装组件有:
Docker的版本需要与kubelete版本相对应,最好都使用最新的版本。
在之前解压的 kubernetes 文件夹中拷贝二进制文件
标签:serve mkdir yun 内容 util tst inf bec 编辑
原文地址:https://www.cnblogs.com/blogscc/p/10105134.html