安装docker

  • 安装docker
    yum -y install docker-io
  • 启动docker
systemctl daemon-reload
systemctl start docker.service
systemctl enable docker.service

安装kubelet

  • cp kubelet /usr/bin
  • 创建/usr/lib/systemd/system/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/kubelet
ExecStart=/usr/bin/kubelet $KUBELET_ARGS
Restart=on-failure

[Install]
WantedBy=multi-user.target
  • 创建文件夹/var/lib/kubelet
  • 创建配置文件/etc/kubernetes/kubelet
KUBELET_ARGS="--api-servers=http://10.254.0.53:8080 --hostname-override=k8s-node1 --logtostderr=false --log-dir=/var/log/kubernetes --v=2"
  • 启动kubelet
systemctl daemon-reload
systemctl start kubelet.service
systemctl enable kubelet.service
systemctl status kubelet.service

报错1:
error: failed to run Kubelet: failed to create kubelet: misconfiguration: kubelet cgroup driver: "cgroupfs" is different from docker cgroup driver: "systemd"
解决方案:
`vi /usr/lib/systemd/system/docker.service`
`--exec-opt native.cgroupdriver=systemd`修改为`--exec-opt native.cgroupdriver=cgroupfs`
systemctl daemon-reload
systemctl restart docker
报错2:
--api-servers为k8s1.6.0的入参,升级版本后已废弃,可用kubeconfig代替
--api-servers has been deprecated, Use --kubeconfig instead. Will be removed in a future version.

安装kube-proxy

  • cp kube-proxy /usr/bin
  • vi /usr/lib/systemd/system/kube-proxy.service
[Unit]
Description=Kubernetes Kube-proxy Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=network.target
Requires=network.target

[Service]
EnvironmentFile=/etc/kubernetes/proxy
ExecStart=/usr/bin/kube-proxy $KUBE_PROXY_ARGS
Restart=on-failure
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
  • 新增配置文件/etc/kubernetes/proxy
KUBE_PROXY_ARGS="--master=http://10.254.0.53:8080 --logtostderr=false --log-dir=/var/log/kubernetes --v=2"
  • 启动kube-proxy
systemctl daemon-reload
systemctl start kube-proxy.service
systemctl status kube-proxy.service
systemctl enable kube-proxy.service