技术交流QQ群:①185473046   ②190706903   ③203744115   网站地图
登录

下次自动登录
现在的位置: 首页Linux>正文
centos7 安装rancher的k8s 客户端
2021年02月07日 Linux 暂无评论 ⁄ 被围观 3,517次+

Centos 7 kubectl 客户端连接rancher里面的k8s

1 centos7 安装最新版本的kubectl

脚本如下:install_kubectl.sh

#!/bin/bash

# make sunny sunnylinux@foxmail.com

cat <<EOF > /etc/yum.repos.d/kubernetes.repo

[kubernetes]

name=Kubernetes

baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64

enabled=1

gpgcheck=1

repo_gpgcheck=1

gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg

EOF

sleep 5

yum install -y kubectl kubelet kubeadm

systemctl enable kubelet

systemctl start kubelet

2 获取rancher上面的k8s集群的config文件

进入rancherk8s集群页面:

点击右上角的Kubeconfig文件复制保存

在客户端的主机上面新建文kube的文件夹

[root@localhost ~]# mkdir -p /root/.kube/

root@localhost ~]# cd /root/.kube/

把刚才复制保存的config文件放到下面对应的路径下

[root@localhost ~]# vi config

[root@localhost .kube]# ls

cache  config

[root@localhost .kube]#

执行kubectl get nodes

[root@localhost .kube]# kubectl get nodes

NAME    STATUS   ROLES                      AGE    VERSION

node3   Ready    controlplane,etcd,worker   189d   v1.17.4

node4   Ready    controlplane,etcd,worker   189d   v1.17.4

Centos7 建立k8s客户端完成

     

  系统运维技术交流QQ群:①185473046 系统运维技术交流□Ⅰ ②190706903 系统运维技术交流™Ⅱ ③203744115 系统运维技术交流™Ⅲ

给我留言

您必须 [ 登录 ] 才能发表留言!



Copyright© 2011-2024 系统运维 All rights reserved
版权声明:本站所有文章均为作者原创内容,如需转载,请注明出处及原文链接
陕ICP备11001040号-3