[K8S:安装异常]:Kubectl执行显示Config not found: /etc/kubernetes/admin.conf
Config not found: /etc/kubernetes/admin.confThe connection to the server localhost:8080 was refused - did you specify the right host or port?
·
1:异常信息
kubectl get pods -n kube-system
sudo kubeadm upgrade apply --force
[root@master ~]# kubectl get pods -n kube-system
W0406 04:27:38.389718 6417 loader.go:221] Config not found: /etc/kubernetes/admin.conf
The connection to the server localhost:8080 was refused - did you specify the right host or port?
[root@master kubernetes]# sudo kubeadm upgrade apply --force
couldn't create a Kubernetes client from file "/etc/kubernetes/admin.conf": failed to load admin kubeconfig: open /etc/kubernetes/admin.conf: no such file or directory
To see the stack trace of this error execute with --v=5 or higher
[root@master kubernetes]# kubeadm init --kubernetes-version=v1.21.0 --image-repository=registry.aliyuncs.com/google_containers --apiserver-advertise-address=192.168.56.101
[init] Using Kubernetes version: v1.21.0
[preflight] Running pre-flight checks
[WARNING Service-Docker]: docker service is not enabled, please run 'systemctl enable docker.service'
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "ca" certificate and key
[certs] Generating "apiserver" certificate and key
2:解决方式
[root@master ~]# echo “export KUBECONFIG=/etc/kubernetes/admin.conf” >> ~/.bash_profile
[root@master ~]# source ~/.bash_profile
[root@master ~]# kubectl get pods -n kube-system
[root@master ~]# echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
[root@master ~]# source ~/.bash_profile
[root@master ~]# kubectl get pods -n kube-system
2:额外
/etc/kubernetes 默认只有mainfests 文件夹,执行完kubeadm init 才会生成
admin.conf controller-manager.conf kubelet.conf manifests pki scheduler.conf
[root@master ~]# cd /etc/kubernetes/
[root@master kubernetes]# ls
manifests
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
Alternatively, if you are the root user, you can run:
export KUBECONFIG=/etc/kubernetes/admin.conf
You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
https://kubernetes.io/docs/concepts/cluster-administration/addons/
Then you can join any number of worker nodes by running the following on each as root:
kubeadm join 192.168.56.101:6443 --token 5tgpl8.eqji22bsewjlkgdh \
--discovery-token-ca-cert-hash sha256:9ae847019f74873733328c2157e9c35385d0346b73fb7ee905ccad37bf812a07
[root@master kubernetes]# LS
-bash: LS: 未找到命令
[root@master kubernetes]# ls
admin.conf controller-manager.conf kubelet.conf manifests pki scheduler.conf
[root@master kubernetes]#
更多推荐
已为社区贡献11条内容
所有评论(0)