k8s 集群 The connection to the server localhost:8080 was refused - did you specify the right host or port?

wuming@master kubernetes]$ sudo kubectl get nodes
出现 The connection to the server localhost:8080 was refused - did you specify the right host or port?

1.echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> profile

  1. 执行 export KUBECONFIG=/etc/kubernetes/admin.conf这个文件下根本没有admin.conf

  2. Run these commands solved this issue:
    mkdir -p $HOME/.kube
    sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
    sudo chown $(id -u):$(id -g) $HOME/.kube/config
    这个还没有尝试

  3. 启动顺序不对
    systemctl start etcd
    systemctl start docker
    systemctl start kube-apiserver
    systemctl start kube-controller-manager
    systemctl start kube-scheduler
    systemctl start kubelet
    systemctl start kube-proxy

    5.copy /root 下的admin.conf 到 work 也是export 环境变量

    请问大佬这个如何解决,为何我的admin.conf 没有

首先将8080端口开放出来再试一下。

创建一个配置文件,配置文件里面指定8080端口,再不行检查防火墙设置