You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用ArgoCD更新应用时遇缓存同步及TestSuite转换Webhook连接拒绝问题

问题描述

ArgoCD更新应用时触发缓存同步错误,具体表现为TestSuite.tests.testkube.io资源的转换webhook连接被拒绝,执行kubectl -n testkube get TestSuite命令时也会报相同错误。已手动移除Testkube的验证/突变webhook,但问题仍未解决。

错误信息详情:

error synchronizing cache state : failed to sync cluster https://10.233.0.1:443: failed to load initial state of resource
TestSuite.tests.testkube.io: conversion webhook for tests.testkube.io/v2, Kind=TestSuite failed: 
Post "https://testkube-operator-webhook-service.testkube.svc:443/convert?timeout=30s": dial tcp 10.233.34.99:443: connect: connection refused

排查与解决方案

  • 彻底清理CRD中的转换webhook配置
    移除验证/突变钩子后,CRD中可能仍残留转换webhook配置,执行以下命令检查:

    kubectl get crd testsuites.tests.testkube.io -o yaml | grep -A 20 "conversion"
    

    如果输出包含webhook相关节点,直接编辑CRD删除整个conversion块:

    kubectl edit crd testsuites.tests.testkube.io
    

    找到conversion字段,删除其下所有内容后保存退出。

  • 检查并清理异常的webhook服务
    先确认目标webhook服务状态:

    kubectl -n testkube get svc testkube-operator-webhook-service
    kubectl -n testkube get pods -l app=testkube-operator-webhook
    

    如果服务对应的pod处于异常状态(如CrashLoopBackOff),且确认不需要该webhook,直接清理相关资源:

    kubectl -n testkube delete svc testkube-operator-webhook-service
    kubectl -n testkube delete deployment <webhook-deployment-name>
    
  • 重启ArgoCD应用控制器刷新缓存
    ArgoCD的缓存可能保留了旧的webhook配置,重启应用控制器pod:

    kubectl -n argocd rollout restart deployment argocd-application-controller
    

    等待pod重启完成后,再尝试同步应用或执行kubectl get TestSuite。

  • 清理API Server端的webhook配置残留
    检查是否有未删除的webhook配置:

    kubectl get validatingwebhookconfigurations | grep testkube
    kubectl get mutatingwebhookconfigurations | grep testkube
    

    若存在相关配置,直接删除:

    kubectl delete validatingwebhookconfigurations <testkube-webhook-name>
    kubectl delete mutatingwebhookconfigurations <testkube-webhook-name>
    
  • 强制刷新CRD状态
    若CRD配置清理后仍有问题,备份当前CRD并强制重新应用:

    kubectl get crd testsuites.tests.testkube.io -o yaml > testsuites-crd-backup.yaml
    kubectl replace -f testsuites-crd-backup.yaml --force
    

内容的提问来源于stack exchange,提问作者batazor

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 14:35:53