{"id":30426,"date":"2024-01-25T10:20:46","date_gmt":"2024-01-25T09:20:46","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/?p=30426"},"modified":"2024-03-08T17:04:34","modified_gmt":"2024-03-08T16:04:34","slug":"how-to-delete-a-resource-with-the-error-failed-calling-webhook","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/","title":{"rendered":"How to delete a resource with the error: failed calling webhook"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"h-the-original-mistake\">The original mistake<\/h2>\n\n\n\n<p>In preparation of the <a href=\"https:\/\/www.dbi-services.com\/courses\/gitlab-essentials\/\" target=\"_blank\" rel=\"noreferrer noopener\">GitLab essentials workshop<\/a>, I&#8217;m using helm to deploy it. After a few tests, I wanted to clean up my cluster, and accidentally deleted the namespace before doing helm uninstall. As a result, the namespace got stuck in the &#8220;terminating&#8221; state\u2026<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-troubleshooting\">Troubleshooting<\/h2>\n\n\n\n<p>Now the namespace is stuck, but why ?<\/p>\n\n\n\n<p>However, no resources seem to exist yet in the namespace:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rocky@gitlab-master1:dbi-gitlab-ws:~$ kubectl get all -n gitlab\n&gt; No resources found<\/code><\/pre>\n\n\n\n<p>By default, GitLab installs the cert-manager controller, which comes with CRDs. However, the get all command does not return the CRDs:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rocky@gitlab-master1:dbi-gitlab-ws:~$ kubectl get challenges.acme.cert-manager.io -n gitlab\nNAME                                              STATE     DOMAIN                                   AGE\ngitlab-gitlab-tls-c5nxj-1256604583-3239988248     invalid   gitlab-workshop.dbi-services.com     27m\ngitlab-kas-tls-qghrb-3784695029-3983492218        invalid   kas-workshop.dbi-services.com        27m\ngitlab-minio-tls-l8676-2620392232-3964581703      invalid   minio-workshop.dbi-services.com      27m\ngitlab-registry-tls-k9j6n-1904257687-1249029966   invalid   registry-workshop.dbi-services.com   27m<\/code><\/pre>\n\n\n\n<p>CRDs delete does not work because the finalizer does not respond during deletion.<\/p>\n\n\n\n<p>The easiest way to do this is to remove the finalizer from the resource:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rocky@gitlab-master1:dbi-gitlab-ws:~$ kubectl patch challenges.acme.cert-manager.io\/gitlab-gitlab-tls-c5nxj-1256604583-3239988248 --type=json --patch='&#091; { \"op\": \"remove\", \"path\": \"\/metadata\/finalizers\" } ]' -n gitlab\n&gt; Error from server (InternalError): Internal error occurred: failed calling webhook \"webhook.cert-manager.io\": failed to call webhook: Post \"https:\/\/gitlab-certmanager-webhook.gitlab.svc:443\/mutate?timeout=10s\": service \"gitlab-certmanager-webhook\" not found<\/code><\/pre>\n\n\n\n<p>Unfortunately, in this case, the patch doesn&#8217;t work because the delete of the namespace has removed some resources needed by the finalizer\u2026<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-solution\">Solution<\/h2>\n\n\n\n<p>The cert-manager installs webhooks to manage CRDs:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rocky@gitlab-master1:dbi-gitlab-ws:~$ kubectl get ValidatingWebhookConfiguration\nNAME                            WEBHOOKS   AGE\ncert-manager-webhook            1          81m\n\nrocky@gitlab-master1:dbi-gitlab-ws:~$ kubectl get MutatingWebhookConfiguration\nNAME                         WEBHOOKS   AGE\ngitlab-certmanager-webhook   1          81m<\/code><\/pre>\n\n\n\n<p>Webhooks call services and pods that no longer exist in our case. As a result, the webhook call fails and blocks the finalizer.<\/p>\n\n\n\n<p>To correct the problem, simply delete the webhooks:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rocky@gitlab-master1:dbi-gitlab-ws:~$ kubectl delete ValidatingWebhookConfiguration cert-manager-webhook\nrocky@gitlab-master1:dbi-gitlab-ws:~$ kubectl delete MutatingWebhookConfiguration gitlab-certmanager-webhook<\/code><\/pre>\n\n\n\n<p>After that, it is possible to delete the remaining CRDs:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rocky@gitlab-master1:dbi-gitlab-ws:~$ kubectl patch challenges.acme.cert-manager.io\/gitlab-gitlab-tls-c5nxj-1256604583-3239988248 --type=json --patch='&#091; { \"op\": \"remove\", \"path\": \"\/metadata\/finalizers\" } ]' -n gitlab\n&gt; challenge.acme.cert-manager.io\/gitlab-gitlab-tls-c5nxj-1256604583-3239988248 patched<\/code><\/pre>\n\n\n\n<p>The namespace will be automatically deleted once all CRDs have been cleaned.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The original mistake In preparation of the GitLab essentials workshop, I&#8217;m using helm to deploy it. After a few tests, I wanted to clean up my cluster, and accidentally deleted the namespace before doing helm uninstall. As a result, the namespace got stuck in the &#8220;terminating&#8221; state\u2026 Troubleshooting Now the namespace is stuck, but why [&hellip;]<\/p>\n","protected":false},"author":72,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1320,1522],"tags":[3232,2648,2634,44],"type_dbi":[],"class_list":["post-30426","post","type-post","status-publish","format-standard","hentry","category-devops","category-kubernetes","tag-cert-manager","tag-gitlab","tag-kubernetes-2","tag-troubleshooting"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to delete a resource with the error: failed calling webhook - dbi Blog<\/title>\n<meta name=\"description\" content=\"A solution to delete a resource in Kubernetes when the removal is stuck with the error: failed calling webhook.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to delete a resource with the error: failed calling webhook\" \/>\n<meta property=\"og:description\" content=\"A solution to delete a resource in Kubernetes when the removal is stuck with the error: failed calling webhook.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2024-01-25T09:20:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-08T16:04:34+00:00\" \/>\n<meta name=\"author\" content=\"Nicolas Meunier\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nicolas Meunier\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/\"},\"author\":{\"name\":\"Nicolas Meunier\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/2e08c09a2f083004587b54128684fefe\"},\"headline\":\"How to delete a resource with the error: failed calling webhook\",\"datePublished\":\"2024-01-25T09:20:46+00:00\",\"dateModified\":\"2024-03-08T16:04:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/\"},\"wordCount\":209,\"commentCount\":0,\"keywords\":[\"Cert-Manager\",\"GitLab\",\"kubernetes\",\"Troubleshooting\"],\"articleSection\":[\"DevOps\",\"Kubernetes\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/\",\"name\":\"How to delete a resource with the error: failed calling webhook - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\"},\"datePublished\":\"2024-01-25T09:20:46+00:00\",\"dateModified\":\"2024-03-08T16:04:34+00:00\",\"author\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/2e08c09a2f083004587b54128684fefe\"},\"description\":\"A solution to delete a resource in Kubernetes when the removal is stuck with the error: failed calling webhook.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/www.dbi-services.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to delete a resource with the error: failed calling webhook\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/2e08c09a2f083004587b54128684fefe\",\"name\":\"Nicolas Meunier\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g\",\"caption\":\"Nicolas Meunier\"},\"description\":\"Nicolas Meunier has more than 20 years of experience in IT web technologies as well as in development. He is specialized in Cloud solutions such as CI\/CD. His expertise also includes Kubernetes, Docker, Jenkins-X and Azure Devops. Florence Porret (FP is IT Consultant in Cloud solutions. Prior to joining dbi services, Nicolas Meunier was developer and maintainer of a CI\/CD pipelines at CEGID in Paris. He also worked as Lead Developer at KPMG. Florence Porret (FP holds a superior technical diploma in IT development. His branch-related experience covers software and cloud platform architecture.\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/author\/nicolasmeunier\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to delete a resource with the error: failed calling webhook - dbi Blog","description":"A solution to delete a resource in Kubernetes when the removal is stuck with the error: failed calling webhook.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/","og_locale":"en_US","og_type":"article","og_title":"How to delete a resource with the error: failed calling webhook","og_description":"A solution to delete a resource in Kubernetes when the removal is stuck with the error: failed calling webhook.","og_url":"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/","og_site_name":"dbi Blog","article_published_time":"2024-01-25T09:20:46+00:00","article_modified_time":"2024-03-08T16:04:34+00:00","author":"Nicolas Meunier","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Nicolas Meunier","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/"},"author":{"name":"Nicolas Meunier","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/2e08c09a2f083004587b54128684fefe"},"headline":"How to delete a resource with the error: failed calling webhook","datePublished":"2024-01-25T09:20:46+00:00","dateModified":"2024-03-08T16:04:34+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/"},"wordCount":209,"commentCount":0,"keywords":["Cert-Manager","GitLab","kubernetes","Troubleshooting"],"articleSection":["DevOps","Kubernetes"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/","url":"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/","name":"How to delete a resource with the error: failed calling webhook - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2024-01-25T09:20:46+00:00","dateModified":"2024-03-08T16:04:34+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/2e08c09a2f083004587b54128684fefe"},"description":"A solution to delete a resource in Kubernetes when the removal is stuck with the error: failed calling webhook.","breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/how-to-delete-a-resource-with-the-error-failed-calling-webhook\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to delete a resource with the error: failed calling webhook"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/2e08c09a2f083004587b54128684fefe","name":"Nicolas Meunier","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g","caption":"Nicolas Meunier"},"description":"Nicolas Meunier has more than 20 years of experience in IT web technologies as well as in development. He is specialized in Cloud solutions such as CI\/CD. His expertise also includes Kubernetes, Docker, Jenkins-X and Azure Devops. Florence Porret (FP is IT Consultant in Cloud solutions. Prior to joining dbi services, Nicolas Meunier was developer and maintainer of a CI\/CD pipelines at CEGID in Paris. He also worked as Lead Developer at KPMG. Florence Porret (FP holds a superior technical diploma in IT development. His branch-related experience covers software and cloud platform architecture.","url":"https:\/\/www.dbi-services.com\/blog\/author\/nicolasmeunier\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/30426","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/72"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=30426"}],"version-history":[{"count":8,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/30426\/revisions"}],"predecessor-version":[{"id":31724,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/30426\/revisions\/31724"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=30426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=30426"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=30426"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=30426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}