Kubernetes + ArgoCD + Prometheus 部署问题总结及解决方案
·
SSH 密钥认证问题
问题表现:
-
Permission denied (publickey) -
SSH 连接 GitHub 失败
解决方案:
# 1. 生成 SSH 密钥
ssh-keygen -t ed25519 -C "your_email@example.com"
# 2. 启动 SSH agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
# 3. 添加到 GitHub
cat ~/.ssh/id_ed25519.pub
# 复制到 GitHub Settings → SSH and GPG keys
# 4. 测试连接
ssh -T git@github.com
ArgoCD 安装和配置问题
问题表现:
-
Pod 状态异常
-
同步状态 Degraded
-
仓库连接失败
解决方案:
# 1. 完全重新安装
kubectl delete namespace argocd
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
# 2. 暴露 UI
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "NodePort"}}'
# 3. 获取密码
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
Calico 网络插件问题
问题表现:
-
connection is unauthorized: Unauthorized -
Pod 卡在 ContainerCreating
解决方案:
# 1. 重新安装 Calico
kubectl delete -f https://docs.projectcalico.org/manifests/calico.yaml
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
# 2. 重启 Calico
kubectl rollout restart daemonset calico-node -n kube-system
镜像拉取问题
问题表现:
-
ImagePullBackOff -
ErrImagePull -
证书验证失败
解决方案:
# 1. 使用国内镜像源
image: registry.cn-hangzhou.aliyuncs.com/google_containers/镜像名
# 2. 设置拉取策略
imagePullPolicy: IfNotPresent
# 3. 手动在节点拉取
crictl pull 镜像名
ArgoCD Application 配置问题
问题表现:
-
仓库地址不一致
-
同步状态异常
-
健康状态 Degraded
yaml文件
# 正确的 Application 配置
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: ollama
namespace: argocd
spec:
project: default
source:
repoURL: 'https://github.com/具体地址'
targetRevision: main # 明确指定分支
path: apps/ollama
destination:
server: 'https://kubernetes.default.svc'
namespace: ai-services
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
故障排查命令:
# 基础诊断
kubectl get pods -A
kubectl describe pod <pod-name> -n <namespace>
kubectl logs <pod-name> -n <namespace>
# ArgoCD 诊断
kubectl get application -n argocd
argocd app get <app-name>
# 网络诊断
kubectl get events -A --sort-by=.metadata.creationTimestamp
更多推荐
所有评论(0)