Kuberneteres、K3S使用技巧
K3S(Linux一键部署)
主 Master
curl -sfL https://get.k3s.io | sh -国内加速
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn INSTALL_K3S_EXEC="server --flannel-backend none" K3S_TOKEN=12345 sh -从 Agent 节点 请使用 K3S_URL 和 K3S_TOKEN 环境变量运行安装脚本
curl -sfL https://get.k3s.io | K3S_URL=https://myserver:6443 K3S_TOKEN=mynodetoken sh -国内加速
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn K3S_URL=https://myserver:6443 K3S_TOKEN=mynodetoken sh -或
export K3S_TOKEN="你的Token"
export K3S_URL="https://<你的Master主机IP>:6443"
curl -sfL https://cdn.rancher.cn/k3s/k3s-install.sh | sh -卸载K3S
sh /usr/local/bin/k3s-uninstall.sh!!!每台主机必须具有唯一的主机名。如果你的计算机没有唯一的主机名,请传递 K3S_NODE_NAME 环境变量,并为每个节点提供一个有效且唯一的主机名。
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="server" sh -s - --flannel-backend none --token 12345
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="server --flannel-backend none" K3S_TOKEN=12345 sh -s -
curl -sfL https://get.k3s.io | K3S_TOKEN=12345 sh -s - server --flannel-backend none
# server is assumed below because there is no K3S_URL
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--flannel-backend none --token 12345" sh -s -
curl -sfL https://get.k3s.io | sh -s - --flannel-backend none --token 12345curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="agent --server https://k3s.example.com --token mypassword" sh -s -
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="agent" K3S_TOKEN="mypassword" sh -s - --server https://k3s.example.com
curl -sfL https://get.k3s.io | K3S_URL=https://k3s.example.com sh -s - agent --token mypassword
curl -sfL https://get.k3s.io | K3S_URL=https://k3s.example.com K3S_TOKEN=mypassword sh -s - # agent is assumed because of K3S_URLMaster获取全部节点信息
kubectl get nodes -o wideMaster获取Token
cat /var/lib/rancher/k3s/server/node-tokenK3s(OpenWrt部署二进制部署 需要cgroup)
# 从Github下载
LATEST_RELEASE=$(curl -sL -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/k3s-io/k3s/releases/latest" | grep -o '"tag_name": *"[^"]*"' | cut -d'"' -f4); ARCH=$(uname -m); FILE="k3s"; [ "$ARCH" = "aarch64" ] && FILE="k3s-arm64"; [ "$ARCH" = "armv7l" ] && FILE="k3s-armhf"; curl -sfL "https://github.com/k3s-io/k3s/releases/download/${LATEST_RELEASE}/${FILE}" -o /usr/bin/k3s && chmod +x /usr/bin/k3s
# 国内镜像加速下载
GH=https://gh-proxy.org
LATEST_RELEASE=$(curl -sL -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/k3s-io/k3s/releases/latest" | grep -o '"tag_name": *"[^"]*"' | cut -d'"' -f4); ARCH=$(uname -m); FILE="k3s"; [ "$ARCH" = "aarch64" ] && FILE="k3s-arm64"; [ "$ARCH" = "armv7l" ] && FILE="k3s-armhf"; curl -sfL "$GH/https://github.com/k3s-io/k3s/releases/download/${LATEST_RELEASE}/${FILE}" -o /usr/bin/k3s && chmod +x /usr/bin/k3s# 运行k3s集群 Docker 运行时
k3s server --disable traefik --disable metrics-server --disable servicelb --https-listen-port 6443 --docker &
# k3s集群状态
k3s kubectl cluster-info
# 查看节点
k3s kubectl get node
# 查看所有pod(pod可以理解成docker的容器)
k3s kubectl get pod -A
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果