> 文章列表 > 安装k3s

安装k3s

安装k3s

k3s官方文档
architecture
quick start

概述:k3s一个轻量级的kubernetes,因资源消耗知识kubernetes的一半,故取名k3s
k3s的node分为 server node 和agent node:
  • server node: 可以运行kubectl等命令,且包含 agent node的功能。
  • agent node: 主要负责运行k8s资源
k3s高可用版的安装与卸载

HA cluster with mysql embedded etcd
HA cluster with mysql

install first server:
embedded etcd版

curl -sfL https://rancher-mirror.oss-cn-beijing.aliyuncs.com/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn K3S_KUBECONFIG_MODE="644" K3S_NODE_NAME=server-1 K3S_TOKEN=123123 sh -s - server --cluster-init

mysql版

curl -sfL https://rancher-mirror.oss-cn-beijing.aliyuncs.com/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn K3S_KUBECONFIG_MODE="644" K3S_NODE_NAME=server-1 K3S_TOKEN=123123 sh -s - server --datastore-endpoint="mysql://root:123456@tcp(10.10.21.28:30306)/k3s"

check token in first server node:
这个token在之后加入server node or agent node都需要使用到,以及备份数据恢复数据都会用到,所以最好是保存起来。
运行命令: sudo cat /var/lib/rancher/k3s/server/token
在这里插入图片描述
install second server:
embedded etcd版

curl -sfL https://rancher-mirror.oss-cn-beijing.aliyuncs.com/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn K3S_KUBECONFIG_MODE="644" K3S_NODE_NAME=server-2 K3S_TOKEN=K10b6152041c17c634d1f6eb2a794e7e32c2592ed4f12162a69ff96ce04662c1296::server:123123 sh -s - server --server https://10.10.21.153:6443

mysql版

curl -sfL https://rancher-mirror.oss-cn-beijing.aliyuncs.com/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn K3S_KUBECONFIG_MODE="644" K3S_NODE_NAME=server-2 K3S_TOKEN=K103437447c4f2dd7564a99e5f5fb39a47a6ef87c3d118a2777ca6fccbc8e414ed4::server:123123 sh -s - server --datastore-endpoint="mysql://root:123456@tcp(10.10.21.28:30306)/k3s"

install agent node:

curl -sfL https://get.k3s.io | K3S_URL=https://myserver:6443 K3S_TOKEN=mynodetoken sh -

uninstall server node:

/usr/local/bin/k3s-uninstall.sh

uninstall agent node:

/usr/local/bin/k3s-agent-uninstall.sh