通过命令行(RancherCLI kubectl)远程调用实现 远程管理 Rancher 的功能

Rancher CLI 安装
官网地址:https://www.cnrancher.com/docs/rancher/v2.x/cn/configuration/cli/
# 简化命令如下
 wget https://releases.rancher.com/cli2/v2.2.0/rancher-linux-amd64-v2.2.0.tar.gz
 tar xf rancher-linux-amd64-v2.2.0.tar.gz
 mv rancher-v2.2.0/rancher /usr/bin/rancher
 chmod +x /usr/bin/rancher
# 使用以下命令登录 替换<BEARER_TOKEN>和<SERVER_URL>
./rancher login https://<SERVER_URL> --token <BEARER_TOKEN>
kubectl 安装
# 简化命令如下
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl

chmod +x ./kubectl
sudo mv ./kubectl /usr/bin/kubectl
kubectl version

操作步骤:


rancher login https://192.168.61.95/v3 --token token-92d5c:5fdsfm4qcp956h67npzsqj7zp4kzsldp85zrpvf259g8zhmg7jgzwg --skip-verify
[root@localhost ~]# rancher kubectl get node
NAME           STATUS   ROLES                      AGE    VERSION
localhost      Ready    controlplane,etcd,worker   349d   v1.16.9
worker-node1   Ready    controlplane,etcd,worker   329d   v1.16.9
posted @ 2021-04-21 09:53  一毛丶丶  阅读(643)  评论(0编辑  收藏  举报