今天在Kubernetes的从节点上运行命令【kubectl】出现了如下错误:

[root@k8snode1 kubernetes]# kubectl get pod The connection to the server localhost:8080 was refused - did you specify the right host or port?

出现这个问题的原因是kubectl命令需要使用kubernetes-admin来运行,解决方法如下,将主节点中的【/etc/kubernetes/admin.conf】文件拷贝到从节点相同目录下,然后如提示配置环境变量:

Your Kubernetes control-plane has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
也可以简单方法

echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile

source ~/.bash_profile
接着再运行kubectl命令就OK了

[root@172-19-102-78 ~]# kubectl get cs
NAME STATUS MESSAGE ERROR
scheduler Healthy ok
controller-manager Healthy ok
etcd-0 Healthy {"health":"true"}

Kubernetes-kubectl The connection to the server localhost:8080 was refused -did you specify的更多相关文章

  1. 使用二进制方式安装K8S时使用kubectl命令报错:The connection to the server localhost:8080 was refused - did you specify the right host or port?

    解决思路: kubectl 默认从 ~/.kube/config 配置文件获取访问 kube-apiserver 地址.证书.用户名等信息,如果没有配置该文件,或者该文件个别参数配置出错,执行命令时出 ...

  2. The connection to the server localhost:8080 was refused - did you specify the right host or port?

    The connection to the server localhost:8080 was refused - did you specify the right host or port? 解决 ...

  3. kubectl error: The connection to the server localhost:8080 was refused

    did you run below commands after kubeadm init To start using your cluster, you need to run (as a reg ...

  4. 【Kubernetes】The connection to the server <master>:6443 was refused - did you specify the right host or port?

    不知道怎么用着用着,使用kubectl 时报错,错误如下: root@R740--:~# kubectl get pod The connection to the server 107.105.13 ...

  5. k8s节点执行master命令报错 localhost:8080 was refused

    首先是按照二进制方式安装的k8s. [root@ht22 calico]# cat /etc/redhat-release CentOS Linux release 7.9.2009 (Core) [ ...

  6. k8s遇坑:The connection to the server k8s-api.virtual.local:6443 was refused - did you specify the right host or port?

    k8s坑The connection to the server localhost:8080 was refused - did you specify the right host or port ...

  7. 【kubernetes】kubectl logs connection refused

    因为启动dashboard报CrashLoopBackOff错误,尝试使用logs去查看日志,结果报错,错误如下: [root@localhost ~]# kubectl -s http://192. ...

  8. [nginx] connect() failed (111: Connection refused) while connecting to upstream, client: 101.18.123.107, server: localhost,

    nginx一直报错, 2016/12/02 10:23:19 [error] 1472#0: *31 connect() failed (111: Connection refused)while c ...

  9. 快速解决mysql Lost connection to MySQL server at 'reading initial communication packet及can't connect to mysql server on 'localhost'

    今天在使用Navicat连一个远程mysql时,总是提示连接不成功,提示Lost connection to MySQL server at 'reading initial communicatio ...

随机推荐

  1. JavaScript教程——对象的继承

    面向对象编程很重要的一个方面,就是对象的继承.A 对象通过继承 B 对象,就能直接拥有 B 对象的所有属性和方法.这对于代码的复用是非常有用的. 大部分面向对象的编程语言,都是通过“类”(class) ...

  2. Hbuilder 开发微信小程序的代码高亮

    一.点击“工具”-“选项”-搜索“文件关联” 二.点击“添加”文件类型,点击确定 三.在相关联的编辑器中点击“添加”按钮,选择CSS Editor,点击确定,重新打开 *.wxss 类型的文件即可 其 ...

  3. C# Transaction 事务处理 -依赖事务

    在DependentTransaction()方法中,实例化CommittableTransaction类,创建一个根事务,显示事务的信息.接着, tx.DependentClone()方法创建一个依 ...

  4. TabSheet源码

    TabSheet.h #if !defined(AFX_TABSHEET_H__42EE262D_D15F_46D5_8F26_28FD049E99F4__INCLUDED_) #define AFX ...

  5. JavaScript实现 简易 堆

    有两个原始操作用于保证插入或删除节点以后堆是一个有效的最大堆或者最小堆: shiftUp(): 如果一个节点比它的父节点大(最大堆)或者小(最小堆),那么需要将它同父节点交换位置.这样是这个节点在数组 ...

  6. DP(第一版)

    序 任何一种具有递推或者递归形式的计算过程,都叫做动态规划 如果你一开始学的时候就不会DP,那么你在考试的时候就一定不会想到用动态规划! 需要进行掌握的内容 1)DP中的基本概念 2)状态 3)转移方 ...

  7. 解决xftp远程连接后出现中文乱码

  8. HDU 4496 D-City —— (并查集的应用)

    给出n个点和m条边,一条一条地删除边,问每次删除以后有多少个联通块. 分析:其实就是并查集的应用,只是前一阵子一直做图论思路一直囿于tarjan了..方法就是,记录每一条边,然后从最后一条边开始不断的 ...

  9. 年视图,选择月份 ---bootstrap datepicker

    $.fn.datepicker.dates['cn'] = { //切换为中文显示 days: ["周日", "周一", "周二", &qu ...

  10. 实现多列等高布局_flex布局

    详情参见此篇博客 http://www.w3cplus.com/css/creaet-equal-height-columns 建议掌握方法四.五 其实,利用最新的flex布局 http://www. ...