<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Damian Myerscough on Medium]]></title>
        <description><![CDATA[Stories by Damian Myerscough on Medium]]></description>
        <link>https://medium.com/@damianmyerscough?source=rss-b6c9596db34f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*5_fb7jpITLosybF5</url>
            <title>Stories by Damian Myerscough on Medium</title>
            <link>https://medium.com/@damianmyerscough?source=rss-b6c9596db34f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 11:11:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@damianmyerscough/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Grafana Mimir Cardinality Analysis]]></title>
            <link>https://blog.devops.dev/grafana-mimir-cardinality-analysis-553a049c6fc6?source=rss-b6c9596db34f------2</link>
            <guid isPermaLink="false">https://medium.com/p/553a049c6fc6</guid>
            <category><![CDATA[lgtm]]></category>
            <category><![CDATA[prometheus]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[high-cardinality]]></category>
            <category><![CDATA[grafana-prometheus]]></category>
            <dc:creator><![CDATA[Damian Myerscough]]></dc:creator>
            <pubDate>Mon, 03 Feb 2025 05:12:10 GMT</pubDate>
            <atom:updated>2025-03-07T17:33:48.405Z</atom:updated>
            <content:encoded><![CDATA[<p>A few weeks ago, I was looking into Grafana Cloud’s cardinality dashboard, which is available to Grafana Cloud customers. These dashboards provide valuable insights into the metrics your LGTM stack is consuming, they can help identify which metrics contribute the most to cardinality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oZFkccqrAwC4wXHYAWrhpw.png" /><figcaption>Cardinality Management Dashboard</figcaption></figure><p>The cardinality dashboards and setup are pretty hidden. If you read through Grafana’s documentation, they insinuate that these dashboards and setup are only for Grafana Enterprise, which is not entirely correct. Yes, these dashboards are open source 🙂, and yes, you can configure your LGTM stack to expose all the necessary metrics to make these dashboards work.</p><h3>Enabling Cardinality Analysis</h3><p>The cardinality endpoint within Mimir is controlled by the <em>cardinality_analysis_enabled</em> flag [<a href="https://grafana.com/docs/enterprise-metrics/latest/tenant-management/cardinality-management/#configuration">1</a>]. When this flag is enabled, it exposes an endpoint within the Mimir Query Frontend component.</p><p>Assuming you’re deploying the LGTM stack via a Helm chart, we can enable the feature by either modifying the values file or setting the value with the <strong>Helm</strong> command. The values file should look like the following:</p><pre>mimir:<br>  mimir:<br>    structuredConfig:<br>      limits:<br>        cardinality_analysis_enabled: true<br>...<br>...</pre><p>The same can be achieved using the following command:</p><pre>$ helm install mimir ... \<br>--set mimir.mimir.structuredConfig.limits.cardinality_analysis_enabled=false</pre><p>Once the <em>cardinality_analysis_enabled</em> flag is enabled, we can port-forward to the Mimir Query Frontend component and query the endpoint using the <strong>cURL</strong> command.</p><pre>$ kubectl port-forward service/mimir-query-frontend 8080 &amp;<br>$ curl -s -H &quot;X-Scope-OrgID: anonymous&quot; \<br>    &#39;http://127.0.0.1:8080/prometheus/api/v1/cardinality/label_names&#39;<br>{                                                                                                                                            14:31:08 [30/1080]<br>  &quot;label_values_count_total&quot;: 352980,<br>  &quot;label_names_count&quot;: 1287,<br>  &quot;cardinality&quot;: [<br>    {<br>      &quot;label_name&quot;: &quot;id&quot;,<br>      &quot;label_values_count&quot;: 107228<br>    },<br>    {<br>      &quot;label_name&quot;: &quot;_name_&quot;,<br>      &quot;label_values_count&quot;: 16906<br>    },<br>    {<br>      &quot;label_name&quot;: &quot;name&quot;,<br>      &quot;label_values_count&quot;: 15705<br>    },<br>    {<br>      &quot;label_name&quot;: &quot;address&quot;,<br>      &quot;label_values_count&quot;: 13636<br>    },<br>    {<br>      &quot;label_name&quot;: &quot;updationtime&quot;,<br>      &quot;label_values_count&quot;: 9091<br>    },<br>    {<br>      &quot;label_name&quot;: &quot;mountpoint&quot;,<br>      &quot;label_values_count&quot;: 7619<br>    },<br>    {<br>      &quot;label_name&quot;: &quot;container_id&quot;,<br>      &quot;label_values_count&quot;: 6893<br>    },<br>    {<br>      &quot;label_name&quot;: &quot;device&quot;,<br>      &quot;label_values_count&quot;: 6882<br>    },<br>    {<br>      &quot;label_name&quot;: &quot;summary&quot;,<br>      &quot;label_values_count&quot;: 5884<br>    },<br>    {<br>      &quot;label_name&quot;: &quot;internalticketkey&quot;,<br>      &quot;label_values_count&quot;: 5587<br>    },<br>    {<br>      &quot;label_name&quot;: &quot;creationtime&quot;,<br>      &quot;label_values_count&quot;: 5579<br>    },<br>    {<br>      &quot;label_name&quot;: &quot;ifalias&quot;,<br>      &quot;label_values_count&quot;: 5319<br>    },<br>    {<br>      &quot;label_name&quot;: &quot;internaljirakey&quot;,<br>      &quot;label_values_count&quot;: 5319<br>    },<br>    {<br>      &quot;label_name&quot;: &quot;internaljiralastupdate&quot;,<br>      &quot;label_values_count&quot;: 5311<br>    },<br>    {<br>      &quot;label_name&quot;: &quot;uid&quot;,<br>      &quot;label_values_count&quot;: 5177<br>    },<br>    {<br>      &quot;label_name&quot;: &quot;source&quot;,<br>      &quot;label_values_count&quot;: 5144<br>    },<br>    {<br>      &quot;label_name&quot;: &quot;node_guid&quot;,<br>      &quot;label_values_count&quot;: 4561<br>    },<br>    {<br>      &quot;label_name&quot;: &quot;port_guid&quot;,<br>      &quot;label_values_count&quot;: 4561<br>    },<br>    {<br>      &quot;label_name&quot;: &quot;ip&quot;,<br>      &quot;label_values_count&quot;: 4436<br>    },<br>    {<br>      &quot;label_name&quot;: &quot;instance&quot;,<br>      &quot;label_values_count&quot;: 4099<br>    }<br>  ]<br>}</pre><p>You can get a full list of endpoints available within the Cardinality Management HTTP API documentation [<a href="https://grafana.com/docs/enterprise-metrics/latest/tenant-management/cardinality-management/#cardinality-management-http-api">2</a>].</p><h3>Cardinality Management Dashboards</h3><p>The cardinality management dashboards require two plugins to be installed for them to function correctly: <a href="https://grafana.com/grafana/plugins/marcusolsson-json-datasource/">marcusolsson-json-datasource</a> and <a href="https://grafana.com/grafana/plugins/marcusolsson-treemap-panel/">marcusolsson-treemap-panel</a>.</p><p>The marcusolsson-json-datasource plugin requires you to configure a connection URL. This URL should be the cardinality endpoint exposed via the Mimir Query Frontend. We can set this value to:</p><p><a href="http://mimir-query-frontend:8080/prometheus/api/v1/cardinality/">http://mimir-query-frontend:8080/prometheus/api/v1/cardinality/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LeOwhtwsseYB3UKT3gZp9Q.jpeg" /><figcaption><em>marcusolsson-json-datasource configuration</em></figcaption></figure><p>When you click <strong>Save and Test</strong>, you might get a connection error because the endpoint returns a 404. However, this error can be ignored, and you can proceed with importing the cardinality management dashboards.</p><p>Once both plugins have been installed and the marcusolsson-json-datasource is configured, you can download the cardinality dashboards from the CERN Database and Analytics Group organization on GitHub and import them like you would import any other dashboard [<a href="https://github.com/cerndb/grafana-mimir-cardinality-dashboards">3</a>].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oZFkccqrAwC4wXHYAWrhpw.png" /><figcaption>Cardinality Management Dashboards Overview</figcaption></figure><p>The three cardinality management dashboards you imported will provide valuable insight into your metrics and their cardinality. You will be able to drill down into each metric and analyze its impact on your system.</p><p>The screenshot below shows a metric with high cardinality because serial numbers are included as a label. This isn’t ideal, but the dashboard clearly highlights the problematic label.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6tgR_lXo8zizmRfc-sx_fQ.jpeg" /><figcaption>Cardinality Management — Metrics</figcaption></figure><p>Hopefully, you now have the cardinality management dashboards set up and can start exploring your own metrics.</p><p>I’ve been exploring ways to automate a workflow that notifies users when they’re emitting high-cardinality metrics. I’ve also started looking into a chargeback model for metrics. Exciting stuff — maybe I’ll share an update on my progress soon! 😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=553a049c6fc6" width="1" height="1" alt=""><hr><p><a href="https://blog.devops.dev/grafana-mimir-cardinality-analysis-553a049c6fc6">Grafana Mimir Cardinality Analysis</a> was originally published in <a href="https://blog.devops.dev/">DevOps.dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Istio Traffic Mirroring Between Clusters]]></title>
            <link>https://medium.com/@damianmyerscough/istio-traffic-mirroring-between-clusters-3f433368a782?source=rss-b6c9596db34f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f433368a782</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[traffic-mirroring]]></category>
            <category><![CDATA[istio]]></category>
            <dc:creator><![CDATA[Damian Myerscough]]></dc:creator>
            <pubDate>Sat, 18 Nov 2023 06:18:19 GMT</pubDate>
            <atom:updated>2023-11-18T06:18:19.721Z</atom:updated>
            <content:encoded><![CDATA[<p>A few months ago, I was working on improving the reliability of a critical service. One of the biggest concerns for the service was around deployments. How could we improve the confidence that changes going out to production were not going to cause issues? Sure, we had unit tests and integration tests but that only verified what we know and expect. Since our environment uses Istio, we decided to take advantage of Istio traffic mirroring production traffic into our staging environment, what better way to find problems with new software releases than actual production traffic?</p><p>We have multiple environments consisting of development, staging, and production. Each environment is a separate Kubernetes cluster that runs Istio. In this write-up, we will mirror production traffic to the staging environment. The domain we use for production is <em>authz.example.com</em> and the staging domain is <em>authz-staging.example.com</em>.</p><blockquote><em>When Istio mirrors traffic, the FQDN appends the suffix </em>-shadow<em> e.g.</em> example.com-shadow. <em>In our example, </em>authz.example.com<em> mirrors the staging environment as </em>authz.example.com-shadow.</blockquote><p>In order to configure traffic mirroring, we need to create a <em>DestinationRule</em>, a <em>ServiceEntry,</em> and a <em>VirtualService</em>. The <em>DestinationRule</em> is needed in our environment because our ingress enforces TLS traffic e.g. all HTTP traffic is permanently redirected to HTTPS.</p><h3>VirtualService</h3><p>On the <em>authz-staging.example.com</em> cluster, we need to create/modify a <em>VirtualService</em> that includes the FQDN that is going to be mirrored with the suffix <em>-shadow.</em> Our example uses <em>authz.example.com-shadow</em>.</p><pre>apiVersion: networking.istio.io/v1beta1<br>kind: VirtualService<br>metadata:<br>  name: authz-staging-example-com<br>  namespace: example<br>spec:<br>  hosts:<br>    - authz-staging.example.com<br>    - authz.example.com-shadow<br>  http:<br>  - name: <br>    match:<br>    - uri:<br>        prefix: /<br>    route:<br>    - destination:<br>        host: example<br>        port:<br>            number: 80</pre><p>On the <em>authz.example.com</em> cluster, we need to modify VirtualService to specify where we want to mirror our production traffic and what percentage of production traffic we want to mirror.</p><pre>apiVersion: networking.istio.io/v1beta1<br>kind: VirtualService<br>metadata:<br>  name: authz-example-com<br>  namespace: example<br>spec:<br>  hosts:<br>    - authz.example.com<br>  http:<br>  - name: <br>    match:<br>    - uri:<br>        prefix: /<br>    mirror:<br>      host: authz-staging.example.com<br>      port:<br>        number: 443<br>    mirrorPercentage:<br>      value: 100<br>    route:<br>    - destination:<br>        host: example<br>        port:<br>            number: 80</pre><h3>DestinationRule</h3><p>The <em>DestinationRule</em> is only required on the <em>authz.example.com</em> cluster. This rule ensures that mirrored traffic is encrypted for the <em>authz-staging.example.com</em> domain, which is required because we enforce HTTPS traffic only.</p><pre>apiVersion: networking.istio.io/v1beta1<br>kind: DestinationRule<br>metadata:<br>  name: authz-example-com<br>  namespace: example<br>spec:<br>  host: authz-staging.example.com<br>  trafficPolicy:<br>    tls:<br>      mode: SIMPLE</pre><blockquote>If you are not enforcing HTTPS traffic, you can omit this rule.</blockquote><h3>ServiceEntry</h3><p>The <em>ServiceEntry</em> is only required on the <em>authz.example.com</em> cluster because <em>authz-staging.example.com</em> is running on another Kubernetes cluster.</p><pre>apiVersion: networking.istio.io/v1alpha3<br>kind: ServiceEntry<br>metadata:<br>  name: authz-example-com-https<br>  namespace: example<br>spec:<br>  hosts:<br>    - authz-staging.example.com<br>  ports:<br>  - number: 443<br>    name: https<br>    protocol: HTTPS<br>  location: MESH_EXTERNAL<br>  resolution: DNS</pre><p>After you have added the <em>DestinationRule</em> and <em>ServiceEntry,</em> and modified the <em>VirtualService, </em>you should see traffic flowing from your production cluster to your staging cluster.</p><p>The Istio documentation has a great demo app that you can configure for traffic mirroring [<a href="https://istio.io/latest/docs/tasks/traffic-management/mirroring/">1</a>], and I would recommend going through that demo too.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f433368a782" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[FluxCD — Deploy a Helm Chat from Git]]></title>
            <link>https://medium.com/@damianmyerscough/fluxcd-deploy-a-helm-chat-from-git-bc517d619810?source=rss-b6c9596db34f------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc517d619810</guid>
            <category><![CDATA[helm]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[flux-cd]]></category>
            <dc:creator><![CDATA[Damian Myerscough]]></dc:creator>
            <pubDate>Thu, 21 Apr 2022 04:41:38 GMT</pubDate>
            <atom:updated>2022-04-21T04:41:38.411Z</atom:updated>
            <content:encoded><![CDATA[<h3>FluxCD — Deploy a Helm Chat from Git</h3><p>I was recently working with FluxCD and needed to deploy a Helm chart from a Git repository without having to set up a Helm repository. However, I couldn’t find any good examples within the FluxCD documentation for deploying Helm charts via a Git repository.</p><p>We will be deploying a Helm chart that is hosted on GitHub[<a href="https://github.com/dmyerscough/angi-helloworld">1</a>], the Helm chart deploys a simple RESTful API that is instrumented with Prometheus and is used for demonstration purposes.</p><h4>Defining a GitRepository resource</h4><p>The first step is to define a <em>GitRepository </em>resource, this tells FluxCD what Git repository to clone. We have included an <em>ignore</em> statement that ensures we don’t archive the entire Git repository. We only want to archive the <em>charts/</em> directory within the Git repository.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7528b2c16ef9bf5e64f94914873516ca/href">https://medium.com/media/7528b2c16ef9bf5e64f94914873516ca/href</a></iframe><p>The <em>interval</em> spec on line 7 tells FluxCD how often to fetch the chart; this is a mandatory field and I would recommend setting this at around 5 minutes. The <em>url</em> spec on line 8 tells FluxCD what repository we are going to clone. On lines 9 and 10, we specify what Git branch to clone from. On GitHub, the default branch is set to <em>main</em>.</p><h4>Defining a HelmRelease</h4><p>Once you have defined your <em>GitRepository</em> resource, we can go ahead and define a <em>HelmRelease </em>resource. The following <em>HelmRelease</em> deploys the <em>angi-helloworld</em> chart from our <em>GitRepository</em> that we defined earlier.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b16b06aed9ca0a5ddfa697dca36c18df/href">https://medium.com/media/b16b06aed9ca0a5ddfa697dca36c18df/href</a></iframe><p>Let’s go over some of the specification. At line 11, we specify the path to our Helm chart; this is the path from the root of our Git repository. Lines 12 through 14 specify the <em>GitRepository</em> resource, which tells FluxCD where our Git repository is located and from where to pull our Helm chart.</p><p>Hopefully, this article has made it more clear on how to deploy a Helm chart from a Git repository without having to set up a Helm repository. Although setting up a Helm repository is pretty straightforward, there is still some overhead with the management of the Helm repository. Deploying directly from a Git repository reduces that management overhead.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc517d619810" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Monitoring Tesla Solar and Powerwall with Prometheus]]></title>
            <link>https://towardsdev.com/monitoring-tesla-solar-and-powerwall-with-prometheus-1967d88db92?source=rss-b6c9596db34f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1967d88db92</guid>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[prometheus]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[tesla]]></category>
            <category><![CDATA[grafana]]></category>
            <dc:creator><![CDATA[Damian Myerscough]]></dc:creator>
            <pubDate>Wed, 13 Apr 2022 02:42:10 GMT</pubDate>
            <atom:updated>2022-04-14T06:16:59.259Z</atom:updated>
            <content:encoded><![CDATA[<p>I have recently started looking into monitoring smart devices around my house. One of the devices that I wanted to monitor and produce historical graphs for is my Tesla Solar and Powerwall systems. I checked to see if anyone had written a Tesla Powerwall Exporter but I didn’t find any, so I decided to write my own Tesla Powerwall Exporter.</p><p>For my setup, I deployed the Tesla Powerwall Exporter on Raspberry Pi with Prometheus and had Prometheus remotely write metrics to Grafana Cloud.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wqY8ffwDtPE95q78A-HhJg.png" /><figcaption>Tesla Powerwall Monitoring</figcaption></figure><h4>Tesla Powerwall Exporter Installation</h4><p>The Tesla Powerwall Exporter can be installed in one of two ways, either by cloning the Git repository [<a href="https://github.com/dmyerscough/tesla-powerwall-exporter">1</a>] and running the <strong><em>node</em></strong> command or by running the pre-built Docker image. In this guide, I will cover using the Docker image to run the Tesla Powerwall Exporter.</p><p>After you download the Tesla Powerwall Exporter, run the following docker command.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/612a2f4874c6bcb9ec26fb98aff0f7b5/href">https://medium.com/media/612a2f4874c6bcb9ec26fb98aff0f7b5/href</a></iframe><p>Once the <strong><em>docker</em></strong> command finishes downloading, you will need to run the container with the following four environment variables.</p><ul><li><strong><em>TESLA_ADDR:</em></strong> The IP address of your Tesla Powerwall</li><li><strong><em>TESLA_EMAIL:</em></strong> Your email address</li><li><strong><em>TESLA_PASSWORD:</em></strong> The password for your Tesla Powerwall, you can find this on the Powerwall itself and it&#39;s the last five characters.</li><li><strong><em>SCRAPE_INTERVAL:</em></strong> Specifies how often we should scrape the Tesla Powerwall for metrics, by default Tesla scrapes at a five-minute interval, I found it better to scrape more frequently like 30 seconds.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f0128728d943a43d1445d9930bd295e/href">https://medium.com/media/9f0128728d943a43d1445d9930bd295e/href</a></iframe><p>Once the container starts, you can verify the exporter is running and that it is successfully scraping metrics from the Tesla Powerwall. The commands to verify this as shown below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca55ec4dda0f43687084c469c35fc9ed/href">https://medium.com/media/ca55ec4dda0f43687084c469c35fc9ed/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9cdf1a8bc81467b4f7a836d134797ea2/href">https://medium.com/media/9cdf1a8bc81467b4f7a836d134797ea2/href</a></iframe><h4><strong>Prometheus Configuration</strong></h4><p>The next step is to configure Prometheus to scrape the Tesla Powerwall Exporter and write those metrics to Grafana Cloud. Since we used Docker to run our exporter, we will use Docker to run Prometheus. The Prometheus configuration that we are going to use is shown below and we will want to save the file as <em>prometheus.yml</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ddba314c2656050a8fbbe5fd1cedd17/href">https://medium.com/media/1ddba314c2656050a8fbbe5fd1cedd17/href</a></iframe><p>The username and password fields within the <em>prometheus.yml</em> can be obtained from the Grafana Cloud portal [<a href="https://grafana.com/docs/grafana-cloud/metrics-prometheus/">2</a>]. Once insert your username and password into the <em>prometheus.yml</em> file you can start the Prometheus process by running the following command.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/852712b0a24a8a76cc297b72a4e5602c/href">https://medium.com/media/852712b0a24a8a76cc297b72a4e5602c/href</a></iframe><p>Once Prometheus starts, metrics will start being written to our Prometheus instance within Grafana Cloud.</p><h4><strong>Grafana Cloud Monitoring</strong></h4><p>Finally, we can use Grafana Cloud to import a pre-built Tesla Powerwall dashboard [<a href="https://grafana.com/grafana/dashboards/16053">3</a>]. The dashboard will give us a good insight into how our Solar and Powerwall systems are performing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lAMKKHfQsH1TyGYLh_eqqg.png" /><figcaption>Seven Day Snapshot of Tesla Powerwall and Solar</figcaption></figure><p>That&#39;s it, we are now monitoring and graphing our Tesla Powerwall and Solar system and have greater insight into our system. The Tesla app shows only five-minute snapshots whereas our exporter can give more granular results.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1967d88db92" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/monitoring-tesla-solar-and-powerwall-with-prometheus-1967d88db92">Monitoring Tesla Solar and Powerwall with Prometheus</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jest — Filenames without test or spec]]></title>
            <link>https://medium.com/@damianmyerscough/jest-filenames-without-test-or-spec-3379a141d21a?source=rss-b6c9596db34f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3379a141d21a</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[jest]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Damian Myerscough]]></dc:creator>
            <pubDate>Mon, 07 Mar 2022 07:42:25 GMT</pubDate>
            <atom:updated>2022-03-07T07:42:25.937Z</atom:updated>
            <content:encoded><![CDATA[<h3>Jest — Filenames without test or spec</h3><p>I was recently writing some unit tests with the Jest framework for a simple application, I was told not to use the default glob patterns Jest uses to detect test files e.g. <em>*.test.js</em> or <em>*.spec.js. </em>In this short article, we have created a file called “<em>myscript.js”,</em> which contains a simple function followed by two unit tests.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/19a5eb776d900a7af2044e0107beea51/href">https://medium.com/media/19a5eb776d900a7af2044e0107beea51/href</a></iframe><p>After reading the <a href="https://jestjs.io/docs/configuration#testmatch-arraystring">Jest documentation</a>, <a href="https://stackoverflow.com/questions/50660509/jest-files-names-without-test-or-spec-in-them">Stack Overflow</a>, and GitHub, I noticed that specifying a single test file without the default glob pattern always returns the message “<em>No tests found, exiting with code 1</em>”.</p><pre>❯ jest myscript.js<br>No tests found, exiting with code 1<br>Run with `--passWithNoTests` to exit with code 0<br>In /Users/damianmyerscough/project1<br>  4 files checked.<br>  testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 0 matches<br>  testPathIgnorePatterns: /node_modules/ - 4 matches<br>  testRegex:  - 0 matches<br>Pattern: myscript.js - 0 matches</pre><pre>❯ jest --testMatch myscript.js<br>No tests found, exiting with code 1<br>Run with `--passWithNoTests` to exit with code 0<br>In /Users/damianmyerscough/project1<br>  4 files checked.<br>  testMatch: answer.js - 0 matches<br>  testPathIgnorePatterns: /node_modules/ - 4 matches<br>  testRegex:  - 0 matches<br>Pattern:  - 0 matches</pre><p>The Jest documentation states you can change the default glob pattern by passing in the <strong><em>testMatch</em></strong> argument to Jest. However, passing over <em>myscript.js</em> as the <strong><em>testMatch</em></strong> glob still causes the “<em>No tests found, exiting with code 1</em>”. After playing around with Jest, I was able to have Jest identify the <em>myscript.js</em> file as a test file and run the tests within that file. I used the following command to achive this.</p><pre>❯ jest --testMatch &#39;**/myscript.js&#39;<br> PASS  ./myscript.js<br>  Multiply functionality<br>    ✓ multiply 2 by 2 to equal 4 (1 ms)<br>    ✓ verify return value is a number</pre><pre>Test Suites: 1 passed, 1 total<br>Tests:       2 passed, 2 total<br>Snapshots:   0 total<br>Time:        0.085 s, estimated 1 s</pre><p>Noitce that the <strong><em>testMatch</em></strong> glob pattern had single quotes and that the pattern was prefix with double asterisks (**).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3379a141d21a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terraform — Safely upgrading RDS instances]]></title>
            <link>https://medium.com/@damianmyerscough/terraform-safely-upgrading-rds-instances-51b31cf2a17?source=rss-b6c9596db34f------2</link>
            <guid isPermaLink="false">https://medium.com/p/51b31cf2a17</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[rds]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Damian Myerscough]]></dc:creator>
            <pubDate>Sun, 11 Jul 2021 06:21:50 GMT</pubDate>
            <atom:updated>2021-07-11T06:21:50.123Z</atom:updated>
            <content:encoded><![CDATA[<h3>Terraform — Safely upgrading RDS instances</h3><p>I was recently tasked with upgrading the instance types for one of our AWS RDS clusters. We had to perform this upgrade with as minimal impact as possible, and of course, outside our normal scheduled RDS maintenance windows. We manage our RDS clusters with Terraform and ensure that apply_immediately is set to false; this ensures that cluster operations are not applied immediately but instead during our next maintenance window.</p><p>Since I was upgrading the instance types, I bumped into a problem where I could not have the changes applied using the <a href="https://docs.aws.amazon.com/cli/latest/reference/rds/apply-pending-maintenance-action.html">apply-pending-maintenance-action</a> argument. I am not sure why this didn’t recognize the RDS instance type change. However, I managed to upgrade the RDS instances one at a time using an alternative method.</p><pre>Note: If you don&#39;t have two reader instances, I would recommend creating an additional temporary reader instance to avoid having the read endpoint becoming unavailable.</pre><h4>Cluster Status</h4><p>The first step is to identify what RDS instance is the writer and what instances are the readers. The reason we want to upgrade the readers first is to avoid having the databases become unavailable for writes during the upgrade. We can identify what instances are readers and what instance is the writer by using the AWS command-line utility with the describe-db-cluster subcommand as shown below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d179e37edd7768d7a43a250b00140f71/href">https://medium.com/media/d179e37edd7768d7a43a250b00140f71/href</a></iframe><p>The <em>IsClusterWriter </em>field shows what instance is the writer and what instance is the reader. When this boolean value is true, that indicates the instance is a writer instance and we should avoid upgrading that instance first. In our output, you can see that <em>spinnaker-prod-1</em> and <em>spinnaker-prod-2 </em>are the reader instances so we can upgrade one of those first.</p><pre>Note: Don&#39;t upgrade both readers at the same time; this causes the reader endpoint to become unavailable.</pre><h4>Verifying and upgrading</h4><p>Before we perform the upgrade, we can verify that Terraform has made the modifications to the instance types.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9604517c57cef602aad805df2a19b58b/href">https://medium.com/media/9604517c57cef602aad805df2a19b58b/href</a></iframe><p>Once we have confirmed our modification is pending on the reader instance, we can go ahead and perform the upgrade using the following AWS command line with the --apply-immediately argument.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/81a59e9421386be390eab3e6a9d1a709/href">https://medium.com/media/81a59e9421386be390eab3e6a9d1a709/href</a></iframe><p>The --apply-immediately argument starts the re-creation of our reader instance with the new instance type. While the upgrade is running, the reader instance becomes unavailable but the writer and secondary reader still accept write and read traffic.</p><h4>Failing over the RDS Cluster</h4><p>Once the reader instance type has been upgraded, we can confirm that the reader instance is available and accepting read traffic using the following AWS command.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b194944510b7aae5aa9f2614457e1c26/href">https://medium.com/media/b194944510b7aae5aa9f2614457e1c26/href</a></iframe><p>When the reader instance is available, we can go ahead and upgrade the second reader instance using the same steps as before. After both readers are upgraded and available, we can failover the cluster so that the current writer can be upgraded. During the failover, the cluster is not able to serve writes while the promotion stage occurs. The command to perform the failover is shown below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2429e2e81a7195b4090a307ea8e37fec/href">https://medium.com/media/2429e2e81a7195b4090a307ea8e37fec/href</a></iframe><h4>Completing the upgrade</h4><p>Once the writer instance has completed the failover and becomes a reader instance, we can follow the same steps in <em>Verifying and upgrading </em>section<em> </em>to upgrade the new reader instance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51b31cf2a17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GCP — Monitoring Quotas with Prometheus]]></title>
            <link>https://medium.com/@damianmyerscough/gcp-monitoring-quotas-with-prometheus-f6e4d378d289?source=rss-b6c9596db34f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6e4d378d289</guid>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[prometheus]]></category>
            <category><![CDATA[prometheus-operator]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Damian Myerscough]]></dc:creator>
            <pubDate>Mon, 01 Jun 2020 05:20:26 GMT</pubDate>
            <atom:updated>2020-06-01T05:20:26.212Z</atom:updated>
            <content:encoded><![CDATA[<h3>GCP — Monitoring Quotas with Prometheus</h3><p>A few months ago, my team was setting up monitoring for GCP resource quotas and we wanted to integrate it into our Prometheus monitoring solution. Monitoring GCP resource quotas is important; if any of these quotas are hit, then that GCP resource becomes unavailable and can impact your environment. For example, we were not monitoring how many <em>CPU Cores</em> were available within one of our projects and our dataflow jobs came to a grinding halt due to the <em>CPU Cores</em> quota being exhausted.</p><p>Since our environment relies heavily on Kubernetes, we leverage Kubernetes as much as possible, including running Prometheus exporters. In this short article, we will setup and configure the <em>gcp-quota-exporter</em> that can be scraped by Prometheus.</p><h4>Creating Service Account for Quotas</h4><p>In order for the <em>gcp-quota-exporter</em> to query GCP resource quotas, we need to create a service account with the <em>compute.projects.get</em> and <em>compute.regions.list </em>privileges. Technically, you could create a custom role with just these two privileges; however, this article demonstrates how to use the <em>compute.viewer</em> role.</p><p>We can create a service account called <em>gcp-quota-exporter</em> and assign the service account <em>compute.viewer</em> privileges using the following commands.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6596d1e9320a5f7b747d698f243d68cf/href">https://medium.com/media/6596d1e9320a5f7b747d698f243d68cf/href</a></iframe><h4>Monitoring Quotas from Kubernetes</h4><p>After we have created the service account, we need to generate a service account key that we store as a Kubernetes secret. The following commands create a service account key and create a secret from that key.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0c1773ab6117ee2d0dbe9aa4fd80d57/href">https://medium.com/media/f0c1773ab6117ee2d0dbe9aa4fd80d57/href</a></iframe><p>Once the service account key has been generated and uploaded as a Kubernetes secret, we can go ahead and create the Kubernetes deployment using the following deployment file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/53844281165822abdb1704d95af74845/href">https://medium.com/media/53844281165822abdb1704d95af74845/href</a></iframe><p>The <em>gcp-quota-exporter-deployment.yaml</em> file can be applied using the <strong>kubectl</strong> command. Once the <em>gcp-quota-exporter</em> has been deployed, you can verify the metrics using Kubernetes port-forwarding as shown below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d09346a9367ba5fbddd98f069c67ef63/href">https://medium.com/media/d09346a9367ba5fbddd98f069c67ef63/href</a></iframe><p>From our Prometheus instance, we can query what percentage of <em>CPU Cores </em>are being used in <em>us-central1</em> as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BZTuwtFhY-71z81_wZXEQg.png" /><figcaption>Percentage of CPU Cores being used in us-central1</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6e4d378d289" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GCP — Secure Bastion]]></title>
            <link>https://medium.com/@damianmyerscough/gcp-secure-bastion-9aa61d6a9e65?source=rss-b6c9596db34f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9aa61d6a9e65</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[gcpsecurity]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[identity-aware-proxy]]></category>
            <category><![CDATA[gcp]]></category>
            <dc:creator><![CDATA[Damian Myerscough]]></dc:creator>
            <pubDate>Thu, 14 May 2020 18:53:27 GMT</pubDate>
            <atom:updated>2020-05-14T18:53:27.696Z</atom:updated>
            <content:encoded><![CDATA[<h3>GCP — Secure Bastion</h3><p>Over the past year, I have been using Google Cloud Platform (GCP) extensively. One of the problems our engineering teams faced was accessing environments in a secure manner without having engineers jump through hoops. Our on-premise solution used a VPN that allowed engineers to access an internal bastion host. However, due to the vast number of complaints with the VPN solution, we decided to review alternative ways for engineers to access our bastion systems that were running in GCP.</p><p>Our security team is pretty darn strict about exposing hosts on the public Internet, including hardened bastion hosts. We had to ensure that our bastion hosts were not exposed to the public Internet and that they did not rely on a VPN. During our research, we came across Googles Identity Aware Proxy that allowed us to expose SSH and TCP services over the Internet in a secure manner.</p><p>How does the Identity Aware Proxy make our bastion more secure? The simple answer is that our SSH connection is routed via the Identity Aware Proxy managed by Google [1], which forwards connections to the appropriate hosts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/0*U2-ulbyZ_pcEYug6" /></figure><h4>Enabling IAP</h4><p>The first step to setting up our secure bastion is to enable the Google Identity Aware Proxy (IAP) API. When you provision a project for the first time, Googles IAP is disabled by default. Enable the API using the <strong><em>gcloud</em></strong> command as shown below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6da9e2e9e2057d397d7214241888f28/href">https://medium.com/media/f6da9e2e9e2057d397d7214241888f28/href</a></iframe><p>When you have enabled the Identity Aware Proxy API, configure the OAuth consent screen from the Identity Aware Proxy page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gkUFG25j8nZ3svmVGJPuqg.png" /></figure><p>Configuring the OAuth consent screen is straightforward, you’ll be asked what user type you want to permit; either internal or external types are acceptable. However, the internal user type requires you to have a G Suite organization.</p><h4>Allowing Google IAP through our firewall</h4><p>Before we create our bastion instance, we need to create a firewall rule to allow Google’s IAP service access to port 22. The Google IAP service requires you to permit access from 35.235.240.0/20, which is an IP range owned by Google. Next, we configure our firewall rule to work on network tags, which allows us to tag our bastion host with a tag and have the firewall rule automatically applied.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c4258273cd35fce3332cb13c4e9c7440/href">https://medium.com/media/c4258273cd35fce3332cb13c4e9c7440/href</a></iframe><h4>Creating your bastion host</h4><p>Now that we have our firewall rule in place, we can create our bastion host. Using the <strong><em>gcloud</em></strong> command, create a bastion host called: “bastion01” and ensure that it does not have a public IP address.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ec9d425ba7429ea8e98897a7decc5751/href">https://medium.com/media/ec9d425ba7429ea8e98897a7decc5751/href</a></iframe><p>When the bastion host finishes provisioning, you will see the host appear under “<em>SSH and TCP Resources</em>” within the Identity-Aware Proxy tab. Select your bastion host and assign the “<em>IAP-secured Tunnel User</em>” to users who you would like to be able to access the bastion host.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6nz9oYKX5QknPdJAWn3S-w.png" /><figcaption>Assigning the user IAP-secured Tunnel User</figcaption></figure><h4>Connecting to your Bastion</h4><p>Now that we have enabled the Identity-Aware Proxy API, configured the firewall, and provisioned our bastion host, we can finally SSH into the bastion host. Since we provisioned our bastion host without a public IP address, we need to use the <strong><em>gcloud</em></strong> command to SSH to our bastion and tunnel through IAP, this can be done using the following command.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/95a4c25566eb647133f446e4b1b7fbf2/href">https://medium.com/media/95a4c25566eb647133f446e4b1b7fbf2/href</a></iframe><p>You may be wondering if it&#39;s possible to port-forward through IAP using the <strong><em>gcloud</em></strong> command. Good news! All you need to do is pass in the extra arguments at the end of the <strong><em>gcloud</em></strong> command as shown below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a535258b1f559ea21477c872c67377bc/href">https://medium.com/media/a535258b1f559ea21477c872c67377bc/href</a></iframe><p>[1] <a href="https://cloud.google.com/iap/">https://cloud.google.com/iap/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9aa61d6a9e65" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git Bisect — Finding breaking commits]]></title>
            <link>https://medium.com/swlh/git-bisect-finding-breaking-commits-66015539f0e5?source=rss-b6c9596db34f------2</link>
            <guid isPermaLink="false">https://medium.com/p/66015539f0e5</guid>
            <category><![CDATA[git-bisect]]></category>
            <category><![CDATA[bugs]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Damian Myerscough]]></dc:creator>
            <pubDate>Tue, 12 May 2020 05:39:20 GMT</pubDate>
            <atom:updated>2020-05-14T04:21:42.841Z</atom:updated>
            <content:encoded><![CDATA[<h3>Git Bisect — Finding breaking commits</h3><p>I have been working on a new project that involves working on a large mono-repo. When a pull request is made against the repository, a large number of unit and integration tests are run against the pull request — these tests can usually take anywhere from ten minutes to over 30 minutes to complete.</p><p>One of the most frustrating parts of this process is that some engineers have permission to land their pull requests without letting the integration tests complete (bad practice, but that is another problem). One Git feature that I have grown to love is <strong><em>git bisect</em></strong>, this subcommand helps you find bugs that were introduced into your project by performing a binary search over a number of Git commits.</p><h4>How does git bisect find bad commits?</h4><p>With <strong><em>git bisect</em></strong> you start by specifying a <em>bad</em> commit that contains the bug, e.g a failing unit/integration test. You then specify a <em>good</em> commit that does not have the failing test. Without a unit/integration test, <strong><em>git bisect</em></strong> cannot identify the bad commit.</p><h4>Finding a bad commit</h4><p>For demo purposes, you can clone [<a href="https://github.com/dmyerscough/demo">1</a>] repository that has a simple unit test for the Fibonacci sequence. When you clone the repository, the commit <em>HEAD</em> contains broken changes that cause the unit test to fail, we can use <strong><em>git bisect</em></strong> to identify the commit that introduces the breaking change for our unit test.</p><p>First, let’s verify the unit test is failing on the <em>HEAD</em> of the repository.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c3a4cc6938308c88c0f94bbbc880029/href">https://medium.com/media/4c3a4cc6938308c88c0f94bbbc880029/href</a></iframe><p>Now that we have verified the <em>HEAD</em> of the repository is bad, we need to find a commit where the unit test was running successfully. Since we are dealing with a small repository we can check out the initial commit and run the unit test.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b16e588e1f772f43e7e02660938c312/href">https://medium.com/media/7b16e588e1f772f43e7e02660938c312/href</a></iframe><p>After checking out the initial commit, the unit test successfully runs. Now that we have our <em>bad</em> commit (<em>HEAD</em>) and our good commit (<em>6dc3236976b</em>) we can start using <strong><em>git bisect </em></strong>to identify what commit caused the unit test to fail.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2dfbe7974b1e328ec0008e0bc9da715f/href">https://medium.com/media/2dfbe7974b1e328ec0008e0bc9da715f/href</a></iframe><p>Let us break down the steps we just ran. The first command <strong><em>git bisect start </em></strong>is required before we can state our good and bad commit. The second command, <strong><em>git bisect bad HEAD</em></strong> sets the <em>HEAD</em> of the repository to indicate a bad state since our unit test was failing. The third command, <strong><em>git bisect good 6dc3236976b</em></strong> specify the commit where our unit test was successful. After specifying the good and bad commits, Git performs a checkout of the commit that is in the middle of the good and bad commit. We then run the unit test on the current commit (<em>85c501f4773</em>) and can see that the unit test passes. Since the test passes, we indicate the current commit is good by running <strong><em>git bisect good</em></strong>. After indicating to <strong><em>git bisect </em></strong>that the commit was good, git checks out another commit (<em>32197027bf9</em>) where we will against run the unit tests, this time the unit tests fails so we indicate that the current commit is bad by running <strong><em>git bisect bad</em></strong>. After flagging the bad commit, <strong><em>git bisect</em></strong> returns the commit where the unit test first started to fail. We have successfully identified which commit caused the unit test to fail, and you can see in the commit we moved yield up one level causing the output to be incorrect.</p><h4>Can we automate finding bad commits?</h4><p>On a larger codebase, manually running tests and telling <strong><em>git bisect</em></strong> if the test was good or bad can be very tedious. However, <strong><em>git bisect</em></strong> has the ability to run a script or in our case run the unit test directly, the only requirement is that the script or the unit test provides an exit status of zero or one, with zero being good and one being bad.</p><p>The following commands show <strong><em>git bisect</em></strong> running our unit test directly and identifying the bad commit that was introduced.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ccb48be453462b8b736c68a4044d576e/href">https://medium.com/media/ccb48be453462b8b736c68a4044d576e/href</a></iframe><p>[1] <a href="https://github.com/dmyerscough/demo">https://github.com/dmyerscough/demo</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66015539f0e5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/git-bisect-finding-breaking-commits-66015539f0e5">Git Bisect — Finding breaking commits</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spinnaker — My pods shrunk]]></title>
            <link>https://medium.com/@damianmyerscough/spinnaker-my-pods-shrunk-a1444381a2b2?source=rss-b6c9596db34f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1444381a2b2</guid>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[spinnaker]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <dc:creator><![CDATA[Damian Myerscough]]></dc:creator>
            <pubDate>Wed, 05 Feb 2020 21:43:06 GMT</pubDate>
            <atom:updated>2020-02-05T21:43:06.497Z</atom:updated>
            <content:encoded><![CDATA[<h3>Spinnaker — My pods shrunk</h3><p>We have been running Spinnaker in production now for over half a year, and use Spinnaker for all our application and infrastructure application deployments. This has enabled engineers to run their own deployments without requiring Site Reliability Engineers to assist. However, there have been some gotchas when engineers run deployments; one of the most common issues was a deployment replica count resetting during a deployment.</p><blockquote>A deployment replica count being reset during increased traffic is pretty much going to cause an outage if you don’t have enough pods available to service requests.</blockquote><p>Let&#39;s walk through a simple pipeline that deploys an Nginx container with a replica count hardcoded to one. You can copy the following deployment manifest into a pipeline that has a stage “<em>Deploy (Manifest)</em>”.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/59c4541650ec8ac06d1edd930f9aafe2/href">https://medium.com/media/59c4541650ec8ac06d1edd930f9aafe2/href</a></iframe><p>Since we only have one step in our pipeline, we can trigger a manual deployment from the Spinnaker web interface. From the command-line, we can verify our initial deployment sets the replica count to one and then scale up our Nginx deployment.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/91341a9a06c20a48dac25eec3818f3a0/href">https://medium.com/media/91341a9a06c20a48dac25eec3818f3a0/href</a></iframe><p>When we go to the Spinnaker web interface, we can see our Nginx replica count is set to five.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rxXiCVJmg7hhL9moIOFPnQ.png" /><figcaption>Nginx deployment — Replica count</figcaption></figure><p>Now, the interesting part, when we re-run our pipeline, the replica count in our Nginx deployment shrinks to the hardcoded value of one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BC2vp8mblH7qSsxGNoUqOQ.png" /><figcaption>Nginx deployment — Pipeline resetting our replica count</figcaption></figure><p><em>This can be a disaster if you leverage Kubernetes </em><strong><em>H</em></strong><em>orizontal </em><strong><em>P</em></strong><em>od </em><strong><em>A</em></strong><em>utoscaler. During an auto-scaling event caused by increased traffic, a new deployment/re-run of your pipeline will cause your environment to become under-provisioned.</em></p><p>The fix to this problem is as simple as using the “<em>strategy.spinnaker.io/use-source-capacity</em>” annotation within our deployment manifest. This annotation instructs Spinnaker to set the replica count to the current value of the running deployment. If our <em>Kubernetes </em><strong><em>H</em></strong><em>orizontal </em><strong><em>P</em></strong><em>od </em><strong><em>A</em></strong><em>utoscaler</em> scales up our deployment or if an engineer increases the replica count manually, a re-run of our deployment pipeline will not reset the replica count.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ab1796c157a821cf25a93aa6ef10531/href">https://medium.com/media/4ab1796c157a821cf25a93aa6ef10531/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1444381a2b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>