登录 Dashboard 时,不能输入 token 时,
输入以下命令 thisisunsafe

kubelet

设置开机启动(所有节点)

# 重新加载服务的配置文件
systemctl daemon-reload
systemctl start kubelet
systemctl enable kubelet
systemctl status kubelet
systemctl restart kubelet

# 查看版本
kubelet --version
kubeadmin version

kubectl常用命令

master上使执行

#查看集群所有节点
kubectl get nodes
#标记节点为不可调度
kubectl cordon node1  
#标记节点为可调度
kubectl uncordon node1
#将pod赶到其他节点:
kubectl drain node1
#master运行pod
kubectl taint nodes master node-role.kubernetes.io/master-
#master不运行pod
kubectl taint nodes master node-role.kubernetes.io/master=:NoSchedule




#根据配置文件,给集群创建资源
kubectl apply -f xxxx.yaml

#查看集群部署了哪些应用?
docker ps   ===   kubectl get pods -A
# 运行中的应用在docker里面叫容器,在k8s里面叫Pod
kubectl get pods -A
# 每一秒刷新一次
watch -n 1 kubectl get pod -A 

# 查看pod详情
kubectl describe pod  calico-node-rsmm8 --namespace=kube-system
kubectl describe pod  calico-kube-controllers-5cdbdf5595-dxnzd --namespace=kube-system

#kubectl delete 常用命令
#https://www.cjavapy.com/article/2420/
# 通过yaml文件删除
kubectl delete -f calico_v3.21.yaml 
# 删除单个pod
kubectl delete pod calico-node-x2bfz  -n kube-system


kubectl cluster-info

# 获取节点信息
kubectl get ns

# 获取kube-system空间下的信息
kubectl get all -n kube-system


# k8s从pod中拷贝文件到宿主机
kubectl cp 命名空间/POD名:/路径/文件名 /本地路径/文件名
# 报错
[root@master home]# kubectl get pod -A
NAMESPACE     NAME                                       READY   STATUS                  RESTARTS   AGE
kube-system   calico-kube-controllers-5cdbdf5595-dxnzd   0/1     ImagePullBackOff        0          18m
kube-system   calico-node-rsmm8                          0/1     Init:ImagePullBackOff   0          18m

# 查看详情
kubectl describe pod  calico-node-rsmm8 --namespace=kube-system
kubectl describe pod  calico-kube-controllers-5cdbdf5595-dxnzd --namespace=kube-system
kubectl describe pod  calico-node-xlpxv --namespace=kube-system
kubectl describe pod  calico-kube-controllers-5cdbdf5595-gkpfq  --namespace=kube-system
kubectl describe pod  calico-node-5bp25 --namespace=kube-system
kubectl describe pod  calico-node-fd5v7 --namespace=kube-system
kubectl describe pod  coredns-7f89b7bc75-98dz4 --namespace=kube-system
kubectl describe pod  coredns-7f89b7bc75-xvr57 --namespace=kube-system


  Warning  Failed     10m (x4 over 19m)     kubelet            Error: ErrImagePull
  Normal   BackOff    9m48s (x8 over 19m)   kubelet            Back-off pulling image "docker.io/calico/cni:v3.21.5"
  Warning  Failed     4m54s (x22 over 19m)  kubelet            Error: ImagePullBackOff


  Warning  Failed     9m35s (x4 over 17m)  kubelet            Error: ErrImagePull
  Normal   BackOff    9m7s (x7 over 17m)   kubelet            Back-off pulling image "docker.io/calico/kube-controllers:v3.21.5"
  Warning  Failed     23s (x29 over 17m)   kubelet            Error: ImagePullBackOff

  Normal   BackOff    49s (x2 over 2m55s)  kubelet            Back-off pulling image "docker.io/calico/pod2daemon-flexvol:v3.21.5"
  Warning  Failed     49s (x2 over 2m55s)  kubelet            Error: ImagePullBackOff

  Normal   BackOff    8m34s (x53 over 46m)  kubelet            Back-off pulling image "docker.io/calico/node:v3.21.5"
  Warning  Failed     3m36s (x67 over 46m)  kubelet            Error: ImagePullBackOff



# 从上面可以看到拉取镜像超时了,
哎,明天换个网再操作 无奈

参考文档:

作者:海马  创建时间:2023-07-09 10:26
最后编辑:海马  更新时间:2024-08-03 21:41