Memecahkan masalah webhook Google Distributed Cloud
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini menunjukkan cara menyelesaikan masalah terkait webhook yang bermasalah atau tidak aman di Google Distributed Cloud.
Jenis webhook bermasalah
Webhook penerimaan, atau webhook di Kubernetes, adalah jenis
pengontrol penerimaan
yang dapat digunakan di cluster Kubernetes untuk memvalidasi atau mengubah permintaan ke
bidang kontrol sebelum permintaan dipertahankan. Umumnya aplikasi pihak ketiga
menggunakan webhook yang beroperasi di resource dan
namespace yang penting bagi sistem. Webhook yang tidak dikonfigurasi dengan benar dapat memengaruhi performa dan keandalan
bidang kontrol. Misalnya, webhook yang tidak dikonfigurasi dengan benar
yang dibuat oleh aplikasi pihak ketiga dapat mencegah Google Distributed Cloud membuat dan
mengubah resource di namespace kube-system terkelola, yang
dapat menurunkan fungsi cluster.
Webhook yang tidak memiliki endpoint yang tersedia
Jika webhook tidak memiliki endpoint yang tersedia, Service yang mendukung endpoint
webhook memiliki satu atau beberapa Pod yang tidak berjalan. Agar endpoint webhook tersedia, ikuti petunjuk untuk menemukan dan memecahkan masalah Pod Service yang mendukung endpoint webhook ini:
Cari Pod aktif untuk Service yang terkait dengan webhook. Jalankan perintah berikut untuk menjelaskan Service:
kubectldescribesvcSERVICE_NAME-nSERVICE_NAMESPACE
Ganti kode berikut:
SERVICE_NAME dengan nama Layanan.
SERVICE_NAMESPACE dengan nama namespace.
Jika Anda tidak dapat menemukan nama Service yang tercantum di webhook, endpoint
yang tidak tersedia mungkin disebabkan oleh ketidakcocokan antara nama yang tercantum dalam
konfigurasi dan nama Service yang sebenarnya. Untuk memperbaiki ketersediaan
endpoint, perbarui nama Service di konfigurasi webhook agar cocok
dengan objek Service yang benar.
Periksa Pod aktif untuk Service ini. Identifikasi Pod mana yang tidak berjalan dengan mencantumkan Deployment:
kubectlgetdeployment-nSERVICE_NAMESPACE
Atau, jalankan perintah berikut untuk mencantumkan Pod:
kubectlgetpods-nSERVICE_NAMESPACE-owide
Untuk setiap Pod yang tidak berjalan, periksa log Pod untuk mengetahui alasan Pod
tidak berjalan.
Webhook yang dianggap tidak aman
Jika webhook menangkap resource di namespace yang dikelola sistem, sebaiknya Anda memperbarui webhook agar tidak menangkap resource ini.
Periksa konfigurasi webhook. Jalankan perintah kubectl berikut untuk
mendapatkan konfigurasi webhook:
Ganti CONFIGURATION_NAME dengan nama
konfigurasi webhook.
Jika perintah ini tidak menampilkan apa pun, jalankan kembali perintah tersebut, dengan mengganti
validatingwebhookconfigurations dengan mutatingwebhookconfigurations.
Di bagian webhooks output, satu atau beberapa webhook tercantum.
Edit konfigurasi, bergantung pada alasan webhook dianggap tidak aman:
Mengecualikan namespace kube-system dan kube-node-lease
Webhook dianggap tidak aman jika scope adalah *, atau jika cakupannya adalah
Namespaced dan salah satu kondisi berikut terpenuhi:
Kondisi operator adalah NotIn dan values menghilangkan kube-system dan
kube-node-lease, seperti dalam contoh berikut:
webhooks:-admissionReviewVersions:...namespaceSelector:matchExpressions:-key:kubernetes.io/metadata.nameoperator:NotInvalues:-blue-system# add 'kube-system' and 'kube-node-lease' if `NotIn`objectSelector:{}rules:-apiGroups:...scope:'*'# 'Namespaced'sideEffects:NonetimeoutSeconds:3
Pastikan scope ditetapkan ke Namespaced, bukan *, sehingga webhook
hanya beroperasi di namespace tertentu. Jika operator adalah
NotIn, pastikan kube-system, dan kube-node-lease disertakan dalam values.
Kondisi operator adalah In dan values menyertakan kube-system dan
kube-node-lease, seperti dalam contoh berikut:
namespaceSelector:matchExpressions:-key:kubernetes.io/metadata.nameoperator:Invalues:-blue-system-kube-system# remove as operator is `In`-kube-node-lease# remove as operator is `In`
Pastikan scope ditetapkan ke Namespaced, bukan *, sehingga webhook
hanya beroperasi di namespace tertentu. Jika operator adalah In,
pastikan kube-system dan kube-node-lease tidak disertakan dalam values.
Mengecualikan resource yang cocok
Webhook juga dianggap tidak aman jika nodes, tokenreviews,
subjectaccessreviews, atau certificatesigningrequests tercantum di bagian
resource, seperti dalam contoh berikut:
Hapus nodes, tokenreviews, subjectaccessreviews, dan
certificatesigningrequests dari bagian resource.
Langkah berikutnya
Jika Anda memerlukan bantuan tambahan, hubungi
Cloud Customer Care.
Anda juga dapat melihat bagian
Mendapatkan dukungan untuk mengetahui informasi selengkapnya tentang sumber dukungan, termasuk yang berikut:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-07-22 UTC."],[],[],null,["This page shows you how to resolve issues with problematic or unsafe webhooks in\nGoogle Distributed Cloud.\n\nTypes of problematic webhooks\n\nAdmission webhooks, or *webhooks* in Kubernetes, are a type of\n[admission controller](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/)\nthat can be used in Kubernetes clusters to validate or mutate requests to the\ncontrol plane prior to a request being persisted. It is common for third-party\napplications to use webhooks that operate on system-critical resources and\nnamespaces. Incorrectly configured webhooks can impact control plane\nperformance and reliability. For example, an incorrectly configured webhook\ncreated by a third-party application could prevent Google Distributed Cloud from\ncreating and modifying resources in the managed `kube-system` namespace, which\ncould degrade the functionality of the cluster.\n\nProblematic webhooks include the following types:\n\n- **Webhooks that operate, but have no endpoints available.** Follow the instructions to [check webhooks with no available endpoints](#no-available-endpoints).\n- **Webhooks that are considered unsafe as they operate on system critical\n resources and namespaces.**\n\n The following webhooks are considered unsafe:\n - Webhooks that intercept Pods and leases in the `kube-system` namespace.\n - Webhooks that intercept leases in the `kube-node-lease` namespace.\n - Webhooks that intercept [`Nodes`](https://kubernetes.io/docs/concepts/architecture/nodes/), [`TokenReviews`](https://kubernetes.io/docs/reference/kubernetes-api/authentication-resources/token-review-v1/), [`SubjectAccessReviews`](https://kubernetes.io/docs/reference/access-authn-authz/authorization/), and [`CertificateSigningRequests`](https://kubernetes.io/docs/reference/access-authn-authz/certificate-signing-requests/) resources.\n\n Follow the instructions to\n [check webhooks that are considered unsafe](#unsafe-webhooks).\n\nWebhooks that have no available endpoints\n\nIf a webhook has no available endpoints, the Service that backs the webhook\nendpoint has one or more Pods which aren't running. To make the webhook\nendpoints available, follow the instructions to find and troubleshoot the Pods\nof the Service that is backing this webhook endpoint:\n\n1. Find the serving Pods for the Service associated with the webhook. Run the\n following command to describe the Service:\n\n kubectl describe svc \u003cvar translate=\"no\"\u003eSERVICE_NAME\u003c/var\u003e -n \u003cvar translate=\"no\"\u003eSERVICE_NAMESPACE\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eSERVICE_NAME\u003c/var\u003e with the name of the Service.\n - \u003cvar translate=\"no\"\u003eSERVICE_NAMESPACE\u003c/var\u003e with the name of the namespace.\n\n If you can't find the Service name listed in the webhook, the unavailable\n endpoint might be caused by a mismatch between the name listed in the\n configuration and the actual name of the Service. To fix the endpoint\n availability, update the Service name in the webhook configuration to match\n the correct Service object.\n2. Inspect the serving Pods for this Service. Identify which Pods aren't\n running by listing the Deployment:\n\n kubectl get deployment -n \u003cvar translate=\"no\"\u003eSERVICE_NAMESPACE\u003c/var\u003e\n\n Or, run the following command to list the Pods: \n\n kubectl get pods -n \u003cvar translate=\"no\"\u003eSERVICE_NAMESPACE\u003c/var\u003e -o wide\n\n For any Pods that aren't running, inspect the Pod logs to see why the Pod\n isn't running.\n\nWebhooks that are considered unsafe\n\nIf a webhook intercepts any resources in system-managed namespaces, we\nrecommend that you update the webhooks to avoid intercepting these resources.\n\n1. Inspect the webhook configuration. Run the following `kubectl` command to\n get the webhook configuration:\n\n kubectl get validatingwebhookconfigurations \u003cvar translate=\"no\"\u003eCONFIGURATION_NAME\u003c/var\u003e -o yaml\n\n Replace \u003cvar translate=\"no\"\u003eCONFIGURATION_NAME\u003c/var\u003e with the name of the\n webhook configuration.\n\n If this command doesn't return anything, run the command again, replacing\n `validatingwebhookconfigurations` with `mutatingwebhookconfigurations`.\n\n In the `webhooks` section of the output, one or more webhooks are listed.\n2. Edit the configuration, depending on the reason the webhook is considered\n unsafe:\n\n Exclude kube-system and kube-node-lease namespaces\n\n A webhook is considered unsafe if `scope` is `*`, or if scope is\n `Namespaced` and either of the following conditions are true:\n - The `operator` condition is `NotIn` and `values` omits `kube-system` and\n `kube-node-lease`, as in the following example:\n\n webhooks:\n - admissionReviewVersions:\n ...\n namespaceSelector:\n matchExpressions:\n - key: kubernetes.io/metadata.name\n operator: NotIn\n values:\n - blue-system # add 'kube-system' and 'kube-node-lease' if `NotIn`\n objectSelector: {}\n rules:\n - apiGroups:\n ...\n scope: '*' # 'Namespaced'\n sideEffects: None\n timeoutSeconds: 3\n\n Ensure that `scope` is set to `Namespaced`, not `*`, so that the webhook\n only operates in specific namespaces. Ensure that if `operator` is\n `NotIn`, `kube-system` and `kube-node-lease` are included in `values`.\n - The `operator` condition is `In` and `values` includes `kube-system` and\n `kube-node-lease`, as in the following example:\n\n namespaceSelector:\n matchExpressions:\n - key: kubernetes.io/metadata.name\n operator: In\n values:\n - blue-system\n - kube-system # remove as operator is `In`\n - kube-node-lease # remove as operator is `In`\n\n Ensure that `scope` is set to `Namespaced`, not `*`, so that the webhook\n only operates in specific namespaces. Ensure that if `operator` is `In`,\n `kube-system` and `kube-node-lease` are not included in `values`.\n\n Exclude matched resources\n\n A webhook is also considered unsafe if `nodes`, `tokenreviews`,\n `subjectaccessreviews`, or `certificatesigningrequests` are listed under\n resources, as in the following example: \n\n - admissionReviewVersions:\n ...\n resources:\n - 'pods' # keep, remove everything else\n - 'nodes'\n - 'tokenreviews'\n - 'subjectacessreviews'\n - 'certificatesigningrequests'\n scope: '*'\n sideEffects: None\n timeoutSeconds: 3\n\n Remove `nodes`, `tokenreviews`, `subjectaccessreviews`, and\n `certificatesigningrequests` from the resource section.\n\nWhat's next\n\nIf you need additional assistance, reach out to\n\n[Cloud Customer Care](/support-hub).\nYou can also see\n[Getting support](/kubernetes-engine/distributed-cloud/bare-metal/docs/getting-support) for more information about support resources, including the following:\n\n- [Requirements](/kubernetes-engine/distributed-cloud/bare-metal/docs/getting-support#intro-support) for opening a support case.\n- [Tools](/kubernetes-engine/distributed-cloud/bare-metal/docs/getting-support#support-tools) to help you troubleshoot, such as your environment configuration, logs, and metrics.\n- Supported [components](/kubernetes-engine/distributed-cloud/bare-metal/docs/getting-support#what-we-support)."]]