使用k8s踩过的坑,优化记录 (持续交作业)
k8s v1.18.3 (dev 二进制安装)
k8s v1.19.4 (线上 kubeadm安装)
1.报错如下
2月 24 15:17:31 k8s-node1 kubelet[10110]: E0224 15:17:31.264276 10110 kubelet_volumes.go:154] orphaned pod "675771bc-fefe-4a1e-b19c-de9341b9bc17" found, but volume paths are still present on disk : There were a total of 1 errors similar to this. Turn up verbosity to see them.
出现此错误集群出现异常的情况删除了这个pod但是没有删掉系统上的文件
解决方法如下
cd /var/lib/kubelet/pods
rm -rf 名称
2.内存溢出问题
-bash: fork: Cannot allocate memory
升级内核参考之前文章
3.Kubernetes v1.20.0 报"unexpected error getting claim reference: selfLink was empty, can’t make reference”
#kubeadm安装
vi /etc/kubernetes/manifests/kube-apiserver.yaml
- --feature-gates=RemoveSelfLink=false
#然后执行
kubectl apply -f /etc/kubernetes/manifests/kube-apiserver.yaml
#二进制kubeasz安装
vi /etc/systemd/system/kube-apiserver.service
--feature-gates=RemoveSelfLink=false \
--v=2
systemctl datemon-reload
systemctl restart kube-api
3.pod网段和阿里云DNS网段冲突(kubeadm安装,网络插件flannle)
#修改集群配置 configmap, 在 networking 下 增加 podSubnet: 10.244.0.0/16
kubectl edit cm kubeadm-config -n kube-system
networking:
dnsDomain: cluster.local
podSubnet: 10.244.0.0/16
serviceSubnet: 10.96.0.0/16
#修改 controller-manager 静态 pod 的启动参数,增加 --allocate-node-cidrs=true --cluster-cidr=10.244.0.0/16
vi /etc/kubernetes/manifests/kube-controller-manager.yaml
- command:
- --allocate-node-cidrs=true
- --cluster-cidr=10.244.0.0/16
#检查配置是否生效
kubectl cluster-info dump | grep -m 1 cluster-cidr
#如果更新较慢,可以手动删除相关 pod
kubectl delete pod -n kube-system kube-flannel-ds-amd64-***
4.安装过isito没有清理干净 Error from server (InternalError): error when creating “tz.yaml”: Internal error occurred: failed calling webhook “namespace.sidecar-injector.istio.io”: Post “https://istiod.istio-system.svc:443/inject?timeout=10s”: service “istiod” not found
# 直接删除sidecar注入
kubectl delete mutatingwebhookconfigurations.admissionregistration.k8s.io istio-sidecar-injector
文章作者 🐳Myki
上次更新 2021-02-24