• 项目实战篇【kubernetes】四 || kubernetes集群环境设置


    1、设置防火墙为 Iptables 并设置空规则

    #需关闭防火墙firewalld并禁用开机启动 systemctl stop firewalld && systemctl disable firewalld
    yum -y install iptables-services && systemctl start iptables && systemctl enable iptables && iptables -F && service iptables save
    

    2、调整内核参数

    cat > kubernetes.conf <<EOF
    net.bridge.bridge-nf-call-iptables=1
    net.bridge.bridge-nf-call-ip6tables=1
    net.ipv4.ip_forward=1
    net.ipv4.tcp_tw_recycle=0
    vm.swappiness=0 # 禁止使用 swap 空间,只有当系统 OOM 时才允许使用它
    vm.overcommit_memory=1 # 不检查物理内存是否够用
    vm.panic_on_oom=0 # 开启 OOM
    fs.inotify.max_user_instances=8192
    fs.inotify.max_user_watches=1048576
    fs.file-max=52706963
    fs.nr_open=52706963
    net.ipv6.conf.all.disable_ipv6=1
    net.netfilter.nf_conntrack_max=2310720
    EOF
    cp kubernetes.conf /etc/sysctl.d/kubernetes.conf
    sysctl -p /etc/sysctl.d/kubernetes.conf
    

    执行脚本后会提示cannot stat /proc/sys/net/netfilter/nt_conntrack_max,没有文件或目录,当前内核版本没有该文件目录,只有升级到4.0以后才有。

    3、kube-proxy开启ipvs的前置条件

    modprobe br_netfilter
    cat > /etc/sysconfig/modules/ipvs.modules <<EOF
    #!/bin/bash
    modprobe -- ip_vs
    modprobe -- ip_vs_rr
    modprobe -- ip_vs_wrr
    modprobe -- ip_vs_sh
    modprobe -- nf_conntrack_ipv4
    EOF
    chmod 755 /etc/sysconfig/modules/ipvs.modules && bash /etc/sysconfig/modules/ipvs.modules && lsmod | grep -e ip_vs -e nf_conntrack_ipv4
    

    4、安装kubeadm、kubelet、kubectl

    配置kubernetes阿里云源

    cat <<EOF > /etc/yum.repos.d/kubernetes.repo
    [kubernetes]
    name=Kubernetes
    baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
    enabled=1
    gpgcheck=1
    repo_gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
    EOF
    

    yum安装

    #目前建议安装1.15.4版本
    yum install -y kubectl-1.15.4-0 kubeadm-1.15.4-0 kubelet-1.15.4-0
    

    启动kubelet服务

    systemctl start kubelet && systemctl enable kubelet
    

    5、学习交流QQ群【883210148】

    alt QQ群

    6、关注微信公众号,免费获取文档及资源

    alt 微信公众号

  • 相关阅读:
    【第三章】DI的配置使用(一)
    【第二章】IoC的配置使用(一)
    【第二章】IoC的基础与详解(一)
    【第一章】 Spring概述(二)
    【第一章】 Spring概述(一)
    数据库分库分表思路
    Java的内存模型JVM
    Servlet 单例多线程详细解释
    三极管
    续流二极管
  • 原文地址:https://www.cnblogs.com/kevin-ying/p/13299948.html
Copyright © 2020-2023  润新知