• kubeadm node节点一键搭建脚本


    #!/bin/bash
    NODENUM=$1
    if [ ! -n "$NODENUM" ];then
    echo "请输入节点名称"
    exit 1
    else
    echo $NODENUM
    fi
    hostnamectl set-hostname $NODENUM
    modprobe br_netfilter
    echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
    echo "net.bridge.bridge-nf-call-ip6tables = 1" >> /etc/sysctl.conf
    echo "net.bridge.bridge-nf-call-iptables = 1" >> /etc/sysctl.conf
    sysctl -p
    yum install -y nfs-utils wget
    yum install -y yum-utils device-mapper-persistent-data lvm2
    yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
    yum install -y docker-ce docker-ce-cli
    systemctl enable docker && systemctl start docker
    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 install -y kubelet-1.17.0 kubeadm-1.17.0 kubectl-1.17.0
    systemctl enable kubelet && systemctl start kubelet
    cat <<EOF > /etc/docker/daemon.json
    {
    "registry-mirrors": ["https://8xta6lj0.mirror.aliyuncs.com"]
    }
    EOF
    sed -i "s#^ExecStart=/usr/bin/dockerd.*#ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --exec-opt native.cgroupdriver=systemd#g" /usr/lib/systemd/system/docker.service
    systemctl daemon-reload  && systemctl restart docker
    echo "172.16.10.9 apiserver.shiji" >> /etc/hosts
    echo "172.16.10.9 shiji.com" >> /etc/hosts
    echo `ip addr |grep eth0 |awk -F' ' '{print $2}'| grep -v eth0 |awk -F'/' '{print $1}'` $NODENUM >> /etc/hosts
    echo "节点初始化操作完成,请在master节点上设置hosts解析后加入K8S集群"

  • 相关阅读:
    notepad++ 编辑器链接地址可点击
    window的cmd窗口运行git
    php update for mac
    sublime打开文件时自动生成并打开.dump文件
    不能设置sublime text 2 为默认编辑器
    sublime text 2 配置文件
    Compass被墙后如何安装安装
    everything搜索工具小技巧
    Ubuntu安装已经下载好的文件包
    Flutter 异步Future与FutureBuilder实用技巧
  • 原文地址:https://www.cnblogs.com/shiji888/p/12672570.html
Copyright © 2020-2023  润新知