<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hans Christian Bartelt</title>
    <description>The latest articles on DEV Community by Hans Christian Bartelt (@hcbartelt).</description>
    <link>https://dev.to/hcbartelt</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F121754%2F4b5e9bac-8bd3-4009-9fd8-25ae67f03857.jpg</url>
      <title>DEV Community: Hans Christian Bartelt</title>
      <link>https://dev.to/hcbartelt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hcbartelt"/>
    <language>en</language>
    <item>
      <title>GraphQL Mesh Readiness &amp; Health Check</title>
      <dc:creator>Hans Christian Bartelt</dc:creator>
      <pubDate>Tue, 28 Feb 2023 17:02:00 +0000</pubDate>
      <link>https://dev.to/hcbartelt/graphql-mesh-readiness-health-check-48pi</link>
      <guid>https://dev.to/hcbartelt/graphql-mesh-readiness-health-check-48pi</guid>
      <description>&lt;p&gt;In container orchestration platforms like Kubernetes, health checks and readiness checks are probes that help to ensure the reliability and availability of containerized applications.&lt;/p&gt;

&lt;p&gt;When &lt;a href="https://the-guild.dev/graphql/mesh/docs/getting-started/deploy-mesh-gateway#deploy-mesh-with-mesh-start-on-nodejs" rel="noopener noreferrer"&gt;deploying GraphQL Mesh with &lt;code&gt;mesh start&lt;/code&gt; on Node.js&lt;/a&gt;, the built-in Yoga Server provides the endpoints &lt;code&gt;/healthcheck&lt;/code&gt; and &lt;code&gt;/readiness&lt;/code&gt; out of the box.&lt;/p&gt;

&lt;h2&gt;
  
  
  Health Check
&lt;/h2&gt;

&lt;p&gt;Health check probes periodically check the container's internal state to ensure it's healthy.&lt;/p&gt;

&lt;p&gt;Endpoint &lt;code&gt;/healthcheck&lt;/code&gt; returns &lt;code&gt;HTTP 200&lt;/code&gt; when successful:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl "http://localhost:4000/healthcheck" -v

&amp;gt; GET /healthcheck HTTP/1.1
&amp;gt; Host: localhost:4000
&amp;gt; User-Agent: curl/7.86.0
&amp;gt; Accept: */*
&amp;gt;
&amp;lt; HTTP/1.1 200 OK
&amp;lt; Date: Tue, 28 Feb 2023 10:56:42 GMT
&amp;lt; Connection: keep-alive
&amp;lt; Keep-Alive: timeout=5
&amp;lt; Content-Length: 0
&amp;lt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Readiness Check
&lt;/h2&gt;

&lt;p&gt;Readiness probes check whether the container is ready to handle traffic:&lt;/p&gt;

&lt;p&gt;Endpoint &lt;code&gt;/readiness&lt;/code&gt; returns &lt;code&gt;HTTP 204&lt;/code&gt; when ready or &lt;code&gt;HTTP 503&lt;/code&gt; when not.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl "http://localhost:4000/readiness" -v

&amp;gt; GET /readiness HTTP/1.1
&amp;gt; Host: localhost:4000
&amp;gt; User-Agent: curl/7.86.0
&amp;gt; Accept: */*
&amp;gt;
&amp;lt; HTTP/1.1 204 No Content
&amp;lt; Date: Tue, 28 Feb 2023 10:56:44 GMT
&amp;lt; Connection: keep-alive
&amp;lt; Keep-Alive: timeout=5
&amp;lt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Kubernetes Example
&lt;/h2&gt;

&lt;p&gt;The Kubernetes &lt;code&gt;livenessProbe&lt;/code&gt; and &lt;code&gt;readinessProbe&lt;/code&gt; configuration would look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;livenessProbe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;httpGet&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/healthcheck&lt;/span&gt;
    &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http&lt;/span&gt;
  &lt;span class="na"&gt;initialDelaySeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;
  &lt;span class="na"&gt;periodSeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10&lt;/span&gt;
&lt;span class="na"&gt;readinessProbe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;httpGet&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/readiness&lt;/span&gt;
    &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http&lt;/span&gt;
  &lt;span class="na"&gt;initialDelaySeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;
  &lt;span class="na"&gt;periodSeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>graphql</category>
      <category>mesh</category>
      <category>container</category>
      <category>kubernetes</category>
    </item>
  </channel>
</rss>
