kyverno: [Bug] Serious performance issues after upgrading 1.11.4 -> 1.12.5
Kyverno Version
1.12.5
Description
After upgrading from v1.11.4 to v1.12.5 admission controller started to bombard our API server with get requests for every policy in every namespace that we have. On v1.11.4 we conducted investigation on whether we should deploy cluster or namespaced policies and we decided to deploy namespaced ones for better management and adjusting to variety of our workloads. It is also a default in your kyverno-policies helm chart. After upgrading to v1.12.5 admission controller which did not behave like that at all in earlier versions started to send get requests to our api server for every single policy in every single namespace with extremely high frequency what caused overloading and ultimately killing our etcd cluster.
To mitigate that issue clientRateLimitBurst, and clientRateLimitQPS were set to 10, what allowed lowering the volume of these get requests by half, the load that is bearable for our cluster. This setting is still not optimal as it increases admission review duration considerably, and still admission controller is the biggest user of kube-api according to audit logs sending over 2 mln get requests every day. Before upgrade it was around 160k.
I personally couldn’t find any related issues or changes in changelog that could cause this, or any parameters in docs that could help tune it. Why has this behaviour changed so much? Is this an expected change? If admission controller needs so frequently get these policies, could the implementation be changed to the informer pattern?
Count in kube-audit logs:
Before upgrade:
After upgrade:
Redacted example entry that our kube audit is flooded with:
{
"kind": "Event",
"apiVersion": "audit.k8s.io/v1",
"level": "Metadata",
"auditID": "326ef7d1-88a2-491c-b65a-1d1023b707c2",
"stage": "ResponseComplete",
"requestURI": "/apis/kyverno.io/v1/namespaces/redacted-ns/policies/disallow-capabilities",
"verb": "get",
"user": {
"username": "system:serviceaccount:kyverno:kyverno-admission-controller",
"uid": "475a11e7-39e4-4c0e-9a25-a1088a3a9f09",
"groups": [
"system:serviceaccounts",
"system:serviceaccounts:kyverno",
"system:authenticated"
],
"extra": {
"authentication.kubernetes.io/pod-name": [
"kyverno-admission-controller-845985496b-w5vc9"
],
"authentication.kubernetes.io/pod-uid": [
"090d2fe8-c7b3-4ffd-b7ff-4f5b9faf264e"
]
}
},
"sourceIPs": [
"redacted-ip"
],
"userAgent": "kyverno/v0.0.0 (linux/amd64) kubernetes/$Format",
"objectRef": {
"resource": "policies",
"namespace": "redacted-ns",
"name": "disallow-capabilities",
"apiGroup": "kyverno.io",
"apiVersion": "v1"
},
"responseStatus": {
"metadata": {},
"code": 200
},
"requestReceivedTimestamp": "2024-07-26T07:24:20.727866Z",
"stageTimestamp": "2024-07-26T07:24:20.733149Z",
"annotations": {
"authorization.k8s.io/decision": "allow",
"authorization.k8s.io/reason": "RBAC: allowed by ClusterRoleBinding \"kyverno:admission-controller\" of ClusterRole \"kyverno:admission-controller\" to ServiceAccount \"kyverno-admission-controller/kyverno\""
}
}
Slack discussion
No response
Troubleshooting
- I have read and followed the documentation AND the troubleshooting guide.
- I have searched other issues in this repository and mine is not recorded.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 15 (11 by maintainers)
I can confirm this happens for Both
PolicyandClusterPolicyinv1.12.5whereas it didn’t happen before inv1.11.4. The offending line seems to bepkg/controllers/webhook/controller.go#L537for updating the status even though it exists inv1.11.4. I need to investigate further to understand why.Hey @realshuting 👋🏼
Sorry, I forgot to update this issue at the time (though shared the details in Slack), but this issue has been fixed for us since 1.12.6-rc.3
resource usage:
api calls:
we’re observing this pattern after upgrading to 1.12.6-rc.2, previously running 1.12.5
we see an increased CPU & Network (Rx) usage on the upgraded clusters