Open
Description
What happened?
当我使用client-go组件的Evict API时,发现当设置了 DeleteOptions 为 metav1.NewDeleteOptions(0) 时,无法触发mutating webhook的Pod 删除回调, 当我不设置 DeleteOptions 时,可以正常触发
代码如下:
if err := cli.CoreV1().Pods("default").Evict(context.Background(), &policy.Eviction{
TypeMeta: metav1.TypeMeta{
Kind: "Pod",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "pod-xxx",
Namespace: "default",
},
DeleteOptions: metav1.NewDeleteOptions(0),
}); err != nil {
glog.Fatalf(err.Error())
}
mutatingwebhookconfiguration:
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: my-webhook
webhooks:
- admissionReviewVersions:
- v1beta1
clientConfig:
caBundle: xxxxx
service:
name: my-webhook-svc
namespace: kube-system
path: /delete/pod
port: 443
failurePolicy: Ignore
matchPolicy: Exact
name: delete-pod-webhook.test.org
reinvocationPolicy: Never
rules:
- apiGroups:
- ""
apiVersions:
- v1
operations:
- DELETE
resources:
- pods
scope: '*'
sideEffects: Unknown
timeoutSeconds: 30
What did you expect to happen?
我期望Evict API在设置了 DeleteOptions 为 metav1.NewDeleteOptions(0) 时,能够正常触发mutatingwebhook的Pod删除回调。
How can we reproduce it (as minimally and precisely as possible)?
- 使用 k8s.io/client-go v0.21.2 创建一个客户端。
- 使用 Evict API 并设置 DeleteOptions 为 metav1.NewDeleteOptions(0)。
- 观察到mutatingwebhook的Pod删除回调没有被触发。
Anything else we need to know?
No response
Kubernetes version
$ cluster version
# v1.20.6
$ client-go version
# v0.21.2
Cloud provider
Tencent Kubernetes Engine (TKE)
OS version
No response
Install tools
No response
Container runtime (CRI) and version (if applicable)
No response
Related plugins (CNI, CSI, ...) and versions (if applicable)
No response