k8s 分发证书文件 启动文件
接着上面的博客继续写
准备三台主机
192.168.1.71
192.168.1.72
192.168.1.73
现在k8s压缩包 我使用时1.12版本 不能下载请FQ
百度网盘提供1.12版本
https://pan.baidu.com/s/1Ty6DRaRtL-0HiTCwy5ubPA
n6cy
192.168.1.71
执行
pwd -> /tmp
tar -zxf kubernetes-server-linux-amd64.tar.gz
cd /tmp/kubernetes/server/bin
删除不需要的文件
rm -rf *.*
cp -rvf * /usr/bin/
修改selinux权限
for i in *; do chcon -u system_u -t bin_t /usr/bin/$i; done
cd
mkdir /root/system
cd /root/system
准备k8s程序启动二进制文件
百度网盘提供
https://pan.baidu.com/s/1LM5SiWuRl0IzhPiIOgGEsw
w2r1
也可以通过下面编辑的方式 设置k8s启动程序文件
下面编写的配置文件
vi kube-apiserver.service
[Unit] Description=Kubernetes API Server Documentation=https://github.com/GoogleCloudPlatform/kubernetes After=network.target After=etcd.service [Service] EnvironmentFile=-/etc/kubernetes/config EnvironmentFile=-/etc/kubernetes/apiserver User=kube ExecStart=/usr/bin/kube-apiserver \ $KUBE_LOGTOSTDERR \ $KUBE_LOG_LEVEL \ $KUBE_ETCD_SERVERS \ $KUBE_API_ADDRESS \ $KUBE_API_PORT \ $KUBELET_PORT \ $KUBE_ALLOW_PRIV \ $KUBE_SERVICE_ADDRESSES \ $KUBE_ADMISSION_CONTROL \ $KUBE_API_ARGS Restart=on-failure Type=notify LimitNOFILE=65536 [Install] WantedBy=multi-user.target
vi kube-controller-manager.service
[Unit] Description=Kubernetes Controller Manager Documentation=https://github.com/GoogleCloudPlatform/kubernetes [Service] EnvironmentFile=-/etc/kubernetes/config EnvironmentFile=-/etc/kubernetes/controller-manager User=kube ExecStart=/usr/bin/kube-controller-manager \ $KUBE_LOGTOSTDERR \ $KUBE_LOG_LEVEL \ $KUBE_MASTER \ $KUBE_CONTROLLER_MANAGER_ARGS Restart=on-failure LimitNOFILE=65536 [Install] WantedBy=multi-user.target
vi kubelet.service
[Unit] Description=Kubernetes Kubelet Server Documentation=https://github.com/GoogleCloudPlatform/kubernetes After=docker.service Requires=docker.service [Service] WorkingDirectory=/var/lib/kubelet EnvironmentFile=-/etc/kubernetes/config EnvironmentFile=-/etc/kubernetes/kubelet ExecStart=/usr/bin/kubelet \ $KUBE_LOGTOSTDERR \ $KUBE_LOG_LEVEL \ $KUBELET_API_SERVER \ $KUBELET_ADDRESS \ $KUBELET_PORT \ $KUBELET_HOSTNAME \ $KUBE_ALLOW_PRIV \ $KUBELET_POD_INFRA_CONTAINER \ $KUBELET_ARGS Restart=on-failure [Install] WantedBy=multi-user.target
vi kube-proxy.service
[Unit] Description=Kubernetes Kube-Proxy Server Documentation=https://github.com/GoogleCloudPlatform/kubernetes After=network.target [Service] EnvironmentFile=-/etc/kubernetes/config EnvironmentFile=-/etc/kubernetes/proxy ExecStart=/usr/bin/kube-proxy \ $KUBE_LOGTOSTDERR \ $KUBE_LOG_LEVEL \ $KUBE_MASTER \ $KUBE_PROXY_ARGS Restart=on-failure LimitNOFILE=65536 [Install] WantedBy=multi-user.target
vi kube-scheduler.service
[Unit] Description=Kubernetes Scheduler Plugin Documentation=https://github.com/GoogleCloudPlatform/kubernetes [Service] EnvironmentFile=-/etc/kubernetes/config EnvironmentFile=-/etc/kubernetes/scheduler User=kube ExecStart=/usr/bin/kube-scheduler \ $KUBE_LOGTOSTDERR \ $KUBE_LOG_LEVEL \ $KUBE_MASTER \ $KUBE_SCHEDULER_ARGS Restart=on-failure LimitNOFILE=65536 [Install] WantedBy=multi-user.target
复制k8s启动文件到 /usr/lib/systemd/system 目录下
pwd -> /root/system
cp -rfv kube* /usr/lib/systemd/system/
systemctl daemon-reload
mkdir /root/k8s-config-file
cd /root/k8s-config-file
下载k8s配置文件 1.10版本
https://pan.baidu.com/s/1uB3vklhNmLZFgrhnJ8TSVA
e0n6
复制配置文件到 /etc/kubernetes 目录
cp -rfv * /etc/kubernetes/
给 72 73 发送k8s配置文件
scp -r * 192.168.1.72:/etc/kubernetes/
scp -r * 192.168.1.73:/etc/kubernetes/
给 72 73 发送k8s启动程序配置文件
scp -r kube* 192.168.1.72:/usr/lib/systemd/system/
scp -r kube* 192.168.1.73:/usr/lib/systemd/system/
给 192.168.1.72 发送k8s命令控制文件 三台主机设计的俩主一从 在实际生产中一般默认要有2个api服务器做高可用
pwd -> /tmp/kubernetes/server/bin
scp -r * 192.168.1.72:/usr/bin/
给 192.168.1.73 发送k8s命令控制文件
scp -r kubelet kube-proxy 192.168.1.73:/usr/bin/
192.168.1.72
执行
chcon -u system_u -t bin_t /usr/bin/apiextensions-apiserver chcon -u system_u -t bin_t /usr/bin/cloud-controller-manager chcon -u system_u -t bin_t /usr/bin/hyperkube chcon -u system_u -t bin_t /usr/bin/kubeadm chcon -u system_u -t bin_t /usr/bin/kube-aggregator chcon -u system_u -t bin_t /usr/bin/kube-apiserver chcon -u system_u -t bin_t /usr/bin/kube-controller-manager chcon -u system_u -t bin_t /usr/bin/kubectl chcon -u system_u -t bin_t /usr/bin/kubefed chcon -u system_u -t bin_t /usr/bin/kubelet chcon -u system_u -t bin_t /usr/bin/kube-proxy chcon -u system_u -t bin_t /usr/bin/kube-scheduler
192.168.1.73
执行
chcon -u system_u -t bin_t /usr/bin/kubelet
chcon -u system_u -t bin_t /usr/bin/kube-proxy
192.168.1.71
执行
复制api证书到/etc/kubernetes/ssl/目录
pwd -> /etc/ssl/k8s/apiserver
cp apiserver.key apiserver.pem /etc/kubernetes/ssl/
给 192.168.1.72 发送证书
scp -r apiserver.key apiserver.pem 192.168.1.72:/etc/kubernetes/ssl/
复制ca.key到k8s目录下
pwd -> /etc/ssl/k8s
cp -rfv ca.key /etc/kubernetes/ssl/
scp -r ca.key 192.168.1.72:/etc/kubernetes/ssl/
scp -r ca.key 192.168.1.73:/etc/kubernetes/ssl/
复制kubelet证书
pwd -> /etc/ssl/k8s
首先删除证书请求文件 签发证书之后csr文件就没用了
rm -rf kubelet/*.csr
rm -rf kube-proxy/*.csr
cp -rfv kubelet/kubelet-1-71.* /etc/kubernetes/ssl/
cp -rfv kube-proxy/kube-proxy-1-71.* /etc/kubernetes/ssl/
scp -r kubelet/kubelet-1-72.* kube-proxy/kube-proxy-1-72.* 192.168.1.72:/etc/kubernetes/ssl/
scp -r kubelet/kubelet-1-73.* kube-proxy/kube-proxy-1-73.* 192.168.1.73:/etc/kubernetes/ssl/