8
Rancher-2.2.2学习笔记-rancher-cli的使用 |坐而言不如起而行! 二丫讲梵
source link: http://www.eryajf.net/2734.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Rancher-2.2.2学习笔记-rancher-cli的使用 |坐而言不如起而行! 二丫讲梵
本文预计阅读时间 9 分钟
Rancher CLI
是一个统一的工具,可用于与Rancher进行交互。借助于此工具,我们可以使用命令行来操作Rancher并管理其下的资源。
- 1、下载rancher-cli工具
可以通过官方的文件下载页面进行下载,也可以直接在首页右下角的下载cli进行下载,这里直接通过命令方式进行下载。
[root@jenkins ~]$ wget https://releases.rancher.com/cli2/v2.2.0/rancher-linux-amd64-v2.2.0.tar.gz
[root@jenkins ~]$ tar xf rancher-linux-amd64-v2.2.0.tar.gz
- 2、配置进系统中
mv rancher-v2.2.0/rancher /usr/bin/rancher
rm -rf rancher-v2.2.0/
- 3、测试登录
新建用户获取tonken:
创建一个永不过期的token,以用于验证使用。
使用如下命令进行登陆:
[root@jenkins ~]$ rancher login https://rancher.com/v3 --token token-fkgj6:gd2z99wnfgc2zw9pw969rppgbnrfwg7l59l4gccqp5wmdc6vd27r5l
注意
:这里测试的主机需要能够访问rancher.com
,如果都在内网环境中,那么可以直接把域名对应解析写入到主机hosts
中。
注意,还需要安装kubectl命令,否则执行相关操作时会报如下错误:
FATA[0000] kubectl is required to be set in your path to use this command. See https://kubernetes.io/docs/tasks/tools/install-kubectl/ for more info. Error: exec: "kubectl": executable file not found in $PATH
随便执行一下命令验证一下。
[root@jenkins ~]$ rancher kubectl get node
NAME STATUS ROLES AGE VERSION
192.168.106.3 Ready controlplane,etcd,worker 32m v1.11.6
192.168.106.4 Ready controlplane,etcd,worker 32m v1.11.6
192.168.106.5 Ready controlplane,etcd,worker 32m v1.11.6
借此机会来个安装应用的定妆照!
[root@jenkins ~]$rancher kubectl get pod --all-namespaces
NAMESPACE NAME READY STATUS RESTARTSAGE
cattle-system cattle-cluster-agent-5c9d5cbb87-nlf8x 1/1 Running 016m
cattle-system cattle-node-agent-6ncnb 1/1 Running 016m
cattle-system cattle-node-agent-cdpww 1/1 Running 016m
cattle-system cattle-node-agent-l48m8 1/1 Running 016m
cattle-system rancher-bdf49fb9-7qhgp 1/1 Running 131m
cattle-system rancher-bdf49fb9-hf6tm 1/1 Running 031m
cattle-system rancher-bdf49fb9-xmbv7 1/1 Running 131m
ingress-nginx default-http-backend-797c5bc547-nnqzt 1/1 Running 034m
ingress-nginx nginx-ingress-controller-mn9jl 1/1 Running 034m
ingress-nginx nginx-ingress-controller-rrm8z 1/1 Running 034m
ingress-nginx nginx-ingress-controller-vt8lx 1/1 Running 034m
kube-system canal-9r7jt 3/3 Running 034m
kube-system canal-b86n6 3/3 Running 034m
kube-system canal-lqk8g 3/3 Running 034m
kube-system cert-manager-cert-manager-8f55cc84b-z84kw 2/2 Running 031m
kube-system kube-dns-7588d5b5f5-dnqk7 3/3 Running 034m
kube-system kube-dns-autoscaler-5db9bbb766-cfqcg 1/1 Running 034m
kube-system metrics-server-97bc649d5-lkn57 1/1 Running 034m
kube-system rke-ingress-controller-deploy-job-s5ss8 0/1 Completed 034m
kube-system rke-kubedns-addon-deploy-job-p2hjb 0/1 Completed 034m
kube-system rke-metrics-addon-deploy-job-fqvfm 0/1 Completed 034m
kube-system rke-network-plugin-deploy-job-7zr8v 0/1 Completed 034m
kube-system tiller-deploy-8cb5b5f5c-qzk5z 1/1 Running 032m
OK,看到能够这样执行命令,就可以了,后边的流水线工作就不用发愁了。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK