Unable to connect to the server: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")
查看配置详情
[root@localhost ~]# kubectl config view
解决:
[root@localhost ~]# kubectl config delete-cluster kubernetes
deleted cluster kubernetes from /root/.kube/config
The Service "nginx-test" is invalid: spec.ports[0].nodePort: Invalid value: 80: provided port is not in the valid range. The range of valid ports is 30000-32767
解决:
使用 kubeadm 安装 K8S 集群的情况下,您的 Master 节点上会有一个文件:
/etc/kubernetes/manifests/kube-apiserver.yaml
修改此文件,向api-server中添加:
--service-node-port-range=1-50000
重启api-server:
systemctl daemon-reload
systemctl restart kube-apiserver
已发布的服务,需要重新发布生效
使用kubectl describe pod [问题pod名称] 查看发现,报错 no basic auth credentials
解决方案:
在master节点使用如下语句创建名为regcred 的secret
kubectl create secret generic regcred --from-file=.dockerconfigjson=/root/.docker/config.json --type=kubernetes.io/dockerconfigjson
并制定yml文件中的imagePullSecrets
imagePullSecrets:
- name: regcred
重新部署,问题解决!
#使用base64生成docker仓库登录凭据
base64 -w 0 /root/.docker/config.json
可能是重新部署k8s相关信息没有清理干净
使用下列命令删除网口再重新初始化
ifconfig cni0 down
ip link delete cni0
使用以下命令,更新pod的labels可以触发pod拉取新的镜像并重新部署
kubectl patch deployment [my_deployment] -n [my_namespace] -p '{"spec":{"template":{"metadata":{"labels":{"date":"'`date +'%s'`'"}}}}}';
#重启docker
systemctl daemon-reload
systemctl restart docker
#重启kubelet
systemctl restart kubelet.service
vi /var/lib/kubelet/config.yaml
#添加配置
evictionHard:
imagefs.available: 15%
memory.available: 1Gi
nodefs.available: 10%
nodefs.inodesFree: 5%
kubectl get pods -n [NAMESPACE]| awk '{ print $1 }' | xargs kubectl delete --force --grace-period=0 -n [NAMESPACE] pod