Linux:搭建K3s集群:修订间差异

来自WHY42
Riguz留言 | 贡献
无编辑摘要
Riguz留言 | 贡献
第11行: 第11行:


== Install K3s ==  
== Install K3s ==  
=== install master ===
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
multipass exec k3s-master -- bash -c "curl -sfL https://get.k3s.io | sh -"
multipass exec k3s-master -- bash -c "curl -sfL https://get.k3s.io | sh -"
# instead use shell:
# multipass shell k3s-master
</syntaxhighlight>
</syntaxhighlight>
<pre>
ubuntu@k3s-master:~$ curl -sfL https://get.k3s.io | sh -
[INFO]  Finding release for channel stable
[INFO]  Using v1.21.4+k3s1 as release
[INFO]  Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.21.4+k3s1/sha256sum-amd64.txt
[INFO]  Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.21.4+k3s1/k3s
[INFO]  Verifying binary download
[INFO]  Installing k3s to /usr/local/bin/k3s
[INFO]  Creating /usr/local/bin/kubectl symlink to k3s
[INFO]  Creating /usr/local/bin/crictl symlink to k3s
[INFO]  Creating /usr/local/bin/ctr symlink to k3s
[INFO]  Creating killall script /usr/local/bin/k3s-killall.sh
[INFO]  Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO]  env: Creating environment file /etc/systemd/system/k3s.service.env
[INFO]  systemd: Creating service file /etc/systemd/system/k3s.service
[INFO]  systemd: Enabling k3s unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
[INFO]  systemd: Starting k3s
</pre>
a token is stored in master:
<syntaxhighlight lang="java">
sudo cat /var/lib/rancher/k3s/server/node-token
K1022c02ad526cfd3d77039346d85e68a07849d907d99c1aef2108e63b60806c963::server:2f9f1afcb5e64d7150dab2b519598bc1
</syntaxhighlight>


[[Category:Linux/Unix]]
[[Category:Linux/Unix]]

2021年9月16日 (四) 00:48的版本

Prepare VMs by Multipass

multipass find
multipass launch -c 1 -m 1G -d 5G -n k3s-master 20.04
multipass launch -c 1 -m 2G -d 10G -n k3s-node01 20.04
multipass launch -c 1 -m 2G -d 10G -n k3s-node02 20.04

multipass list
multipass info k3s-node01

Install K3s

install master

multipass exec k3s-master -- bash -c "curl -sfL https://get.k3s.io | sh -"

# instead use shell:
# multipass shell k3s-master
ubuntu@k3s-master:~$ curl -sfL https://get.k3s.io | sh -
[INFO]  Finding release for channel stable
[INFO]  Using v1.21.4+k3s1 as release
[INFO]  Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.21.4+k3s1/sha256sum-amd64.txt
[INFO]  Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.21.4+k3s1/k3s
[INFO]  Verifying binary download
[INFO]  Installing k3s to /usr/local/bin/k3s
[INFO]  Creating /usr/local/bin/kubectl symlink to k3s
[INFO]  Creating /usr/local/bin/crictl symlink to k3s
[INFO]  Creating /usr/local/bin/ctr symlink to k3s
[INFO]  Creating killall script /usr/local/bin/k3s-killall.sh
[INFO]  Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO]  env: Creating environment file /etc/systemd/system/k3s.service.env
[INFO]  systemd: Creating service file /etc/systemd/system/k3s.service
[INFO]  systemd: Enabling k3s unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
[INFO]  systemd: Starting k3s

a token is stored in master:

sudo cat /var/lib/rancher/k3s/server/node-token
K1022c02ad526cfd3d77039346d85e68a07849d907d99c1aef2108e63b60806c963::server:2f9f1afcb5e64d7150dab2b519598bc1