K3s安装

前情提要

操作系统最好一致、纯净,推荐debian12。主机名称不要设置一样。可使用下面脚本先将集群主机全部更改一遍主机名称

bash <(wget -qO- -o- https://raw.githubusercontent.com/htazq/Auto/main/change_hostname.sh)

安装k3s

海外服务器执行

curl -sfL https://get.k3s.io | sh -

大陆服务器命令

curl -sfL https://get.k3s.io | INSTALL_K3S_MIRROR=cn sh -

等待完成,观察机器资源负载,明显小下来后创建软连接

创建软连接

ln -s /etc/rancher/k3s/k3s.yaml ~/.kube/config

查看node机器对接token

cat /var/lib/rancher/k3s/server/agent-token

复制token,记录下来,在node机器上会用到

海外服务器

curl -sfL https://get.k3s.io | K3S_URL=https://1.1.1.1:6443 K3S_TOKEN=K102fe2593954a710b38f58c5e3e00708f7eb35124f378c7de0d6974cd494b559fa::server:e53e4596baa6f5eb142c916f89900477 sh -

中国大陆服务器

curl -sfL https://get.k3s.io | INSTALL_K3S_MIRROR=cn K3S_URL=https://1.1.1.1:6443 K3S_TOKEN=K102fe2593954a710b38f58c5e3e00708f7eb35124f378c7de0d6974cd494b559fa::server:e53e4596baa6f5eb142c916f89900477 sh -

将以上K3S_URL和K3S_TOKEN都换成你的即可。

kubectl get nodes 

安装helm

bash <(curl -s -L https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3)
helm list -A

会出现traefik和traefik-crd,这是K3s默认带的

helm repo add bitnami https://charts.bitnami.com/bitnami
helm search repo brigade