{"id":477608,"date":"2022-07-25T11:04:10","date_gmt":"2022-07-25T08:04:10","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-use-kubernetes-hooks-to-track-container-lifecycles\/"},"modified":"2022-07-25T11:04:10","modified_gmt":"2022-07-25T08:04:10","slug":"how-to-use-kubernetes-hooks-to-track-container-lifecycles","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-use-kubernetes-hooks-to-track-container-lifecycles\/","title":{"rendered":"#How to Use Kubernetes Hooks to Track Container Lifecycles"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a3a96e7bfe95\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a3a96e7bfe95\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-kubernetes-hooks-to-track-container-lifecycles\/#%E2%80%9CHow_to_Use_Kubernetes_Hooks_to_Track_Container_Lifecycles%E2%80%9D\" >&#8220;How to Use Kubernetes Hooks to Track Container Lifecycles&#8221;<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-kubernetes-hooks-to-track-container-lifecycles\/#The_Two_Available_Hooks\" >The Two Available Hooks<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-kubernetes-hooks-to-track-container-lifecycles\/#Defining_Hook_Handlers\" >Defining Hook Handlers<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-kubernetes-hooks-to-track-container-lifecycles\/#HTTP_Handlers\" >HTTP Handlers<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-kubernetes-hooks-to-track-container-lifecycles\/#Debugging_Your_Handlers\" >Debugging Your Handlers<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-kubernetes-hooks-to-track-container-lifecycles\/#Gotchas_to_Watch_For\" >Gotchas to Watch For<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-kubernetes-hooks-to-track-container-lifecycles\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"%E2%80%9CHow_to_Use_Kubernetes_Hooks_to_Track_Container_Lifecycles%E2%80%9D\"><\/span>&#8220;How to Use Kubernetes Hooks to Track Container Lifecycles&#8221;<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<div>\n<img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage aligncenter size-full wp-image-9632\" data-pagespeed-no-defer=\"\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/csit\/2021\/02\/748108a6.jpg?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Graphic showing the Kubernetes logo\" width=\"1602\" height=\"902\"\/><br \/>Kubernetes <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/kubernetes.io\/docs\/concepts\/containers\/container-lifecycle-hooks\">container lifecycle hooks<\/a> let you respond to container creations and terminations. You can handle events by running a command inside the container or making an HTTP request to an endpoint it exposes.<\/p>\n<p>Hooks are commonly used to log container events, implement clean-up <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">script<\/a>s, and run asynchronous tasks after a new Pod joins your cluster. In this article, we\u2019ll show how to attach hook handlers to your Pods and gain more control over container lifecycles.<\/p>\n<h2 id=\"the-two-available-hooks\"><span class=\"ez-toc-section\" id=\"The_Two_Available_Hooks\"><\/span>The Two Available Hooks<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Current Kubernetes releases support two container lifecycle hooks:<\/p>\n<ul>\n<li><strong><code>PostStart<\/code><\/strong> \u2013 Handlers for this hook are called im<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/social-mediaa\/\" data-internallinksmanager029f6b8e52c=\"1\" title=\"Social Media\" target=\"_blank\" rel=\"noopener\">media<\/a>tely after a new container is created.<\/li>\n<li><strong><code>PreStop<\/code><\/strong> \u2013 This hook\u2019s invoked immediately before Kubernetes terminates a container.<\/li>\n<\/ul>\n<p>They can be handled using two different mechanisms:<\/p>\n<ul>\n<li><strong><code>Exec<\/code><\/strong> \u2013 Runs a specified command inside the container.<\/li>\n<li><strong><code>HTTP<\/code><\/strong> \u2013 Makes an HTTP request to a URL inside the container.<\/li>\n<\/ul>\n<p>Neither of the hooks provide any arguments to their handlers. Each container supports a single handler per-hook; it\u2019s not possible to call multiple endpoints or combine an exec command with an HTTP request.<\/p>\n<h2 id=\"defining-hook-handlers\"><span class=\"ez-toc-section\" id=\"Defining_Hook_Handlers\"><\/span>Defining Hook Handlers<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>You define hook handlers for Pods using their <code>containers.lifecycle<\/code> manifest field. Within this field, set the <code>postStart<\/code> and <code>preStop<\/code> properties to implement one or both of the available hooks.<\/p>\n<p>Here\u2019s a simple Pod which logs a message when it starts up:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"yaml\">\n<pre class=\"de1\"><span class=\"co3\">apiVersion<\/span><span class=\"sy2\">: <\/span>v1<span class=\"co3\">\nkind<\/span><span class=\"sy2\">: <\/span>Pod<span class=\"co4\">\nmetadata<\/span>:<span class=\"co3\">\n  name<\/span><span class=\"sy2\">: <\/span>pod-with-hooks<span class=\"co4\">\nspec<\/span>:<span class=\"co4\">\n  containers<\/span>:<span class=\"co3\">\n    - name<\/span><span class=\"sy2\">: <\/span>pod-hook-container<span class=\"co3\">\n      image<\/span><span class=\"sy2\">: <\/span>nginx:latest<span class=\"co4\">\n      lifecycle<\/span>:<span class=\"co4\">\n        postStart<\/span>:<span class=\"co4\">\n          exec<\/span>:<span class=\"co3\">\n            command<\/span><span class=\"sy2\">: <\/span><span class=\"br0\">[<\/span><span class=\"st0\">\"\/bin\/sh\"<\/span>, <span class=\"st0\">\"-c\"<\/span>, <span class=\"st0\">\"echo STARTED &gt; \/startup_message\"<\/span><span class=\"br0\">]<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>Apply the Pod to your cluster using Kubectl:<\/p>\n<pre>$ kubectl apply -f pod.yaml<\/pre>\n<p>Now get a shell to the running container inside the Pod:<\/p>\n<pre>$ kubectl exec --stdin --tty pod\/pod-with-hooks -- sh<\/pre>\n<p>Read the contents of the <code>\/startup_message<\/code> file:<\/p>\n<pre>$ cat \/startup_message&#13;\nSTARTED<\/pre>\n<p>This demonstrates that the hook was called successfully. An exec hook is considered successful if its command exits with a zero status code.<\/p>\n<h2 id=\"http-handlers\"><span class=\"ez-toc-section\" id=\"HTTP_Handlers\"><\/span>HTTP Handlers<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>You can configure an HTTP handler by replacing the <code>exec<\/code> field with <code>httpGet<\/code>. Only HTTP <code>GET<\/code> requests are supported (there\u2019s no <code>httpPost<\/code> field).<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"yaml\">\n<pre class=\"de1\"><span class=\"co3\">apiVersion<\/span><span class=\"sy2\">: <\/span>v1<span class=\"co3\">\nkind<\/span><span class=\"sy2\">: <\/span>Pod<span class=\"co4\">\nmetadata<\/span>:<span class=\"co3\">\n  name<\/span><span class=\"sy2\">: <\/span>pod-with-hooks<span class=\"co4\">\nspec<\/span>:<span class=\"co4\">\n  containers<\/span>:<span class=\"co3\">\n    - name<\/span><span class=\"sy2\">: <\/span>pod-hook-container<span class=\"co3\">\n      image<\/span><span class=\"sy2\">: <\/span>nginx:latest<span class=\"co4\">\n      lifecycle<\/span>:<span class=\"co4\">\n        postStart<\/span>:<span class=\"co4\">\n          httpGet<\/span>:<span class=\"co3\">\n            path<\/span><span class=\"sy2\">: <\/span>\/startup<span class=\"co3\">\n            port<\/span><span class=\"sy2\">: <\/span>80<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>In this example, Kubernetes makes a <code>GET<\/code> request to <code>\/startup<\/code> on the container\u2019s port 80. The <code>httpGet<\/code> field also accepts <code>scheme<\/code> and <code>host<\/code> properties to further configure the request.<\/p>\n<p>Here\u2019s a Pod where <code>\/shutdown<\/code> is called over HTTPS before container termination occurs:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"yaml\">\n<pre class=\"de1\"><span class=\"co3\">apiVersion<\/span><span class=\"sy2\">: <\/span>v1<span class=\"co3\">\nkind<\/span><span class=\"sy2\">: <\/span>Pod<span class=\"co4\">\nmetadata<\/span>:<span class=\"co3\">\n  name<\/span><span class=\"sy2\">: <\/span>pod-with-hooks<span class=\"co4\">\nspec<\/span>:<span class=\"co4\">\n  containers<\/span>:<span class=\"co3\">\n    - name<\/span><span class=\"sy2\">: <\/span>pod-hook-container<span class=\"co3\">\n      image<\/span><span class=\"sy2\">: <\/span>nginx:latest<span class=\"co4\">\n      lifecycle<\/span>:<span class=\"co4\">\n        preStop<\/span>:<span class=\"co4\">\n          httpGet<\/span>:<span class=\"co3\">\n            path<\/span><span class=\"sy2\">: <\/span>\/startup<span class=\"co3\">\n            scheme<\/span><span class=\"sy2\">: <\/span>HTTPS<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>HTTP hook handlers are deemed to have succeeded if the HTTP response code lies in the 200-299 range.<\/p>\n<h2 id=\"debugging-your-handlers\"><span class=\"ez-toc-section\" id=\"Debugging_Your_Handlers\"><\/span>Debugging Your Handlers<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Hook handlers are managed independently of the Pods they\u2019re attached to. Their logs aren\u2019t collected or stored alongside normal Pod logs, so you won\u2019t see exec commands like <code>echo Started<\/code> when running <code>kubectl logs pod\/pod-with-hooks<\/code>.<\/p>\n<p>You can debug hooks by viewing a Pod\u2019s event history. Failed invocations will be reported as <code>FailedPostStartHook<\/code> and <code>FailedPreStophook<\/code> events. The error message includes a description of what prompted the error.<\/p>\n<p>Try adding this Pod to your cluster:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"yaml\">\n<pre class=\"de1\"><span class=\"co3\">apiVersion<\/span><span class=\"sy2\">: <\/span>v1<span class=\"co3\">\nkind<\/span><span class=\"sy2\">: <\/span>Pod<span class=\"co4\">\nmetadata<\/span>:<span class=\"co3\">\n  name<\/span><span class=\"sy2\">: <\/span>pod-with-hooks<span class=\"co4\">\nspec<\/span>:<span class=\"co4\">\n  containers<\/span>:<span class=\"co3\">\n    - name<\/span><span class=\"sy2\">: <\/span>pod-hook-container<span class=\"co3\">\n      image<\/span><span class=\"sy2\">: <\/span>nginx:latest<span class=\"co4\">\n      lifecycle<\/span>:<span class=\"co4\">\n        postStart<\/span>:<span class=\"co4\">\n          exec<\/span>:<span class=\"co3\">\n            command<\/span><span class=\"sy2\">: <\/span><span class=\"br0\">[<\/span><span class=\"st0\">\"missing-command\"<\/span><span class=\"br0\">]<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>The broken PostStart hook will cause the Pod\u2019s startup to fail. Use <code>kubectl describe<\/code> to access its event history:<\/p>\n<pre>$ kubectl describe pod\/pod-with-hooks&#13;\n...&#13;\nEvents:&#13;\n  Type     Reason               Age                From               Message&#13;\n  ----     ------               ----               ----               -------&#13;\n  Normal   Scheduled            30s                default-scheduler  Successfully assigned pod-with-hooks...&#13;\n  Normal   Created              10s (x2 over 11s)  kubelet            Created container pod-hook-container&#13;\n  Normal   Started              10s (x2 over 11s)  kubelet            Started container pod-hook-container&#13;\n  Warning  FailedPostStartHook  10s (x2 over 11s)  kubelet            Exec lifecycle hook ([missing-command]) for Container \"pod-hook-container\" in Pod \"pod-with-hooks\" failed - error: command 'missing-command' exited with 126: , message: \"OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: \"missing-command\": executable file not found in $PATH: unknownrn\"&#13;\n  Normal   Killing              10s (x2 over 11s)  kubelet            FailedPostStartHook&#13;\n  Warning  BackOff              5s (x2 over 6s)    kubelet            Back-off restarting failed container<\/pre>\n<p>The <code>FailedPostStartHook<\/code> event reveals the handler failed because <code>missing-command<\/code> isn\u2019t a valid executable inside the container. This caused the container to be killed and restarted in a back-off loop. It\u2019ll be stuck like this perpetually as <code>missing-command<\/code> will never be executable.<\/p>\n<h2 id=\"gotchas-to-watch-for\"><span class=\"ez-toc-section\" id=\"Gotchas_to_Watch_For\"><\/span>Gotchas to Watch For<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Hook invocations have a few characteristics which can catch you out. Keeping these in mind can help avoid odd behavior and unexpected failures.<\/p>\n<ul>\n<li><strong>Hooks may be called more than once.<\/strong> Kubernetes guarantees your <code>PostStart<\/code> and <code>PreStop<\/code> handlers will be called <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/kubernetes.io\/docs\/concepts\/containers\/container-lifecycle-hooks\/#hook-delivery-guarantees\">\u201cat least\u201d once<\/a> for each container. In some situations, a hook might be invoked multiple times. Your handlers should be idempotent so they can withstand this possibility.<\/li>\n<li><strong>Failed hooks kill their container.<\/strong> As the debugging example above illustrates, failed hooks immediately kill their container. You need to make sure your commands and HTTP endpoints are free of errors to avoid unexpected Pod startup issues. Hook handlers should be lightweight and free of dependencies. Don\u2019t try to access a resource that might not be available immediately after your container starts.<\/li>\n<li><strong><code>PostStart<\/code> hooks race the container\u2019s <code>ENTRYPOINT<\/code>.<\/strong> <code>PostStart<\/code> fires at about the same time as the container is created. Kubernetes doesn\u2019t wait for the hook though \u2013 it\u2019ll be called asynchronously alongside the container\u2019s <code>ENTRYPOINT<\/code>, which could complete before your hook handler is invoked. This means your container\u2019s entrypoint script <em>will<\/em> begin running even if your handler reports an error and ends up killing the container.<\/li>\n<li><strong><code>PreStop<\/code> hooks will block container termination.<\/strong> Kubernetes guarantees your containers won\u2019t terminate until their <code>PreStop<\/code> hooks have completed, up to a maximum time defined by the Pod\u2019s <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/kubernetes.io\/docs\/concepts\/workloads\/pods\/pod-lifecycle\/#pod-termination\">termination grace period<\/a>. The container will be terminated regardless if the hook\u2019s still running when the grace period ends.<\/li>\n<li><strong><code>PreStop<\/code> hooks aren\u2019t called for <em>completed<\/em> Pods.<\/strong> This one can be particularly impactful depending on your use case. The current implementation of <code>PreStop<\/code> only fires when a Pod is <em>terminated<\/em> due to deletion, resource exhaustion, a probe failure, or a similar event. The hook will <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/github.com\/kubernetes\/kubernetes\/issues\/55807\">not be called<\/a> for containers that stop naturally because their process finishes its task and exits with a zero error code.<\/li>\n<\/ul>\n<p>Hooks directly impact the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/kubernetes.io\/docs\/concepts\/workloads\/pods\/pod-lifecycle\">lifecycle progression<\/a> of your Pods. Pods can\u2019t be marked as <code>Running<\/code> until their <code>PostStart<\/code> hook completes; similarly, a Pod will be stuck <code>Terminating<\/code> until <code>PreStop<\/code> has finished.<\/p>\n<h2 id=\"conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Kubernetes lifecycle events are a way to notify containers of their own creation and impending deletion. By providing commands or API endpoints inside your container, you can track the critical lifecycle stages and report them to other components of your infrastructure.<\/p>\n<p>Lifecycle events are easy to set up but they also have some common pitfalls. You can use adjacent mechanisms such as <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/kubernetes.io\/docs\/tasks\/configure-pod-container\/configure-liveness-readiness-startup-probes\/\">startup and readiness probes<\/a> if you need a more reliable invocation. These are a better option for scripts that are essential when preparing a new container\u2019s environment.<\/p>\n<\/div>\n<p><script>\n setTimeout(function(){\n  !function(f,b,e,v,n,t,s)\n  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n  n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n  n.queue=[];t=b.createElement(e);t.async=!0;\n  t.src=v;s=b.getElementsByTagName(e)[0];\n  s.parentNode.insertBefore(t,s) } (window, document,'script',\n  'https:\/\/connect.facebook.net\/en_US\/fbevents.js');\n   fbq('init', '335401813750447');\n   fbq('track', 'PageView');\n  },3000);\n<\/script><\/p>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.howtogeek.com\/devops\/how-to-use-kubernetes-hooks-to-track-container-lifecycles\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;How to Use Kubernetes Hooks to Track Container Lifecycles&#8221; Kubernetes container lifecycle hooks let you respond to container creations and terminations. You can handle events by running a command inside the container or making an HTTP request to an endpoint it exposes. Hooks are commonly used to log container events, implement clean-up scripts, and run&#8230;<\/p>\n","protected":false},"author":1,"featured_media":477609,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.howtogeek.com\/wp-content\/uploads\/csit\/2021\/02\/748108a6.jpg?height=200p&trim=2,2,2,2","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-477608","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/477608","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=477608"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/477608\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/477609"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=477608"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=477608"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=477608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}