九,Kubernetes

    xiaoxiao2023-11-12  143

    一,修改docker的systemd的文件

    cat > /usr/lib/systemd/system/docker.service << "EOF" [Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com BindsTo=containerd.service After=network-online.target firewalld.service containerd.service flannel.service Wants=network-online.target Requires=flannel.service [Service] Type=notify EnvironmentFile=-/run/flannel/docker # the default is not to use systemd for cgroups because the delegate issues still # exists and systemd currently does not support the cgroup feature set required # for containers run by docker ExecStart=/usr/bin/dockerd $DOCKER_OPTS ExecReload=/bin/kill -s HUP $MAINPID TimeoutSec=0 RestartSec=2 Restart=always # Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229. # Both the old, and new location are accepted by systemd 229 and up, so using the old location # to make them work for either version of systemd. StartLimitBurst=3 # Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230. # Both the old, and new name are accepted by systemd 230 and up, so using the old name to make # this option work for either version of systemd. StartLimitInterval=60s # Having non-zero Limit*s causes performance problems due to accounting overhead # in the kernel. We recommend using cgroups to do container-local accounting. LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity # Comment TasksMax if your systemd version does not supports it. # Only systemd 226 and above support this option. TasksMax=infinity # set delegate yes so that systemd does not reset the cgroups of docker containers Delegate=yes # kill only the docker process, not all processes in the cgroup KillMode=process [Install] WantedBy=multi-user.target EOF

     

     

    二,分发docker的systemd的文件

    source /root/env.sh for master_ip in ${MASTER_IPS[@]} do echo -e "\033[31m>>> ${master_ip} \033[0m" scp /usr/lib/systemd/system/docker.service root@${master_ip}:/usr/lib/systemd/system/docker.service done #验证是否分发成功 source /root/env.sh for master_ip in ${MASTER_IPS[@]} do echo -e "\033[31m>>> ${master_ip} \033[0m" ssh root@${master_ip} "ls -ld /usr/lib/systemd/system/docker.service" done

     

     

    三,重启docker, 出现docker0网卡,且在10.2.0.0/16网段,说明配置成功

    source /root/env.sh for master_ip in ${MASTER_IPS[@]} do echo -e "\033[31m>>> ${master_ip} \033[0m" ssh root@${master_ip} "systemctl daemon-reload && systemctl restart docker" done

     

     

    四,验证docker服务

    source /root/env.sh for master_ip in ${MASTER_IPS[@]} do echo -e "\033[31m>>> ${master_ip} \033[0m" ssh root@${master_ip} "systemctl status docker | grep Active" done

     

     

    五,验证网段

    source /root/env.sh for master_ip in ${MASTER_IPS[@]} do echo -e "\033[31m>>> ${master_ip} \033[0m" ssh root@${master_ip} "/usr/sbin/ip addr show flannel.1 && /usr/sbin/ip addr show docker0" done

    确认各 work 节点的 docker0 网桥和 flannel.1 接口的 IP 处于同一个网段中(如下 10.2.63.0.0/32 位于 10.2.63.1/21 中) 输出: (结果是部署情况而定,网段可能与下面不一样)>>> 172.27.128.11  3: flannel.1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UNKNOWN group default      link/ether da:e9:aa:41:a0:9e brd ff:ff:ff:ff:ff:ff     inet 10.2.63.0/32 scope global flannel.1        valid_lft forever preferred_lft forever     inet6 fe80::d8e9:aaff:fe41:a09e/64 scope link         valid_lft forever preferred_lft forever 4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default      link/ether 02:42:21:2d:63:99 brd ff:ff:ff:ff:ff:ff     inet 10.2.63.1/24 brd 10.2.63.255 scope global docker0        valid_lft forever preferred_lft forever >>> 172.27.128.12  3: flannel.1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UNKNOWN group default      link/ether 7a:2b:18:31:ad:3d brd ff:ff:ff:ff:ff:ff     inet 10.2.55.0/32 scope global flannel.1        valid_lft forever preferred_lft forever     inet6 fe80::782b:18ff:fe31:ad3d/64 scope link         valid_lft forever preferred_lft forever 4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default      link/ether 02:42:81:b9:d4:84 brd ff:ff:ff:ff:ff:ff     inet 10.2.55.1/24 brd 10.2.55.255 scope global docker0        valid_lft forever preferred_lft forever >>> 172.27.128.13  3: flannel.1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UNKNOWN group default      link/ether 0e:50:a7:8d:b5:df brd ff:ff:ff:ff:ff:ff     inet 10.2.67.0/32 scope global flannel.1        valid_lft forever preferred_lft forever     inet6 fe80::c50:a7ff:fe8d:b5df/64 scope link         valid_lft forever preferred_lft forever 4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default      link/ether 02:42:c8:3f:76:fa brd ff:ff:ff:ff:ff:ff     inet 10.2.67.1/24 brd 10.2.67.255 scope global docker0        valid_lft forever preferred_lft forever

    最新回复(0)