[关闭]
@zhangyy 2021-04-12T16:34:18.000000Z 字数 2529 阅读 167

rancher server 单节点部署/K8S高可用部署

rancher系列


  • 一: 环境说明:
  • 二:部署准备:

一: 环境说明:

  1. # 操作系统:centos7
  2. # docker版本:19.03.5
  3. # rancher版本: latest
  4. # rancher server 节点IP :192.168.100.11
  5. # rancher agent节点IP: 192.168.100.12
  6. # K8S master 节点IP:192.168.100.11---192.168.100.14
  7. # K8S worker节点IP: 192.168.100.11---192.168.100.14
  8. # K8S etcd 节点IP:192.168.100.11--192.168.100.13

二:部署准备:

  1. # 操作在所有节点进行
  2. # 修改内核参数:
  3. 关闭swap
  4. vim /etc/sysctl.conf
  5. vm.swappiness=0
  6. net.ipv4.ip_forward = 1
  7. net.bridge.bridge-nf-call-ip6tables = 1
  8. net.bridge.bridge-nf-call-iptables = 1
  9. sysctl -p
  10. 临时生效
  11. swapoff -a && sysctl -w vm.swappiness=0
  12. # 修改 fstab 不在挂载 swap
  13. vi /etc/fstab
  14. # /dev/mapper/centos-swap swap swap defaults 0 0
  15. # 安装docker
  16. yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  17. # 添加docker配置
  18. mkdir -p /etc/docker
  19. vim /etc/docker/daemon.json
  20. {
  21. "max-concurrent-downloads": 20,
  22. "data-root": "/opt/docker/data",
  23. "exec-root": "/opt/docker/root",
  24. "registry-mirrors": ["https://fy707np5.mirror.aliyuncs.com"],
  25. "log-driver": "json-file",
  26. "bridge": "docker0",
  27. "oom-score-adjust": -1000,
  28. "debug": false,
  29. "log-opts": {
  30. "max-size": "100M",
  31. "max-file": "10"
  32. },
  33. "default-ulimits": {
  34. "nofile": {
  35. "Name": "nofile",
  36. "Hard": 1024000,
  37. "Soft": 1024000
  38. },
  39. "nproc": {
  40. "Name": "nproc",
  41. "Hard": 1024000,
  42. "Soft": 1024000
  43. },
  44. "core": {
  45. "Name": "core",
  46. "Hard": -1,
  47. "Soft": -1
  48. }
  49. }
  50. }
  51. # 安装依赖
  52. yum install -y yum-utils ipvsadm telnet wget net-tools conntrack ipset jq iptables curl sysstat libseccomp socat nfs-utils fuse fuse-devel
  53. # 安装docker依赖
  54. yum install -y python-pip python-devel yum-utils device-mapper-persistent-data lvm2
  55. # 安装docker
  56. yum install -y docker-ce
  57. # reload service 配置
  58. systemctl daemon-reload
  59. # 重启docker
  60. systemctl restart docker
  61. # 设置开机启动
  62. systemctl enable docker
  63. #自动加载ipvs 创建开机加载
  64. cat << EOF > /etc/sysconfig/modules/ipvs.modules
  65. #!/bin/bash
  66. modprobe -- ip_vs
  67. modprobe -- ip_vs_rr
  68. modprobe -- ip_vs_wrr
  69. modprobe -- ip_vs_sh
  70. modprobe -- nf_conntrack_ipv4
  71. EOF
  72. # /etc/sysconfig/modules/ipvs.modules 可执行权限
  73. chmod +x /etc/sysconfig/modules/ipvs.modules
  74. # 执行 /etc/sysconfig/modules/ipvs.modules
  75. /etc/sysconfig/modules/ipvs.modules

三:部署rancher server

3.1 安装单机版的rancher server

  1. # 操作IP: 192.168.100.11
  2. docker run -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher:latest
  3. # 等待镜像拉取完成启动好容器
  4. 打开浏览器输入:192.168.100.11 浏览器会自动跳转到https选择 继续前往192.168.100.11(不安全)

3.2 rancher server 添加集群

image_1e7ms8is5qmg1ukqbfs1rpp1csh9.png-191.5kB

image_1e7ms9q941t7p1a321bve8851fkc16.png-307.2kB

image_1e7mt5tu01b0e1hqera715an4ri3k.png-306.3kB

  1. kubeproxy:
  2. extra_args:
  3. proxy-mode: "ipvs"

image_1e7mstjeq1rr29br1vlmg431k2s2q.png-297.7kB

  1. 配置 kube-proxy 数据转发模式 这里我修改为IPVS 模式当然如果默认是iptables 配置完成选择下一步

image_1e7mt7f6o1d25vlh1t61k1ek2b41.png-359.7kB

  1. sudo docker run -d --privileged --restart=unless-stopped --net=host -v /etc/kubernetes:/etc/kubernetes -v /var/run:/var/run rancher/rancher-agent:v2.4.3 --server https://192.168.100.11 --token 4q66cvt6gdmqb2nc76jlt6g884lnpfrppz5fb42d2qzxbq5pftwp8n --ca-checksum bb0a1bc022960b372681aef2888dac5770e546bce82c69e77b1e1d0604a8490b --etcd --controlplane --worker

四: 启动 rancher agent

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注