Loading

k8s及其基本插件离线文件下载和安装

k8s下载脚本的使用方法

设置k8s及相关组件的版本,在k8s_donwload.sh文件同级目录下创建releases文件,并填写版本号,如下示例。如果没有该文件,脚本会从github上自动获取最新版本,并生成releases文件

containerd_version=v1.7.7
runc_version=v1.1.9
cni_version=v1.3.0
cri_tools_version=v1.27.1
kubernetes_version=v1.27.7
kubernetes_release_version=v0.15.1
calico_version=v3.26.3
lvscare_version=v4.3.7

kubeadm-config.yaml

apiVersion: kubeadm.k8s.io/v1beta3
kind: InitConfiguration
---
apiVersion: kubeadm.k8s.io/v1beta3
kind: ClusterConfiguration
controlPlaneEndpoint: apiserver.cluster.local
networking:
  serviceSubnet: 10.96.0.0/16
  podSubnet: 10.244.0.0/16
kubernetesVersion: v1.27.7
nodeRegistration:
  criSocket: unix:///var/run/containerd/containerd.sock
---
apiVersion: kubeproxy.config.k8s.io/v1alpha1
kind: KubeProxyConfiguration
mode: "ipvs"
ipvs:
  excludeCIDRs:
  - "240.8.8.8/32"

k8s安装脚本的使用方法

# 查看使用命令
bash install_k8s.sh

确保所有服务器上都已经可以访问该软件包中的内容,并且配置一致
修改脚本配置,配置3台master服务器的ip地址,

master1="10.1.1.60"
master2="10.1.1.61"
master3="10.1.1.62"

master1 节点一键安装

# 注意:一键安装会删除master节点的污点,目的是为了方便单节点安装
bash install_k8s.sh install_all

或者多节点情况下逐步操作

# 逐步操作不会删除污点
bash install_k8s.sh install_containerd
bash install_k8s.sh install_runc
bash install_k8s.sh install_cni
bash install_k8s.sh install_cri_tools
bash install_k8s.sh init_system
bash install_k8s.sh install_k8s
bash install_k8s.sh init_k8s
bash install_k8s.sh install_calico

查看输出日志,

使用提示 
请在master2和master3节点上执行:

bash install_k8s.sh join_master dpj2fh.uw430qu93ky1xxs8 sha256:dc496d78fa13f1fbe20c0f27f56293052c98dc0177a0b310b60e060e8775c283 1960881d0fb845d53ab5f25243481b2718607728c917612aeb4ec8215d2372ce

请在所有node节点上执行:

bash install_k8s.sh join_node dpj2fh.uw430qu93ky1xxs8 sha256:dc496d78fa13f1fbe20c0f27f56293052c98dc0177a0b310b60e060e8775c283

master2 和 master3 加入集群

bash install_k8s.sh install_containerd
bash install_k8s.sh install_runc
bash install_k8s.sh install_cni
bash install_k8s.sh install_cri_tools
bash install_k8s.sh init_system
bash install_k8s.sh install_k8s
bash install_k8s.sh join_master <token> <cert-hash> <certificate-key>

node 节点安装

bash install_k8s.sh install_containerd
bash install_k8s.sh install_runc
bash install_k8s.sh install_cni
bash install_k8s.sh install_cri_tools
bash install_k8s.sh init_system
bash install_k8s.sh install_k8s
bash install_k8s.sh join_node <token> <cert-hash> 

安装脚本

#!/bin/bash

set -e

master1="172.28.20.10"
master2="172.28.20.10"
master3="172.28.20.10"

base_path=$(realpath $(dirname "${BASH_SOURCE[0]}"))

# base_path=$(
#     cd "$(dirname "$0")" || exit 1
#     pwd
# )
HOST_IF=$(ip route|grep default|head -n1|cut -d' ' -f5);
HOST_IP=$(ip a|grep "$HOST_IF$"|head -n1|awk '{print $2}'|cut -d'/' -f1)
VIP="240.8.8.8"

function usage() {
  echo -e "\033[33mUsage: \033[0mbash $0 <command> [parameter]"
  cat <<EOF
------------------------------------------------------------------------------------
准备
    bash $0 install_jq                                            安装jq,获取版本需要
    bash $0 get_version                                           获取最新版本

下载二进制文件
    bash $0 download_nerdctl                                      下载nerdctl
    bash $0 download_containerd                                   下载containerd
    bash $0 download_runc                                         下载runc
    bash $0 download_cni                                          下载cni
    bash $0 download_cri_tools                                    下载cri_tools
    bash $0 download_k8s                                          下载k8s
    bash $0 download_calico                                       下载calico yaml文件

保存镜像
    bash $0 save_k8s_image                                        保存k8s镜像
    bash $0 save_calico_image                                     下载calico镜像
    bash $0 save_lvscare_image                                    下载lvscare镜像

安装cri
    bash $0 install_nerdctl                                       安装nerdctl
    bash $0 install_containerd                                    安装containerd
    bash $0 install_runc                                          安装runc
    bash $0 install_cri_tools                                     安装cri_tools
安装k8s
    bash $0 init_system                                           初始化系统
    bash $0 install_cni                                           安装cni
    bash $0 install_k8s                                           安装k8s及其依赖,导入k8s镜像等
    bash $0 init_k8s                                              初始化k8s
    bash $0 install_calico                                        安装calico
    bash $0 join_master <token> <cert-hash> <certificate-key>     加入master节点
    bash $0 join_node   <token> <cert-hash>                       加入node节点
快速部署
    bash $0 install_all                                           一键安装k8s到本机
EOF
}

install_jq() {
  # jq_tag="$(curl https://api.github.com/repos/stedolan/jq/releases/latest | grep '  "tag_name": ' | awk -F'"' '{print $4}')"
  jq_tag="$(curl https://api.github.com/repos/jqlang/jq/releases/latest | grep '  "tag_name": ' | awk -F'"' '{print $4}')"
  # wget "https://github.com/stedolan/jq/releases/download/${jq_tag}/jq-linux-${platform}" -O "/usr/local/bin/jq"
  wget "https://github.com/jqlang/jq/releases/download/${jq_tag}/jq-linux-${platform}" -O "/usr/local/bin/jq"
  chmod +x /usr/local/bin/jq
}

get_version() {
  nerdctl_version="curl --retry 5 -sSL https://api.github.com/repos/containerd/nerdctl/releases/latest | jq -r '.tag_name' || exit 1"
  containerd_version="$(curl --retry 5 -sSL https://api.github.com/repos/containerd/containerd/releases/latest | jq -r '.tag_name' || exit 1)"
  runc_version="$(curl --retry 5 -sSL https://api.github.com/repos/opencontainers/runc/releases/latest | jq -r '.tag_name' || exit 1)"
  cni_version="$(curl --retry 5 -sSL https://api.github.com/repos/containernetworking/plugins/releases/latest | jq -r '.tag_name' || exit 1)"
  cri_tools_version="$(curl --retry 5 -sSL https://api.github.com/repos/kubernetes-sigs/cri-tools/releases/latest | jq -r '.tag_name' || exit 1)"
  kubernetes_version="$(curl --retry 5 -sSL https://dl.k8s.io/release/stable.txt || exit 1)"
  kubernetes_release_version="$(curl --retry 5 -sSL https://api.github.com/repos/kubernetes/release/releases/latest | jq -r '.tag_name' || exit 1)"
  calico_version="$(curl --retry 5 -sSL https://api.github.com/repos/projectcalico/calico/releases/latest | jq -r '.tag_name' || exit 1)"
  lvscare_version="$(curl --retry 5 -sSL https://api.github.com/repos/labring/lvscare/releases/latest | jq -r '.tag_name' || exit 1)"

  cat <<EOF | tee ${base_path}/releases
nerdctl_version=${nerdctl_version}
containerd_version=${containerd_version}
runc_version=${runc_version}
cni_version=${cni_version}
cri_tools_version=${cri_tools_version}
kubernetes_version=${kubernetes_version}
kubernetes_release_version=${kubernetes_release_version}
calico_version=$calico_version
lvscare_version=$lvscare_version
EOF
}

download_containerd() {
  file_name="cri-containerd-cni-${containerd_version:1}-linux-${platform}.tar.gz"
  if [ ! -f "${file_name}" ]; then
    wget https://github.com/containerd/containerd/releases/download/"${containerd_version}"/"${file_name}"{,.sha256sum}
  fi
  sha256sum --check "${file_name}.sha256sum" || echo "sha256sum --check ${file_name}.sha256sum 失败!" exit
}

download_runc() {
  file_name="runc.${platform}"
  if [ ! -f "${file_name}" ]; then
    wget https://github.com/opencontainers/runc/releases/download/"${runc_version}"/"${file_name}"
    wget https://github.com/opencontainers/runc/releases/download/"${runc_version}"/runc.sha256sum
  fi
  cat "runc.sha256sum" | grep "${file_name}" | sha256sum --check
}

download_nerdctl() {
  file_name="nerdctl-full-${nerdctl_version:1}-linux-${platform}.tar.gz"
  if [ ! -f "${file_name}" ]; then
    wget https://github.com/containerd/nerdctl/releases/download/${nerdctl_version}/"${file_name}"
    wget https://github.com/containerd/nerdctl/releases/download/${nerdctl_version}/SHA256SUMS -O "${file_name}.sha256sum"
  fi
  sha256sum --check "${file_name}.sha256sum" --ignore-missing || echo "sha256sum --check ${file_name}.sha256sum 失败!" exit
}

download_cni() {
  file_name="cni-plugins-linux-${platform}-${cni_version}.tgz"
  if [ ! -f "${file_name}" ]; then
    wget https://github.com/containernetworking/plugins/releases/download/"${cni_version}"/"${file_name}"{,.sha256}
  fi
  sha256sum --check "${file_name}.sha256" || echo "sha256sum --check ${file_name}.sha256sum 失败!" exit
}

download_cri_tools() {
  file_name="crictl-${cri_tools_version}-linux-${platform}.tar.gz"
  if [ ! -f "${file_name}" ]; then
    wget https://github.com/kubernetes-sigs/cri-tools/releases/download/"${cri_tools_version}"/"${file_name}"{,.sha256}
  fi
  echo "$(cat ${file_name}.sha256) ${file_name}" | sha256sum --check
  file_name="critest-${cri_tools_version}-linux-${platform}.tar.gz"
  if [ ! -f "${file_name}" ]; then
    wget https://github.com/kubernetes-sigs/cri-tools/releases/download/"${cri_tools_version}"/"${file_name}"{,.sha256}
  fi
  echo "$(cat ${file_name}.sha256) ${file_name}" | sha256sum --check || echo "sha256sum --check ${file_name}.sha256sum 失败!" exit
}

download_k8s() {
  file_name="kubeadm"
  if [ ! -f "${file_name}" ]; then
    wget https://storage.googleapis.com/kubernetes-release/release/${kubernetes_version}/bin/linux/${platform}/"${file_name}"{,.sha256}
    chmod +x $file_name
  fi
  echo "$(cat ${file_name}.sha256) ${file_name}" | sha256sum --check

  file_name="kubelet"
  if [ ! -f "${file_name}" ]; then
    wget https://storage.googleapis.com/kubernetes-release/release/${kubernetes_version}/bin/linux/${platform}/"${file_name}"{,.sha256}
    chmod +x $file_name
  fi
  echo "$(cat ${file_name}.sha256) ${file_name}" | sha256sum --check

  file_name="kubectl"
  if [ ! -f "${file_name}" ]; then
    wget https://storage.googleapis.com/kubernetes-release/release/${kubernetes_version}/bin/linux/${platform}/"${file_name}"{,.sha256}
    chmod +x $file_name
  fi
  echo "$(cat ${file_name}.sha256) ${file_name}" | sha256sum --check

  if [ -f /etc/debian_version ]; then
    if [ ! -f kubelet.service ]; then
      wget "https://raw.githubusercontent.com/kubernetes/release/${kubernetes_release_version}/cmd/kubepkg/templates/latest/deb/kubelet/lib/systemd/system/kubelet.service" || \
      wget https://raw.githubusercontent.com/kubernetes/release/master/cmd/krel/templates/latest/kubelet/kubelet.service
    fi
    if [ ! -f 10-kubeadm.conf ]; then
      wget "https://raw.githubusercontent.com/kubernetes/release/${kubernetes_release_version}/cmd/kubepkg/templates/latest/deb/kubeadm/10-kubeadm.conf" || \
      wget https://raw.githubusercontent.com/kubernetes/release/master/cmd/krel/templates/latest/kubeadm/10-kubeadm.conf
    fi

  elif [ -f /etc/redhat-release || -f /etc/kylin-release ]; then
    if [ ! -f kubelet.service ]; then
      wget "https://raw.githubusercontent.com/kubernetes/release/${kubernetes_release_version}/cmd/kubepkg/templates/latest/rpm/kubelet/kubelet.service" || \
      wget https://raw.githubusercontent.com/kubernetes/release/master/cmd/krel/templates/latest/kubelet/kubelet.service
    fi

    if [ ! -f 10-kubeadm.conf ]; then
      wget "https://raw.githubusercontent.com/kubernetes/release/${kubernetes_release_version}/cmd/kubepkg/templates/latest/rpm/kubeadm/10-kubeadm.conf" || \
      wget https://raw.githubusercontent.com/kubernetes/release/master/cmd/krel/templates/latest/kubeadm/10-kubeadm.conf
    fi
  else
    echo "当前操作系统未做适配!"
    exit 1
  fi
}

download_calico() {
  wget https://raw.githubusercontent.com/projectcalico/calico/${calico_version}/manifests/calico.yaml -O calico-${calico_version}.yaml
}

save_k8s_image() {
  if [ ! -f "k8s-${kubernetes_version}.tar" ]; then
    chmod +x kubeadm
    kubeadm="./kubeadm"
    ${kubeadm} config images pull
    ctr -n k8s.io images export "k8s-${kubernetes_version}.tar" $("${kubeadm}" config images list | tr '\n' ' ')
  fi
}

save_calico_image() {
  ctr -n k8s.io images pull docker.io/calico/kube-controllers:${calico_version}
  ctr -n k8s.io images pull docker.io/calico/cni:${calico_version}
  ctr -n k8s.io images pull docker.io/calico/node:${calico_version}
  ctr -n k8s.io images export calico-${calico_version}.tar docker.io/calico/kube-controllers:${calico_version} docker.io/calico/cni:${calico_version} docker.io/calico/node:${calico_version} 
}

save_lvscare_image() {
  ctr -n k8s.io images pull ghcr.io/labring/lvscare:${lvscare_version}
  ctr -n k8s.io images export lvscare-${lvscare_version}.tar ghcr.io/labring/lvscare:${lvscare_version}
}

install_nerdctl() {
  file_name="nerdctl-full-${nerdctl_version:1}-linux-${platform}.tar.gz"
  sha256sum --check "${file_name}.sha256sum" --ignore-missing || echo "sha256sum --check ${file_name}.sha256sum 失败!" exit
  tar Cxzvvf /usr/local ${file_name}
  mkdir -p /etc/containerd
  containerd config default > /etc/containerd/config.toml
  sandbox_image=$(${kubeadm} config images list  --kubernetes-version=${kubernetes_version} | grep pause)
  sed -i 's#SystemdCgroup = false#SystemdCgroup = true#g' /etc/containerd/config.toml
  sed -i "s@sandbox_image = .*@sandbox_image = \"${sandbox_image}\"@g" /etc/containerd/config.toml
  systemctl enable --now containerd.service
}

install_containerd() {
  file_name="cri-containerd-cni-${containerd_version:1}-linux-${platform}.tar.gz"
  sha256sum --check "${file_name}.sha256sum"
  tar -xf ${file_name} -C /
  mkdir -p /etc/containerd
  containerd config default > /etc/containerd/config.toml
  sandbox_image=$(${kubeadm} config images list  --kubernetes-version=${kubernetes_version} | grep pause)
  sed -i 's#SystemdCgroup = false#SystemdCgroup = true#g' /etc/containerd/config.toml
  sed -i "s@sandbox_image = .*@sandbox_image = \"${sandbox_image}\"@g" /etc/containerd/config.toml
  systemctl enable --now containerd.service
}

install_runc() {
  file_name="runc.${platform}"
  cat "runc.sha256sum" | grep "${file_name}" | sha256sum --check
  cp ${file_name} /usr/local/sbin/runc
  chmod +x /usr/local/sbin/runc
}

install_cni() {
  file_name="cni-plugins-linux-${platform}-${cni_version}.tgz"
  sha256sum --check "${file_name}.sha256"
  cni_dir=/opt/cni/bin
  mkdir -p ${cni_dir}
  tar -xf ${file_name} -C ${cni_dir}
  chmod +x ${cni_dir}/*
}

install_cri_tools() {
  file_name="crictl-${cri_tools_version}-linux-${platform}.tar.gz"
  echo "$(cat ${file_name}.sha256) ${file_name}" | sha256sum --check
  tar -xf ${file_name} -C /usr/local/bin
  file_name="critest-${cri_tools_version}-linux-${platform}.tar.gz"
  echo "$(cat ${file_name}.sha256) ${file_name}" | sha256sum --check
  tar -xf ${file_name} -C /usr/local/bin
  chmod +x /usr/local/bin/{crictl,critest}
  crictl config --set runtime-endpoint=unix:///run/containerd/containerd.sock
}


init_system() {
  cat /sys/fs/cgroup/cgroup.controllers >/dev/null 2>&1 || grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=1"
  cat <<EOF | tee /etc/modules-load.d/containerd.conf
overlay
br_netfilter
ip_vs
ip_vs_rr
ip_vs_wrr
ip_vs_sh
EOF
  modprobe overlay
  modprobe br_netfilter
  cat <<EOF | tee /etc/sysctl.d/99-kubernetes-cri.conf
net.bridge.bridge-nf-call-iptables  = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF
  sysctl --system
  if [ -f /etc/debian_version ]; then
    swapoff -a && sysctl -w vm.swappiness=0
    sed -i 's@^/dev/.*swap.*@# &@' /etc/fstab
    apt install -y conntrack ebtables iptables libip6tc2 libnetfilter-conntrack3 libnfnetlink0 socat bash-completion
  elif [ -f /etc/redhat-release ]; then
    swapoff -a && sysctl -w vm.swappiness=0
    sed -i 's@^/dev/.*swap.*@# &@' /etc/fstab
    if [ "$(getenforce)" == "Enforcing" ]; then
      setenforce 0
    fi
    sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
    systemctl disable --now firewalld
    yum install socat conntrack-tools bash-completion iproute-tc ipvsadm -y
  elif [ -f /etc/kylin-release ]; then
    swapoff -a && sysctl -w vm.swappiness=0
    sed -i 's@^/dev/.*swap.*@# &@' /etc/fstab
    if [ "$(getenforce)" == "Enforcing" ]; then
      setenforce 0
    fi
    sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
    systemctl disable --now firewalld
    yum install socat conntrack-tools bash-completion iproute-tc ipvsadm -y
  else
    echo "不支持的操作系统"
    #exit 1
  fi
}

install_k8s() {
  k8s_run_dir=/usr/local/bin
  mkdir -p ${k8s_run_dir}
  ls {kubeadm,kubelet,kubectl} && chmod +x {kubeadm,kubelet,kubectl}
  cp {kubeadm,kubelet,kubectl} ${k8s_run_dir}
  sed "s:/usr/bin:${k8s_run_dir}:g" kubelet.service | tee /etc/systemd/system/kubelet.service
  mkdir -p /etc/systemd/system/kubelet.service.d
  sed "s:/usr/bin:${k8s_run_dir}:g" 10-kubeadm.conf | tee /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
  mkdir -p /etc/bash_completion.d
  kubectl completion bash > /etc/bash_completion.d/kubectl
  source /etc/bash_completion.d/kubectl
  systemctl enable kubelet.service
  export KUBE_PROXY_MODE=ipvs
  ctr -n k8s.io images import --platform linux/${platform} "k8s-${kubernetes_version}.tar"
  ctr -n k8s.io images import --platform linux/${platform} "calico-${calico_version}.tar"
}

function init_k8s() {
  sed -i '/apiserver.cluster.local/d' /etc/hosts
  echo '127.0.0.1 apiserver.cluster.local' >> /etc/hosts
  kubeadm init --upload-certs \
  --node-name ${HOST_IP} \
  --config ${base_path}/kubeadm-config.yaml \
  | tee kubeadm-init.log
  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

  token=$(tail -n 2 kubeadm-init.log | grep "\--token" | awk '{print $(NF-1)}')
  hash=$(tail -n 2 kubeadm-init.log | grep "\--discovery-token-ca-cert-hash" | awk '{print $NF}')
  key=$(tail -n 10 kubeadm-init.log | grep "\--certificate-key" | awk '{print $NF}')
  echo -e "\e[38;5;46m\n\n使用提示 \e[0m"
  cat <<EOF
请在master2和master3节点上执行:

bash $0 join_master ${token} ${hash} ${key}

请在所有node节点上执行:

bash $0 join_node ${token} ${hash}

EOF
}

function install_calico() {
  kubectl apply -f "${base_path}/resources/calico-${calico_version}.yaml"
}

function join_master() {
  sed -i '/apiserver.cluster.local/d' /etc/hosts
  echo "$master1 apiserver.cluster.local" >> /etc/hosts
  kubeadm join apiserver.cluster.local:6443 --node-name ${HOST_IP} \
        --control-plane --apiserver-advertise-address ${HOST_IP} \
        --token $1 \
        --discovery-token-ca-cert-hash $2 \
        --certificate-key $3
  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config
  sed -i '/apiserver.cluster.local/d' /etc/hosts
  echo "127.0.0.1 apiserver.cluster.local" >> /etc/hosts
}

function join_node() {
  lvscare
  sed -i '/apiserver.cluster.local/d' /etc/hosts
  echo "$master1 apiserver.cluster.local" >> /etc/hosts
  kubeadm join apiserver.cluster.local:6443 --node-name ${HOST_IP} \
        --token $1 \
        --discovery-token-ca-cert-hash $2
  sed -i '/apiserver.cluster.local/d' /etc/hosts
  echo "$VIP apiserver.cluster.local" >> /etc/hosts
}
function lvscare() {
  ctr -n k8s.io images import "lvscare-${lvscare_version}.tar"
  mkdir -p /etc/kubernetes/manifests
  cat << EOF | tee /etc/kubernetes/manifests/lvscare.yaml
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    component: lvscare
    tier: control-plane
  name: lvscare
  namespace: kube-system
spec:
  containers:
  - args:
    - care
    - --vs
    - ${VIP}:6443
    - --health-path
    - /healthz
    - --health-schem
    - https
    - --rs
    - ${master1}:6443
    - --rs
    - ${master2}:6443
    - --rs
    - ${master3}:6443
    command:
    - /usr/bin/lvscare
    image: ghcr.io/labring/lvscare:${lvscare_version}
    imagePullPolicy: IfNotPresent
    name: lvscare
    resources: {}
    securityContext:
      privileged: true
    volumeMounts:
    - mountPath: /lib/modules
      name: lib-modules
      readOnly: true
  hostNetwork: true
  priorityClassName: system-cluster-critical
  volumes:
  - hostPath:
      path: /lib/modules
      type: ""
    name: lib-modules
status: {}
EOF
}


function install_all() {
  # install_nerdctl
  install_containerd
  install_runc
  install_cni
  install_cri_tools
  init_system
  install_k8s
  init_k8s
  kubectl taint node $HOST_IP node.kubernetes.io/not-ready:NoSchedule-
  kubectl taint node $HOST_IP node-role.kubernetes.io/control-plane:NoSchedule-
  install_calico
}


function main() {
  if [ ! -f "${base_path}/releases" ]; then
    get_version
  else
    . ${base_path}/releases
  fi 

  mkdir -p ${base_path}/resources
  cd ${base_path}/resources
  platform=$(uname -m)
  if [ $platform = aarch64 ]; then
      platform=arm64
  elif [ $platform = x86_64 ]; then
      platform=amd64
  else
      echo "当前的CPU架构为${platform},暂时还不支持!"
  fi
  kubeadm="${base_path}/resources/kubeadm"
  chmod +x $kubeadm
  case "$1" in
    (install_jq)
        install_jq
        ;;
    (get_version)
        get_version
        ;;
    (download_nerdctl)
        download_nerdctl
        ;;
    (download_containerd)
        download_containerd
        ;;
    (download_runc)
        download_runc
        ;;
    (download_cni)
        download_cni
        ;;
    (download_cri_tools)
        download_cri_tools
        ;;
    (download_k8s)
        download_k8s
        ;;
    (download_calico)
        download_calico
        ;;
    (save_k8s_image)
        save_k8s_image
        ;;
    (save_calico_image)
        save_calico_image
        ;;
    (save_lvscare_image)
        save_lvscare_image
        ;;
    (install_all)
        install_all
        ;;
    (install_nerdctl)
        install_nerdctl
        ;;
    (install_containerd)
        install_containerd
        ;;
    (install_runc)
        install_runc
        ;;
    (install_cni)
        install_cni
        ;;
    (install_cri_tools)
        install_cri_tools
        ;;
    (init_system)
        init_system
        ;;
    (install_k8s)
        install_k8s
        ;;
    (init_k8s)
        init_k8s
        ;;
    (install_calico)
        install_calico
        ;;
    (join_master)
        shift
        join_master $@
        ;;
    (join_node)
        shift
        join_node $@
        ;;
    (help)
        usage
        exit 0
        ;;
    (*)
        usage
        exit 0
        ;;
  esac
}

main $@

posted @ 2023-10-30 18:29  小维江湖  阅读(305)  评论(0编辑  收藏  举报