正常安装

KLTS 提供了基于 deb 和 rpm 软件源的安装方式,您可以选择适合的安装方式。

安装前请确认已经完成了准备工作。

设置 KLTS 软件源

执行以下代码设置下载 KLTS 的软件源:

VERSION=1.18.20-lts.2
cat << EOF > /etc/yum.repos.d/klts.repo
[klts]
name=klts
baseurl=https://raw.githubusercontent.com/klts-io/kubernetes-lts/rpm-v${VERSION}/\$basearch/
enabled=1
gpgcheck=0
[klts-other]
name=klts-others
baseurl=https://raw.githubusercontent.com/klts-io/others/rpm/\$basearch/
enabled=1
gpgcheck=0
EOF

yum makecache

执行以下代码设置下载 KLTS 的软件源:

VERSION=1.18.20-lts.2
cat << EOF > /etc/apt/sources.list.d/klts.list
deb [trusted=yes] https://raw.githubusercontent.com/klts-io/kubernetes-lts/deb-v${VERSION} stable main
deb [trusted=yes] https://raw.githubusercontent.com/klts-io/others/deb stable main
EOF

apt-get update

说明:以下加速均来自第三方, 安全和稳定性不做保障, 仅建议测试环境使用 ❗️❗️❗️

执行以下代码设置下载 KLTS 的软件源:

curl https://raw.githubusercontent.com/wzshiming/github-hosts/master/hosts >>/etc/hosts

VERSION=1.18.20-lts.2
cat << EOF > /etc/yum.repos.d/klts.repo
[klts]
name=klts
baseurl=https://raw.githubusercontent.com/klts-io/kubernetes-lts/rpm-v${VERSION}/\$basearch/
enabled=1
gpgcheck=0
[klts-other]
name=klts-others
baseurl=https://raw.githubusercontent.com/klts-io/others/rpm/\$basearch/
enabled=1
gpgcheck=0
EOF

yum makecache

VERSION=1.18.20-lts.2
cat << EOF > /etc/yum.repos.d/klts.repo
[klts]
name=klts
baseurl=https://hub.fastgit.org/klts-io/kubernetes-lts/raw/rpm-v${VERSION}/\$basearch/
enabled=1
gpgcheck=0
[klts-other]
name=klts-others
baseurl=https://hub.fastgit.org/klts-io/others/raw/rpm/\$basearch/
enabled=1
gpgcheck=0
EOF

yum makecache

VERSION=1.18.20-lts.2
cat << EOF > /etc/yum.repos.d/klts.repo
[klts]
name=klts
baseurl=https://ghproxy.com/https://raw.githubusercontent.com/klts-io/kubernetes-lts/rpm-v${VERSION}/\$basearch/
enabled=1
gpgcheck=0
[klts-other]
name=klts-others
baseurl=https://ghproxy.com/https://raw.githubusercontent.com/klts-io/others/rpm/\$basearch/
enabled=1
gpgcheck=0
EOF

yum makecache

VERSION=1.18.20-lts.2
cat << EOF > /etc/yum.repos.d/klts.repo
[klts]
name=klts
baseurl=https://raw.githubusercontents.com/klts-io/kubernetes-lts/rpm-v${VERSION}/\$basearch/
enabled=1
gpgcheck=0
[klts-other]
name=klts-others
baseurl=https://raw.githubusercontents.com/klts-io/others/rpm/\$basearch/
enabled=1
gpgcheck=0
EOF

yum makecache

VERSION=1.18.20-lts.2
cat << EOF > /etc/yum.repos.d/klts.repo
[klts]
name=klts
baseurl=https://raw.staticdn.net/klts-io/kubernetes-lts/rpm-v${VERSION}/\$basearch/
enabled=1
gpgcheck=0
[klts-other]
name=klts-others
baseurl=https://raw.staticdn.net/klts-io/others/rpm/\$basearch/
enabled=1
gpgcheck=0
EOF

yum makecache

说明:以下加速均来自第三方, 安全和稳定性不做保障, 仅建议测试环境使用 ❗️❗️❗️

执行以下代码设置下载 KLTS 的软件源:

curl https://raw.githubusercontent.com/wzshiming/github-hosts/master/hosts >>/etc/hosts

VERSION=1.18.20-lts.2
cat << EOF > /etc/apt/sources.list.d/klts.list
deb [trusted=yes] https://raw.githubusercontent.com/klts-io/kubernetes-lts/deb-v${VERSION} stable main
deb [trusted=yes] https://raw.githubusercontent.com/klts-io/others/deb stable main
EOF

apt-get update

VERSION=1.18.20-lts.2
cat << EOF > /etc/apt/sources.list.d/klts.list
deb [trusted=yes] https://hub.fastgit.org/klts-io/kubernetes-lts/raw/deb-v${VERSION} stable main
deb [trusted=yes] https://hub.fastgit.org/klts-io/others/raw/deb stable main
EOF

apt-get update

VERSION=1.18.20-lts.2
cat << EOF > /etc/apt/sources.list.d/klts.list
deb [trusted=yes] https://ghproxy.com/https://raw.githubusercontent.com/klts-io/kubernetes-lts/deb-v${VERSION} stable main
deb [trusted=yes] https://ghproxy.com/https://raw.githubusercontent.com/klts-io/others/deb stable main
EOF

apt-get update

VERSION=1.18.20-lts.2
cat << EOF > /etc/apt/sources.list.d/klts.list
deb [trusted=yes] https://raw.githubusercontents.com/klts-io/kubernetes-lts/deb-v${VERSION} stable main
deb [trusted=yes] https://raw.githubusercontents.com/klts-io/others/deb stable main
EOF

apt-get update

VERSION=1.18.20-lts.2
cat << EOF > /etc/apt/sources.list.d/klts.list
deb [trusted=yes] https://raw.staticdn.net/klts-io/kubernetes-lts/deb-v${VERSION} stable main
deb [trusted=yes] https://raw.staticdn.net/klts-io/kubernetes-lts/deb stable main
EOF

apt-get update

安装

执行以下命令安装:

yum install kubeadm kubelet kubectl

执行以下命令安装:

apt-get install kubeadm kubelet kubectl

开机自动启动 Kubelet

执行以下命令开机自动启动 Kubelet:

systemctl enable kubelet

拉取依赖镜像

执行以下命令 pull 依赖的镜像:

VERSION=1.18.20-lts.2
REPOS=ghcr.io/klts-io/kubernetes-lts
kubeadm config images pull --image-repository ${REPOS} --kubernetes-version v${VERSION}

执行以下命令 pull 依赖的镜像:

VERSION=1.18.20-lts.2
REPOS=ghcr.m.daocloud.io/klts-io/kubernetes-lts
kubeadm config images pull --image-repository ${REPOS} --kubernetes-version v${VERSION}

后续对 kubeadm 的操作都需要加上 --image-repository--kubernetes-version 以主动指定镜像。

初始化控制面节点

执行以下命令初始化控制面的节点:

VERSION=1.18.20-lts.2
REPOS=ghcr.io/klts-io/kubernetes-lts
kubeadm init --image-repository ${REPOS} --kubernetes-version v${VERSION}

执行以下命令初始化控制面的节点:

VERSION=1.18.20-lts.2
REPOS=ghcr.m.daocloud.io/klts-io/kubernetes-lts
kubeadm init --image-repository ${REPOS} --kubernetes-version v${VERSION}

有关更多安装说明,请参阅 Kubernetes 操作指南


最后修改 2022.03.22 : Add others source (5b676715)