📅  最后修改于: 2023-12-03 15:37:44.226000             🧑  作者: Mango
如果您对 Traefik 不感兴趣,或者只是希望通过其他方式与 K3s 一起工作,那么此文可能适合您。在此篇文章中,我们将介绍如何在没有 Traefik 的情况下安装 K3s。
在开始操作之前,需要先确保您已经完成以下准备工作:
IP
支持HostNetwork
模式(k3s默认开启)1.下载 K3s
curl -sfL https://get.k3s.io | sh -
该脚本将自动下载最新版本的 K3s,并将其安装在您的系统上。
2.等待安装完成
稍等一下,等待 K3s 安装完成,安装完成后,您应该会看到如下输出:
[INFO] Successfully installed kubernetes-cni, kubelet and kubectl
[INFO] Installing crictl v1.11.1...
[INFO] Creating /etc/rancher/k3s and /var/lib/rancher/k3s/data directories
[INFO] Creating /var/lib/rancher/k3s/server/db directory
[INFO] Creating /var/lib/rancher/k3s/server/services directory
[INFO] Creating /var/lib/rancher/k3s/server/tmp directory
[INFO] Creating /var/lib/rancher/k3s/server/manifests directory
[INFO] Creating /var/lib/rancher/k3s/client directory
[INFO] Creating /var/lib/rancher/k3s/client/tmp directory
[INFO] Creating /var/lib/rancher/k3s/client/data directory
[INFO] Creating /var/lib/rancher/k3s/client/dispach directory
[INFO] Creating /var/lib/rancher/k3s/client/dispach/env directory
[INFO] Creating /var/lib/rancher/k3s/client/dispach/hooks directory
[INFO] Creating /var/lib/rancher/k3s/client/dispach/mounts directory
[INFO] Creating /var/lib/rancher/k3s/client/dispach/secrets directory
[INFO] Creating /var/lib/rancher/k3s/client/dispach/volumes directory
[INFO] Creating /var/lib/rancher/k3s/client/dispach/bind directory
[INFO] Creating /var/lib/rancher/k3s/client/dispach/paths directory
[INFO] Creating /var/lib/rancher/k3s/client/dispach/states directory
[INFO] Creating /var/lib/rancher/k3s/server/env.yaml
[INFO] Creating /var/lib/rancher/k3s/server/services/kubelet.yaml
[INFO] Creating /etc/systemd/system/k3s.service
[INFO] env: Creating environment file /etc/rancher/k3s/env
[INFO] systemd: Starting k3s
3.检查 Kubernetes 配置
安装 K3s 后,可以检查运行中的 Kubernetes 配置以确保一切运行正常。您可以使用以下命令检查 Kubernetes 状态:
kubectl get nodes
如果您看到类似于以下输出的内容,则表示一切正常:
NAME STATUS ROLES AGE VERSION
<node-name> Ready control-plane,master 3s v1.21.3+k3s1
到这里,就完成了在没有 Traefik 的情况下安装 K3s 的操作步骤。
K3s 提供了许多适用于不同场景的灵活选项,其中之一是 Traefik。但是,在某些情况下,Traefik 可能不是最好的选择。现在,您已经学会了如何在没有 Traefik 的情况下安装 K3s,这使得人们能够根据自己的需要自由选择最适合的选项。