升级内核

Shell># rpm —import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
Shell># rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
Shell># yum —enablerepo=elrepo-kernel -y install kernel-ml-devel kernel-ml
Shell># grub2-set-default 0
Shell># init 6

调整内核参数

  1. net.ipv4.ip_forward = 1

关闭swap

在kubernetes系统中,推荐禁用!如果在系统安装过程中,启用了swap,请使用以下命令关闭

  1. Shell># swapoff -a

也可删除/etc/fstab中的相关信息,彻底清除
验证

  1. Shell># free -m

防火墙

推荐关闭

selinux

推荐设置为disable

安装常用必备软件

  1. shell># yum -y install chrony kubelet docker flannel

说明

  • chrony :时间同步用的。我们将配置它同步ntp.k8s.com的时间,这里不说明如何调整。
  • kubelet :使用私有yum仓库,安装kubelet 1.9.0
  • docker :安装了docker 17.12 ce版本,使用了官方的yum仓库
  • flannel :网络插件,使用了yum安装。

配置docker

shell># vi /usr/lib/systemd/system/docker.service

  1. [Unit]
  2. Description=Docker Application Container Engine
  3. Documentation=https://docs.docker.com
  4. After=network-online.target firewalld.service
  5. Wants=network-online.target
  6. [Service]
  7. Type=notify
  8. EnvironmentFile=-/run/flannel/docker
  9. # the default is not to use systemd for cgroups because the delegate issues still
  10. # exists and systemd currently does not support the cgroup feature set required
  11. # for containers run by docker
  12. ExecStart=/usr/bin/dockerd $DOCKER_NETWORK_OPTIONS
  13. ExecReload=/bin/kill -s HUP $MAINPID
  14. # Having non-zero Limit*s causes performance problems due to accounting overhead
  15. # in the kernel. We recommend using cgroups to do container-local accounting.
  16. LimitNOFILE=infinity
  17. LimitNPROC=infinity
  18. LimitCORE=infinity
  19. # Uncomment TasksMax if your systemd version supports it.
  20. # Only systemd 226 and above support this version.
  21. #TasksMax=infinity
  22. TimeoutStartSec=0
  23. # set delegate yes so that systemd does not reset the cgroups of docker containers
  24. Delegate=yes
  25. # kill only the docker process, not all processes in the cgroup
  26. KillMode=process
  27. # restart the docker process if it exits prematurely
  28. Restart=on-failure
  29. StartLimitBurst=3
  30. StartLimitInterval=60s
  31. [Install]
  32. WantedBy=multi-user.target