K&

一、证书超时问题

 

kubeadm部署集群证书是有期限的,可以用这个命令查看。解决办法后续补上

 

kubeadm alpha certs check-expiration

 

 

二、Kubernetes cp 失败原因:

 

其实容器外的文件到容器内有两种方式

 

1、挂载

2、CP

 

!!!Important Note!!! # Requires that the 'tar' binary is present in your container # image. If 'tar' is not present, 'kubectl cp' will fail. # # For advanced use cases, such as symlinks, wildcard expansion or # file mode preservation consider using 'kubectl exec'. # Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace

 

 

tar cf - /tmp/foo | kubectl exec -i -n <some-namespace> <some-pod> -- tar xf - -C /tmp/bar

 

kubectl exec -n <some-namespace> <some-pod> -- tar cf - /tmp/foo | tar xf - -C /tmp/bar

 

 

这里是CP的报错过程

 

 

[root@master ~]# kubectl cp 1.txt calico-node-7zgqj:/ -n kube-system
OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "exec: \"tar\": executable file not found in $PATH": unknown
command terminated with exit code 126

 

这个报错结合上面那段英文,意思就是我需要容器内含有tar命令不然就CP失败。怎么解决,有两种方法,第一种通过docker查找目标容器的id找到后利用docker去cp。第二种在跑容器前在挂载文件直接吧tar挂载进去,之后就可以为所欲为了。(不过第一种需要在一箩筐的container中去找你要的container id,而第二种就需要在部署前就处理好。)

 

 

 

posted on 2021-05-09 10:50  K&  阅读(959)  评论(0编辑  收藏  举报