<?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 Tristan Colgate-McFarlane on Medium]]></title>
        <description><![CDATA[Stories by Tristan Colgate-McFarlane on Medium]]></description>
        <link>https://medium.com/@tristan_96324?source=rss-caa286475a71------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*k0UsYonWh-Ktfne5.</url>
            <title>Stories by Tristan Colgate-McFarlane on Medium</title>
            <link>https://medium.com/@tristan_96324?source=rss-caa286475a71------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 12:18:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tristan_96324/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[Prometheus: K8s Cronjob alerts]]></title>
            <link>https://medium.com/@tristan_96324/prometheus-k8s-cronjob-alerts-94bee7b90511?source=rss-caa286475a71------2</link>
            <guid isPermaLink="false">https://medium.com/p/94bee7b90511</guid>
            <category><![CDATA[prometheus]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Tristan Colgate-McFarlane]]></dc:creator>
            <pubDate>Sun, 04 Mar 2018 12:53:42 GMT</pubDate>
            <atom:updated>2018-03-04T12:58:23.060Z</atom:updated>
            <content:encoded><![CDATA[<p>Kubernetes <a href="https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/#cron-jobsL">Jobs</a> and <a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/">Cronjobs</a> are powerful tools that present some interesting challenges to monitoring. We’ll demonstrate rules using <a href="https://github.com/kubernetes/kube-state-metrics">kube-state-metrics</a> and Prometheus to monitor and alert on failed jobs. We’ll discuss how the rules were formulated, and how to leverage Prometheus label matching techniques for advanced alerting.</p><p>I have attempted to demonstrate the workflow for developing such alerts. The final result, for the bored or impatient, can be found <a href="https://github.com/tcolgate/prometheus-rules/blob/master/kubernetes/cron.yaml">here</a>.</p><p>Alerting of traditional Unix cronjobs was “simple”, if the job failed you’d get an email. Most job scheduling systems that have followed have provided the same experience, Kubernetes does not. One <a href="https://www.robustperception.io/monitoring-batch-jobs-in-python/">excellent approach</a> to alerting jobs is to use the Prometheus push gateway, allowing us to push richer metrics than simple success/failure. This approach has it’s downsides; we have to update the code for our jobs, we also have to explicitly configure a push gateway location and update it if it changes (a burden alleviated by the pull based metrics for long lived workloads). Tools such as <a href="https://sentry.io/welcome/">Sentry</a> can also be used, but will also require changes to simple jobs.With some effort we can achieve an easy middle ground.</p><h4>K8s Jobs and Cronjobs</h4><p>In Kubernetes <a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/">cronjobs</a> are built on <a href="https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/">jobs</a> which are themselves built on pods. Jobs are powerful things allowing us to implement several different workflows, the combination of options can be overwhelming compared to a traditional Unix cron job.</p><p>The variety of options makes it difficult to establish one simple rule for alerting failed jobs. Things are easier if we restrict ourselves to a simpler subset of possible options. We will focus on the following style of job:</p><ul><li>Run periodically on a schedule</li><li>Non-concurrent</li></ul><p>Concurrent jobs permit a second instance of a task to start if a previous task for a job is still running, this is the behaviour of a classic cron task. I have focused on non-concurrent tasks. I suggest that non-concurrent tasks have the desired behaviour for the majority of typical systems administration tasks (database backups, batch reindexes and such like), people often overlook the possibility of job runs overlapping.</p><p>The relationship between cronjobs and jobs makes the task ahead difficult. To make our life easier we will put one requirement on the jobs we create, they will have to include a label that associates them with the original cronjob. Below we present an example of our ideal cronjob:</p><pre>apiVersion: batch/v1beta1<br>kind: CronJob<br>metadata:<br>  name: our-task<br>spec:<br>  schedule: &quot;*/5 * * * *&quot;<br>  successfulJobsHistoryLimit: 3<br>  concurrencyPolicy: Forbid<br>  jobTemplate:<br>    metadata:<br>      labels:<br>        cronjob: our-task # &lt;-- match created jobs with the cronjob<br>    spec:<br>      backoffLimit: 3<br>      template:<br>        metadata:<br>          labels:<br>            cronjob: our-task<br>        spec:<br>          containers:<br>          - name: our-task<br>            command:<br>            - /user/bin/false<br>            image: alpine<br>          restartPolicy: Never</pre><h4>Building our alert</h4><p>We are also going to need some metrics to get us started. K8s does not provide us any by default, but fortunately we can leverage <a href="https://github.com/kubernetes/kube-state-metrics">kube-state-metrics</a> (you will need at least version 1.2). Once installed we will get the following metrics for the above job:</p><pre>kube_cronjob_labels{<br>  cronjob=&quot;our-task&quot;,<br>  namespace=&quot;default&quot;} 1<br>kube_job_created{<br>  job=&quot;our-task-1520165700&quot;,<br>  namespace=&quot;default&quot;} 1.520165707e+09                                   <br>kube_job_failed{<br>  condition=&quot;false&quot;,<br>  job=&quot;our-task-1520165700&quot;,<br>  namespace=&quot;default&quot;} 0<br>kube_job_failed{<br>  condition=&quot;true&quot;,<br>  job=&quot;our-task-1520165700&quot;,<br>  namespace=&quot;default&quot;} 1<br>kube_job_labels{<br>  job=&quot;our-task-1520165700&quot;,<br>  label_cronjob=&quot;our-task&quot;,<br>  namespace=&quot;default&quot;} 1</pre><p>This shows the primary set of metrics we will be using to construct our alert. What is not shown above is the status of the cronjob. The big challenge with K8s cronjob alerting is that cronjobs themselves do not possess any status information, beyond the last time the cronjob created a job. The status information only exists on the job that the cronjob creates.</p><p>In order to determine if our cronjob is failing, our first order of business is to find which jobs we should be looking at. A K8s cronjob creates new job objects and keeps a number of them around to help us debug the runs of our jobs. We have to be determine which job corresponds to the last run of our cronjob. If we have added the cronjob label to the jobs as above, we can find the last run time of the jobs for a given cronjob as follows:</p><pre>          max(<br>            kube_job_status_start_time<br>            * ON(exported_job) GROUP_RIGHT()<br>            kube_job_labels{label_cronjob!=&quot;&quot;}<br>          ) BY (exported_job, label_cronjob)</pre><p>This query demonstrates an important technique when working with <strong>kube-state-metrics</strong>. For each API object it exported data on, it exports a time series including all the labels for that object. These time series have a value of 1. As such we can join the set of labels for an object onto the metrics about that object by multiplication.</p><p>Depending on how your Prometheus instance is configured, the value of the <strong>job </strong>label on your metrics will likely be “kube-state-metrics”. <strong>kube-state-metrics </strong>adds a job label itself with the name of the job object. Prometheus resolves this collision of label names by including the raw metric’s label as an <strong>exported_job </strong>label.</p><p>Since we are querying the start time of jobs, and there should only every be one job with a given name, you may wonder why we need the max aggregation. Manually plugging the query into Prometheus may convince you that it is unnecessary. Consider though that you may have multiple instances of <strong>kube-state-metrics</strong> running for redundancy. Using max ensures our query is valid even if we have multiple instances of <strong>kube-state-metrics</strong> running. Issues of duplicate metrics are common when constructing production recording rules and alerts.</p><p>We can find the start time of the most recent job for a given cronjob by finding the maximum of all job start times as follows:</p><pre>          max(<br>            kube_job_status_start_time                                                                            <br>            * ON(exported_job) GROUP_RIGHT()<br>            kube_job_labels{label_cronjob!=&quot;&quot;}<br>          ) BY (label_cronjob),</pre><p>The only difference between this and the previous query is in the labels used for the aggregation. Now that we have the start time of each job, and the start time of the most recent job, we can do a simple equality match to find the start time of the most recent job for a given cronjob. We will create a metric for this</p><pre>  - record: job_cronjob:kube_job_status_start_time:max                                                            <br>    expr: |<br>      label_replace(<br>        label_replace(<br>          max(<br>            kube_job_status_start_time<br>            * ON(exported_job) GROUP_RIGHT()<br>            kube_job_labels{label_cronjob!=&quot;&quot;}<br>          ) BY (exported_job, label_cronjob)<br>          == ON(label_cronjob) GROUP_LEFT()<br>          max(<br>            kube_job_status_start_time<br>            * ON(exported_job) GROUP_RIGHT()<br>            kube_job_labels{label_cronjob!=&quot;&quot;}<br>          ) BY (label_cronjob),<br>          &quot;job&quot;, &quot;$1&quot;, &quot;exported_job&quot;, &quot;(.+)&quot;),<br>        &quot;cronjob&quot;, &quot;$1&quot;, &quot;label_cronjob&quot;, &quot;(.+)&quot;)</pre><p>In addition to the equality test, we have also taken the opportunity to adjust the labels to be a little more aesthetically pleasing. Now that we have the most recently started job for a given cronjob, it is a simple step to find which, if any, have failed attempts:</p><pre>- record: job_cronjob:kube_job_status_failed:sum<br>    expr: |<br>      clamp_max(<br>        job_cronjob:kube_job_status_start_time:max,<br>      1)<br>      * ON(job) GROUP_LEFT()<br>      label_replace(<br>        label_replace(<br>          (kube_job_status_failed != 0),<br>          &quot;job&quot;, &quot;$1&quot;, &quot;exported_job&quot;, &quot;(.+)&quot;),<br>        &quot;cronjob&quot;, &quot;$1&quot;, &quot;label_cronjob&quot;, &quot;(.+)&quot;)</pre><p>The initial clamp_max clause is used to transform our start times metric into a set of time series we can use purely for the purpose of label matching to filter another set of metrics. Multiplication by 1 (or addition of 0), is a useful means of filter and merging time series and it is well worth taking the time to understand the technique. We adjust the labels on the raw <strong>kube_job_status_failed </strong>to match our start time metric so ensure the labels have the same meaning as those on our <strong>job_cronjob:kube_job_status_start_time:max </strong>metric. The label matching on the multiplication will then perform our filtering. We now have a metric containing the set of most recently failed jobs, labelled by their parent cronjob. Constructing an alert from here is trivial:</p><pre>- alert: CronJobStatusFailed<br>    expr: |<br>      job_cronjob:kube_job_status_failed:sum<br>      * ON(cronjob) GROUP_RIGHT()<br>      kube_cronjob_labels<br>      &gt; 0<br>    for: 1m<br>    annotations:<br>      description: &#39;{{ $labels.cronjob }} last run has failed {{ $value }} times.&#39;</pre><p>We use the <strong>kube_cronjob_labels </strong>here to merge in labels from the original cronjob. By labelling cronjobs with Slack channel, email address, or OpsGenie team information, alerts can be routed to the specific team that owns the job.</p><h4>Conclusion</h4><p>Constructing Prometheus recording rules and alerts can be tricky. The example presented above, and in the <a href="http://- alert: CronJobStatusFailed     expr: |       job_cronjob:kube_job_status_failed:sum       * ON(cronjob) GROUP_RIGHT()       kube_cronjob_labels       &gt; 0     for: 1m     annotations:       description: &#39;{{ $labels.cronjob }} last run has failed {{ $value }} times.&#39;">Apdex</a> alerting article, are fairly typical of the techniques needed for more advanced alerts. Hopefully these two articles have given you some insight and tips for your own alerting needs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94bee7b90511" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prometheus: Apdex alerting]]></title>
            <link>https://medium.com/@tristan_96324/prometheus-apdex-alerting-d17a065e39d0?source=rss-caa286475a71------2</link>
            <guid isPermaLink="false">https://medium.com/p/d17a065e39d0</guid>
            <category><![CDATA[apdex]]></category>
            <category><![CDATA[prometheus]]></category>
            <category><![CDATA[monitoring]]></category>
            <dc:creator><![CDATA[Tristan Colgate-McFarlane]]></dc:creator>
            <pubDate>Sat, 03 Mar 2018 17:57:30 GMT</pubDate>
            <atom:updated>2018-03-03T17:57:30.061Z</atom:updated>
            <content:encoded><![CDATA[<p>I’m going to take a break from our series on Production Kubernetes to write up a couple of smaller articles on Prometheus. This article will give an overview of Apdex, and go on to describe a practical approach to implementing Apdex alerts in Prometheus.</p><h4>Why Apdex?</h4><p>Apdex provides a single number that attempts to quantify a user’s experience of requests to a web service. We first decide what we consider to be an acceptable response time from our service, in Apdex terminology this is called the <strong>T </strong>value. We then classifies requests as follows:</p><ul><li>All error responses are intolerable.</li><li>All responses qucker than <strong>T </strong>are satisfactory.</li><li>All responses slower than <strong>T</strong>, but<strong> </strong>quicker than <strong>4T </strong>are tolerable.</li><li>All responses slower than <strong>4T</strong> are intolerable.</li></ul><p>The Apdex score for a service, over a given time, is a ratio of intolerable vs satisfactory and tolerable responses.</p><pre>apdex = (satisfactory + (tolerable / 2)) / total</pre><p>High error rates and slow response times will result in a lower Apdex score. By encapsulating errors and high latency in a single metric Apdex attempts to quantify our users experience of our service as a single number. Since a low Apdex score implies either high rates of errors or undesirable response latencies it is a reliable metric to alarm on. While a low Apdex score reliably indicates issues, depending on where it is measured from, a high score may not guarantee all is well.</p><h4>Application metrics</h4><p>Since Apdex represents user experience we would ideally measure it externally from the application. Load balancer metrics are a good choice, (<a href="https://traefik.io/">Traefik</a> provides all the required metrics). Apdex can also be measured directly from the application as long as we keep in mind that we are not guaranteed to be seeing all errors. Refused connection are an example of an error that is probably not measurable from inside the application. On the other hand, application side measurement allows us more control over the metrics we produce.</p><p>You can find a simple example Go application with suitably instrumented handlers, along with Prometheus configuration files, <a href="https://github.com/tcolgate/prometheus-rules/tree/master/apdex">here</a>. The instrumentation provide the following metrics:</p><ul><li><strong>http_apdex_target_seconds</strong><em> </em>is a gauge metric providing our target request duration.</li><li><strong>http_request_duration_seconds </strong>is a histogram of response times with handler name and response code labels.</li></ul><p>The Prometheus documentation rightly cautions against adding too many labels to metrics. Including the response code and handler as a labels is questionable. Request code are arbitrary (though usually between 200 and 599) and including them can result in an explosion of the number of time series your application is reporting. In addition to this, it has been suggested that differentiating errors with labels can lead poor dashboarding and alerting by allowing people to only focus on successful calls. For the purpose of Apdex calculation we need to differentiate errors from successes. In our example we use the response code, other approaches are possible. In practice your author has not seen problems including code and handler as labels on production services.</p><p>Since we will probably want to our histogram for more than just Apdex calculations, we include some additional buckets. The only requirement is that we must have buckets at exactly <strong>T </strong>and<strong> 4T</strong>, other buckets are included here to demonstrate that they do not impact the overall calculation.</p><h4>Calculating Apdex</h4><p>The approach given below uses some relatively advanced Prometheus query techniques which I hope you will find interesting and useful in future. We will walk through each rule, giving the motivation and a brief discussion of how it works. First off let us look at our raw material, what metrics is our application producing (I have filtered out series that we do not need for our calculations).</p><pre>http_request_apdex_target_seconds 0.1<br>http_request_duration_seconds_bucket{<br>  code=&quot;200&quot;,handler=&quot;/healthz&quot;,le=&quot;0.1&quot;} 10<br>http_request_duration_seconds_bucket{<br>  code=&quot;200&quot;,handler=&quot;/healthz&quot;,le=&quot;0.4&quot;} 10<br>http_request_duration_seconds_bucket{<br>  code=&quot;200&quot;,handler=&quot;/healthz&quot;,le=&quot;+Inf&quot;} 10<br>http_request_duration_seconds_bucket{<br>  code=&quot;200&quot;,handler=&quot;/q&quot;,le=&quot;0.1&quot;} 775<br>http_request_duration_seconds_bucket{<br>  code=&quot;200&quot;,handler=&quot;/q&quot;,le=&quot;0.4&quot;} 1605<br>http_request_duration_seconds_bucket{<br>  code=&quot;500&quot;,handler=&quot;/q&quot;,le=&quot;0.1&quot;} 390<br>http_request_duration_seconds_bucket{<br>  code=&quot;500&quot;,handler=&quot;/q&quot;,le=&quot;0.4&quot;} 390<br>http_request_duration_seconds_count{<br>  code=&quot;500&quot;,handler=&quot;/q&quot;} 390</pre><p>Since each instance of the application may expose a different value for any metric, we must establish what the current preferred T value is. We shall use the current maximum for a given job.</p><pre>- record: job:http_request_apdex_target_seconds:max<br>  expr: max(http_request_apdex_target_seconds) BY (job)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*00PPzsx0OEeOhfCShOthEg.png" /></figure><p>Our new metric is convenient for adding to graphs to indicate the expected latency, but we must adjust it to be useful for alerting. Prometheus histograms use a label (<strong>le</strong>) to label each bucket. We are going to want to be able to select out buckets based on our <strong>T</strong> value. We could have simply produced some metrics with the required labels, but as alternative, we can also use the following rules to produce the required series on the Prometheus server side</p><pre>- record: job_le:http_request_apdex_target_seconds:max<br>  expr: |<br>    clamp_max(<br>      count_values(<br>        &quot;le&quot;,<br>        job:http_request_apdex_target_seconds:max<br>      ) BY (job),<br>      1)<br><br>- record: job_le:http_request_apdex_target_seconds:4_times_max<br>  expr: |<br>    clamp_max(<br>      count_values(<br>        &quot;le&quot;,<br>        job:http_request_apdex_target_seconds:max * 4<br>      ) BY (job),<br>      1)</pre><p>These rules transform our selected <strong>job:http_apdex_target_seconds:max </strong>in to two new metrics. These represent <strong>T </strong>and <strong>4T</strong>. Rather than simply having a metric with the specific values, <strong>count_values </strong>transforms the value of a time series into a label, <strong>le </strong>in our case<strong>,</strong>with the value of the label being a string representation of the values. Since we know we only have 1 occurrence of this metric for a given instance of our application, we know the count we always be 1. This results in the following metrics</p><pre>job_le:http_request_apdex_target_seconds:max{le=&quot;0.1&quot;} = 1<br>job_le:http_request_apdex_target_seconds:4_times_max{le=&quot;0.4&quot;} = 1</pre><p>The <strong>le </strong>label can now be used for label matching in calculations involving our histogram. We can finally calculate our Apdex score. We will adjust the formula slightly</p><pre>apdex = (<br>         (<br>           satisfactoryRate + <br>           (satisfactor + tolerableRate)<br>         ) / 2<br>        ) / totalRate</pre><p>We use rates rather than total requests. We could have used <strong>increase() </strong>in place of <strong>rate()</strong>, however Prometheus estimates increases by multiply rates by the requested duration, the end result is equivalent. Also, since our histogram buckets count all samples with duration less than or equal to the specific bucket, the <strong>4T</strong> bucket will also include sample from the <strong>T</strong> bucket. We could subtract , but we can also just move the division.</p><p>For low traffic services it is often desirable to ignore our own health checks. Health checks are useful for establishing if a service is capable of serving traffic, but rarely catch unexpected errors. They often only trivially test back end services, so are unlikely to timeout in the way that bad user requests can. If we do not ignore our health checks they may artificially raise our Apdex score hiding real problems in a fog of fake successes. We will ignore requests to our health check handler.</p><p>Translating this to PromQL we get</p><pre>- record: job:http_request_apdex:max<br>  expr: |<br>    (<br>      sum(<br>        rate(         <br>          http_request_duration_seconds_bucket{ <br>            handler!=&quot;/healthz&quot;,<br>            code!~&quot;5..&quot;}[1m]<br>        )<br>        * ON(job, le) GROUP_LEFT()<br>        job_le:http_request_apdex_target_seconds:max<br>      ) BY (job)<br>      +<br>      sum(<br>        rate(<br>          http_request_duration_seconds_bucket{<br>            handler!=&quot;/healthz&quot;,<br>            code!~&quot;5..&quot;}[1m]<br>        )<br>        * ON(job, le) GROUP_LEFT()<br>        job_le:http_request_apdex_target_seconds:4_times_max<br>      ) BY (job)<br>    ) / 2<br>    /<br>    sum(<br>      rate(<br>        http_request_duration_seconds_count{<br>          handler!=&quot;/healthz&quot;}[1m]<br>      )<br>    ) BY (job)</pre><p>This query can be divided up into simpler sections. First we calculate the rate of satisfactory requests. As per the rules given in the first section, this is made up of all successful (non-5xx) requests that have been sampled by our <strong>le=”T” </strong>bucket. We then calculate our tolerable requests from the <strong>4T </strong>bucket. Finally we divide the sum of those by 2, and then by the total number of requests to the service. The bucket selection is achieved through label matching on our <strong>le </strong>label<strong>.</strong>The GROUP_LEFT clauses are used to retain any additional instrumentation labels that were present on the original time series.</p><p>Finally we can create an alert.</p><pre>- alert: HTTPApdexViolation<br>  expr: job:http_request_apdex:max &lt; 0.8<br>  for: 5m<br>  annotations:<br>    description: |<br>      &#39;{{ $labels.job }} has ApDex has dropped below 0.8 {{printf &quot;%.2f&quot; $value}}&#39;</pre><p>We could allow the alert threshold, here set to 0.8, to be specified by the application by exposing it as a metrics, as we did for the <strong>T</strong> value. To do so though would encourage developers to lower the alert threshold in response to an application which is not meeting its Apdex target. In my opinion it is more honest to adjust the target response time rather than the alert threshold. This encourages discussions around what is really achievable, rather than simply twiddling a “magic alert threshold”.</p><h4>Conclusion</h4><p>Apdex is a useful metric for monitoring, and especially for alerting. It is a concise representation of user experience. Prometheus provides us all the tools we need to calculate Apdex. The same technique presented here can be used to estimate similarly “Business-centric” metrics, such as error-budgets and service availability.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d17a065e39d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes: Up & Integrated — Secrets & Configuration]]></title>
            <link>https://medium.com/qubit-engineering/kubernetes-up-integrated-secrets-configuration-5a15b9f5a6c6?source=rss-caa286475a71------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a15b9f5a6c6</guid>
            <category><![CDATA[mesos]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[vault]]></category>
            <category><![CDATA[gke]]></category>
            <dc:creator><![CDATA[Tristan Colgate-McFarlane]]></dc:creator>
            <pubDate>Wed, 22 Nov 2017 09:54:51 GMT</pubDate>
            <atom:updated>2017-11-22T09:54:51.389Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the second in a four part <a href="https://medium.com/qubit-engineering/kubernetes-up-integrated-authentication-5d2c908c2810">series</a> on how we at Qubit built our production ready Kubernetes (k8s) environments. For those of us with pre-existing configuration management workflows, moving to k8s can present some challenges. We will briefly describe Qubit’s previous configuration management process, where it caused problems and what we wanted to preserve. After this we will present a detailed overview of the workflow we have built. This will be a long post, you have been warned!</p><p>The tools we will discuss here are not open-source at this time. We hope to release something in the near future. The workflow is also not perfect. We will discuss where the weaknesses lie and how things may change.</p><p>As with the previous article we will assume a reasonable working knowledge of Kubernetes. We will also be discussing some issues involving HashCorp’s <a href="https://www.vaultproject.io/">Vault</a>. We’ll discuss relevant Vault topics briefly but will not attempt to give an exhaustive treatment.</p><h3>The Ghost of Config Past</h3><p>Qubit’s previous configuration management process was built around <a href="https://puppet.com/">Puppet</a> and <a href="https://github.com/voxpupuli/hiera-eyaml">hiera-eyaml</a>. Any configuration containing sensitive material, such as passwords, authentication tokens and private keys, are stored in a central Puppet Git repository. The repository contains a public key that can encrypt data which can than be decrypted by the Puppet master server. Nodes within the cluster infrastructure retrieve configuration from the Puppet master, the master decrypts any encrypted data, passing fully rendered configuration to the cluster node. The container orchestration infrastructure on each node (<a href="http://mesos.apache.org/">Apache Mesos</a>) can then mount the rendered content into containers as they start.</p><p>Many of the workloads running within the clusters are Node.js tasks using the <a href="https://github.com/lorenwest/node-config">node-config</a> package for configuration. We leverage the merging behaviour of both hiera-eyaml and node-config. Applications can ship per-environment settings in e.g. staging.yaml, hiera then merges an unencryped per-application YAML section with the decrypted per-application settings, and renders this into a local.yaml file. The practical result is that developers can place a section of their configuration, as YAML, into our Puppet repository, and have that presented to their application in a secure fashion.</p><p>The developer workflow is as follows:</p><ol><li>Create or update an application’s configuration requirements.</li><li>Create a new section in the Puppet repository with the encrypted version of a secret.</li><li>Raise a pull-request to merge the new configuration section.</li><li>Wait for Puppet to deploy the secrets to the cluster nodes. In our case: one run per-hour per-node.</li><li>Once merged, deploy the new version of the application.</li></ol><p>This process meets many of our security needs:</p><ul><li>Secrets are not checked-in to any source repository in plain text.</li><li>Plain text secrets are at rest in a relatively minimal set of locations (on the root partition of each cluster node).</li><li>Plain text secrets are only visible to the intended recipient application.</li></ul><p>Many of you will have similar workflows. With hindsight and experience it is easy to be critical of this workflow. We’ll discuss the practical problems we experienced, but it is important to state that for many organisations this process is perfectly adequate. Many of the issues we’ll discuss below could be fixed by other means, without moving away from Puppet. We could certainly have stuck to this workflow with our move to k8s, for many people that will certainly be the right thing to do. That being said, here is a brief list of issues we faced regularly:</p><ul><li>Pull-request review by the Infrastructure team becomes a bottleneck for developers.</li><li>Unnoticed errors in configuration easily broke Puppet runs for all applications, and all related infrastructure.</li><li>Feedback on when Puppet has finally deployed configuration to the cluster is very poor and of limited visibility. Either Puppet runs were forced, which required Infrastructure team action, or the developer had to wait for “about an hour” before deploying.</li><li>Deploying an application before Puppet had deployed configuration had unexpected results. Docker creates a local directory if asked to mount a file into a container if no such file exists on disk. This results in Puppet runs failing when a directory exists where a file should have been. This required Infrastructure team involvement to fix. The application would also deploy, but fail when attempting to read a directory.</li></ul><p>As Qubit’s development teams scaled up, occasional irritating misbehaviour turned into serious problems.</p><h3>What Does “Good” Look Like?</h3><p>In the previous section we have discussed some of the practical issues we faced with our Puppet based configuration process. It is worth taking a step back and trying to understand how these issues impacted the Big Picture.</p><ul><li>Developers had to be aware of the behaviour of a tool they would never actually run or use directly (Puppet).</li><li>Developers had to work with an extra code repository.</li><li>The Infrastructure team had to be involved with many new deploys, or emergency deploys, and all secret changes (or any changes to any of the configuration managed by Puppet).</li></ul><p>As mentioned in the previous article in this series, we aim to have development teams have complete ownership of everything needed by their application from one single code repository. Ideally this should include:</p><ul><li>Code, tests and CI configuration.</li><li>Configuration needed for deploying the application.</li><li>Run-time configuration.</li><li>Metrics and alerting configuration.</li></ul><p>It is worth mentioning at this point that Qubit do not (at this time) have what other organisations might call an Operations team (variously known as ‘SRE team’, or the outright oxymoron of ‘DevOps team’). Development teams are responsible for the day-to-day running of their applications. Qubit’s Infrastructure team is focused on building, managing and maintaining the underlying infrastructure and providing the tools for the developers to use that infrastructure. This allows the number of services and associated development teams to scale independently of the Infrastructure team.</p><h3>A Brave New World</h3><p>Kubernetes presented a new challenge. One of our goals was to make deployments agnostic of the underlying cloud provider. We could have built k8s infrastructure via Puppet in both GCE and AWS, we had already done this for Mesos. Our existing Puppet infrastructure would have needed work to support GCE. The presence of GKE made this approach less attractive. <a href="https://github.com/kubernetes/kops">Kops</a> had also provided a straightforward approach to delivering a solid k8s infrastructure on AWS without this effort. The idea of no longer requiring Puppet to build the underlying cluster nodes was too attractive to pass up, especially when combined with the issues presented above.</p><p>The subject of presenting secrets to containers is generally known as Secret Injection. Fortunately for us, people had already outlined approaches to Secret Injection within k8s. Whilst none of the existing tools completely covered our use case, there was enough prior-art to give us a head start.</p><p>We had settled on HashiCorp’s Vault for storage of secrets. Vault is an incredibly powerful tool. While there is a wealth of introductory documentation on Vault, there is considerably less by way of detailed discussion of production ready deployment. All requests to retrieve secrets from Vault require a Vault Token with suitable assigned policies for reading a given secret. Getting an initial token for a service to talk to Vault can seem like a ‘chicken and egg’ situation. Various mechanisms can be used to get an initial Vault token (see Authentication Backends), but the most relevant to our use case all require some other process to already have a Vault Token. This ‘Token Bootstrapping’ represents a real challenge to production Vault deployments.</p><p>Once you have logged in to Vault, you still have to access and use your secrets. We considered requiring developers to talk to Vault directly. This would have been the easiest option for the Infrastructure team, and arguably given the best end result in terms of Vault integration. In reality the code changes required to some 200 micro-services ruled this out. Vault is not an easy tool to use, especially when compared with YAML configuration files loaded via node-conf. Simply retrieving secrets is not the only issue, for some secrets the Vault Token must be periodically refreshed.</p><p>Our final goals were:</p><ul><li>Minimal / No code alteration for existing applications.</li><li>Minimal configuration changes.</li><li>Configuration from the application’s source repository.</li><li>Configuration available immediately upon deployment.</li><li>Minimal exposure of plain text secret content.</li><li>Allow leveraging advanced Vault concepts (such as managed PKI, and managed lifetime secrets for AWS).</li></ul><p>Our eventual approach was inspired by three existing projects:</p><ul><li><a href="https://github.com/kelseyhightower/vault-controller">https://github.com/kelseyhightower/vault-controller</a></li><li><a href="https://github.com/Boostport/kubernetes-vault">https://github.com/Boostport/kubernetes-vault</a></li><li><a href="https://github.com/kelseyhightower/confd">https://github.com/kelseyhightower/confd</a></li></ul><p>Since you have been so patient, and we still have a long road ahead, we’ll break up proceeding with the basic block diagram of what we eventually produced.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*Bw6CRX2lJNQ5IEde4QycfA.png" /></figure><h3>Token Bootstrap</h3><p>We elected to use Vault’s <a href="https://www.vaultproject.io/docs/auth/approle.html">AppRole</a> feature. With AppRole a micro-service is assigned to a given AppRole in Vault. A micro-service instance must log in to the Vault AppRole to obtain a Vault Token before it can begin reading secrets. In order to log in to the AppRole, an instance of a micro-service requires two pieces of information:</p><ul><li>AppRole RoleID, by default this is a UUID. There is only one RoleID for a given AppRole.</li><li>AppRole SecretID, a UUID that is retrieved from Vault by another process which is allowed to issue SecretIDs for a given AppRole. In our configuration this SecretID is unique for each new running instance, may only be used to log in to Vault once, and is only valid for a limited time after being issued.</li></ul><p>Getting two pieces of information to our embryonic micro-service instance might seem harder than the problem we originally had of getting a single Vault Token into our container. We seem to have made our situation worse. There is a very good reason for taking this approach. These two bits of information can be delivered by different means, and neither of the processes responsible for either part of that delivery ever have enough information to actually log into the AppRole and retrieve the applications secrets. Our embryonic micro-service instance can combine these two IDs and use them to log into Vault, the resulting token grants it the power to read secrets. Since the SecretID may only be used once we can also detect potential misuse. If a service is unable to log in to Vault with a given RoleID and SecretID then only one of two things could have happened. It either took them too long, or the SecretID has already been used. It is possible, via Vault’s Audit infrastructure, to spot and alert on the latter case.</p><p>This is excellent, but we still have a Token Bootstrapping problem. In order to get the RoleID and SecretIDs for an AppRole, whatever is requesting them must, in turn, have a valid Vault token. In our case, the RoleID will be retrieved by the process that is deploying the application (usually a CI tool or developer laptop), and the SecretID will be retrieved by an in-cluster Vault Controller. We could pick any other Vault <a href="https://www.vaultproject.io/docs/auth/index.html">authentication method</a> here. The RoleID could be retrieved by a user authenticated via the GitHub authentication mechanism, whilst the SecretID process could be authenticated by an EC2 or GCP machine credential.</p><p>There is a further complication here that ruled out these simple authentication methods. Vault Policies are not very dynamic things at present. We want each AppRole to be limited to reading secret for just its associated micro-service. Out of the box Vault would require the developer to be able to create a policy for their application, and create the associated AppRole. This gives the developer carte-blanche as to the content of that policy. Whilst we do trust our developers, this would require them to understand Vault policies and would be very prone to error.</p><p>Since we already have a central authentication mechanism based on JWTs (discussed in our <a href="https://medium.com/qubit-engineering/kubernetes-up-integrated-authentication-5d2c908c2810">previous article</a>), we elected to leverage it. We have built a small Secret API that sits in front of Vault and is responsible for managing AppRoles and policies. The deployment process can request the RoleID for a given application from the Secret API. After verifying the request the Secret API creates a set of policies for the application, along with an AppRole. Similarly, access to SecretIDs is controlled via this service. Pushing these parts of the Vault flow through an API also allows us to use our existing authorisation mechanism based on our internal Google Groups.</p><h3>The End Result</h3><p>Here is a brief overview of each of the components in the diagram above:</p><ul><li>Vault: Stores secrets at rest and enforces access policies.</li><li>SecretAPI: Manages Vault AppRoles and policies, and is responsible for authorising access to Vault AppRole details. It is also used for setting secrets and maintaining a version history of secrets.</li><li>Docker (Init): A Docker Registry containing a set of Init Containers for applications.</li><li>Docker (Apps): A Docker Registry containing the main application containers. This is currently the same registry as the Init registry, this will be discussed further in the Future Work section.</li><li>Secret Controller: Runs within each Kubernetes cluster. This is responsible for retrieving SecretIDs for new Pods.</li><li>Secret Init Container: This is a container added to each Pod needing to receive configuration.</li><li>Secret Refresh Cotainer: Optional container that can be used to manage Vault leases.</li><li>Config Volume: A tmpfs in-memory volume shared between the Init Container and the main Application Container. This stores the final configuration for the application.</li><li>Lease Volume: A tmpfs in-memory volume shared between the Init Container and the Refresh Container. This stores any Vault Leases that will need to be refreshed.</li></ul><p>The final system is probably best described via a worked example. We will describe the key components in the process as they become relevant.</p><p>We will start with an application. We have a source code repository with the following content:</p><pre>/Dockerfile            - to build out final application container<br>/deployer.yml          - our deployment configuration file<br>/config/staging.yml    - non-secret node-config file for staging<br>/config/production.yml - non-secret node-config file for production<br>/config/local.yml.tmpl - Go template that will become local.yml<br>/...                   - the rest of our application code</pre><p>Developers, if so authorised, can set specific secrets within Vault using a command line utility that talks to the Secret API.</p><p>When the application is deployed:</p><ol><li>The main application’s Docker container is built and pushed to the application Docker repository.</li><li>The deployment tool contacts the Secret API to retrieve the RoleID for this application, specifying the destination cluster’s details.</li><li>If the user running the deployment is suitably authorised the Secret API server ensures the necessary Vault AppRole and policies exists and returns the RoleID and AppRole name to the user.</li></ol><h4>The Vault AppRoles and Policies</h4><p>When an application is first deployed we create four items in Vault. First we create the AppRole itself. This controls the set of permissions that will be given to the final Pod that retrieves the information. An example might be as follows:</p><pre>auth/approle/role/aws.stg.myapp</pre><pre>period                  300<br>policies                [default secret-api/read-aws.stg.myapp]<br>secret_id_num_uses      1<br>secret_id_ttl           300<br>token_max_ttl           300<br>token_num_uses          0<br>token_ttl               300</pre><p>This is an AppRole for instances of myapp running in the stg (staging) cluster within aws (Amazon Web Services). The tokens issued to the final application will be refreshable tokens and will be given the secret-api/read-aws.stg.myapppolicy. We also create that policy:</p><pre>policy secret-api/read-aws.stg.myapp:</pre><pre>path &quot;secret/myapp/*&quot; { capabilities = [&quot;read&quot;, &quot;list&quot;] }<br>path &quot;secret/global/*&quot; { capabilities = [&quot;read&quot;, &quot;list&quot;] }<br>path &quot;secret/project/aws/*&quot; { capabilities = [&quot;read&quot;, &quot;list&quot;] }<br>path &quot;secret/cluster/aws/stg/*&quot; { capabilities = [&quot;read&quot;, &quot;list&quot;] }<br>path &quot;pki/cluster/stg/*&quot; { capabilities = [&quot;read&quot;, &quot;list&quot;] }<br>path &quot;pki/cluster/aws/stg/issue&quot; { capabilities = [&quot;create&quot;, &quot;update&quot;] }<br>path &quot;aws/creds/aws.stg.myapp&quot; { capabilities = [&quot;read&quot;, &quot;list&quot;] }</pre><p>This policy allows the application to:</p><ul><li>read and list various static secrets, some specific to it, others shared among applications</li><li>read and create certificates in a cluster wide PKI</li><li>create AWS credentials specific to this applications role. These credentials are limited to the lifetime of the application.</li></ul><p>We also create a second policy. This will be used by the Secret Contoller later on in the process.</p><pre>policy secret-api/getsecretid-aws.stg.myapp:</pre><pre>path &quot;auth/approle/role/aws.stg.myapp/secret-id&quot; {<br>                capabilities = [&quot;create&quot;, &quot;update&quot;]<br>        }</pre><p>We also create a Vault Token Role (this is separate from an AppRole), associated with this policy:</p><pre>auth/token/roles/getsecretid-aws.stg.myapp</pre><pre>allowed_policies        [secret-api/getsecretid-aws.stg.myapp]<br>disallowed_policies     [root]<br>explicit_max_ttl        0<br>name                    getsecretid-aws.stg.myapp<br>orphan                  false<br>path_suffix        <br>period                  0<br>renewable               true</pre><p>We will explain this policy briefly when we get to the Secret Contoller.</p><p>We continue with our deployment:</p><p>5. The deployment tool takes the AppRole information returned in the previous step and builds an InitContainer that will be added to the Pod.</p><h4>The Init Container</h4><p>Kubernetes allows Pods to have Init Containers. These containers are run before other in the Pod. They must run, and finally exit cleanly before the Pod start-up is allowed to continue.</p><p>Our Init Container includes 3 things:</p><ul><li>A binary capable of logging in to a Vault AppRole, and rendering Go Template files that include secret lookups into Vault.</li><li>The AppRole RoleID information. This is the first half of our AppRole login details.</li><li>The set of configuration files from the /config directory of the original source code.</li></ul><p>Once the Init Container is pushed to the Docker registry, the deployment continues:</p><p>6. The deployment tool creates a set of k8s Deployments in the cluster. The deployments include the Vault AppRole name as an annotation on any Pod specification that wishes to engage in the Configuration process.</p><p>7. Kubernetes starts a Pod.</p><p>8. The Init Container starts. After reading in the RoleID information it begins listening on a known port.</p><p>9. The Secret Controller watches for new Pods. Upon finding one with suitable annotations, and with a running InitContainer listening on the known port, it begins its work.</p><h4>The Secret Controller</h4><p>The secret controller runs in each cluster. It has a Google Cloud Service Account specific to that cluster which permits it to retrieve SecretIDs on behalf of applications started in that cluster.</p><p>When it finds a new Pod wanting configuration, it contacts the SecretAPI and asks for a Vault Token for reading SecretIDs for the given application. Once the SecretAPI approves this request, a new Vault token with the secret-api/getsecretid-aws.stg.myapp policy is issued (via the previously mentioned Token Role). The Secret Controller then contacts Vault directly and retrieves a new SecretID for the required AppRole. This is then passed to the waiting Init Container via a HTTP POST. Ideally this would be a HTTPS POST, however bootstrapping a certificate here is tricky. Since the SecretID is of no use without the RoleID, and we can detect abuse of leaked SecretIDs, we do not consider this to be a major issue. Potentially the forthcoming <a href="https://istio.io/">Istio</a> project could help here, or the Kubernetes Certificate API could be used.</p><p>The Secret Controller’s work is now done, and the deployment of the Pod continues inside the Init Container.</p><p>10. The Init Container now has the AppRole RoleID that was baked into the container image and the SecretID that has been given to it by the Controller. It proceeds to log in to the Vault AppRole. All things being well, it will receive a Vault Token with the secret-api/read-aws.stg.myapp policy mentioned above.</p><p>11. The Init Container now copies any files in the configuration data baked into its image into the shared configuration volume. During this process any file with a .tmpl extension is assumed to be a <a href="https://golang.org/pkg/text/template/">Go Template</a>. The template handling code contains a rich set of functions (including the <a href="https://github.com/Masterminds/sprig">Sprig</a>). Several functions are included for interacting with Vault. The following is an illustrative subset:</p><ul><li>lookup: This looks up a given secret name in the application specific area of the Vault tree for this application.</li><li>awsCredsEnvVars: Retrieves a set of AWS credentials for this process and renders them as sh shell environment variables.</li><li>dbUsername,dbPassword: These can be used to request database credentials from Vault.</li><li>tlsKey, tlsCert , tlsCA: These generate a TLS key and certificate that can be used for mutual authentication within the cluster. The certificates are long lived and a largely intended for providing TLS to any loadbalancer ingress.</li><li>rawRead, rawWrite: These permit arbitrary reads/writes to Vault paths. Since the policy limits the application to specific paths, allowing arbitrary read/write is fine.</li></ul><p>After template rendering the resulting content is written to the shared configuration directory (with the .tmpl extension stripped). The end result is a set of complete configuration files with the relevant secrets for this application, stored on a temporary filesystem readable by the main application container.</p><p>The db* and aws* functions are worth a little further comment. It is important to note here that the credentials the application will get are specific to this running instance of the application and are not shared with other instances. When the application exits these credentials are revoked and destroyed. The creation of these credentials is audited by Vault. We can, for instance, track an action in AWS down to a specific running instance of an application. A practical upshot of this is that AWS and Database credential management is significantly simplified. We no longer need to roll keys. This can be trivially achieved by a rolling restart of the application (or a fresh deployment).</p><p>The final act of our Init Container relates to these temporary credentials. If requested, the Init Container will additionally write the Token and Lease information for any per-process credentials into a second temporary filesystem.</p><p>If all goes well, our Init Container exits cleanly and our deployment continues. If it does not (due to missing secrets, unavailable Vault server, or general network flakiness), the Init Container will eventually be restarted and the process will continue again from Step 8. We shall continue on, assuming all is well:</p><p>12. At this point our main application container starts. It can read its configuration from the shared configuration volume, access required services and begin its work. In the basic case we are now done. If we are using credentials we are leasing from Vault, one further action is required.</p><p>13. Our Kubernetes Pod may include a Secret Refresh Sidecar. If so, it will be started alongside our main application container. It will periodically refresh our Vault token, ensuring that our per application credentials are kept valid. Upon termination it will revoke the Vault token, thus destroying any associated credentials.</p><h3>Profit!…</h3><p>Our application is successfully deployed. Our secrets are in in-memory storage, only visible to the application we desired to have them. Each component on the way has had minimal access to secret related material. By generating temporary per-process credentials we have also achieved something that would be considerably harder to achieve with our original Puppet configuration.</p><h3>Loss?</h3><p>It would be dishonest not to point out some of the weak points in this process:</p><ul><li>The Secret API has considerable access to Vault. Vault has no support for subclassing or templating of policies at this time, so I consider this largely unavoidable unless you are willing to have an Operations team that can take responsibility for create the required Vault elements.</li><li>None of this plays particularly well with Kubernetes Secrets or ConfigMaps. This is less of a problem for internal services, where we generate the k8s objects ourselves, but becomes more awkward when leveraging 3rd party helm charts.</li><li>Config from environment variables is still possible but cannot be configured on the container. A shell must be present inside the container, and suitable shell content rendered to populate the environment. Since this limits visibility of the environment variables from outside the Pod, this can be seen as a reasonable trade-off.</li><li>The Refresh Sidecar needs further work. Kubernetes will not destroy a Pod if an individual Sidecar crashes. Since the crashing sidecar may have revoked the Vault token, we really need to destroy the entire Pod and start again. This could be done from the Secret Controller. Further experience needs to be gathered.</li><li>Kubernetes secrets are still very much a work in progress. Vault integration is on the horizon and it is quite possible that much of this process will be rendered irrelevant in the next 6 months.</li><li>Clearly this process is non-trivial. In reality the volume of code amounts to no more than about 1000 lines spread over 4 processes (the Secret API, Init Container, Refresh Container and Controller). We believe that the end-user experience is no more complicated than the original tooling (with the possible exception of the Go Templates). Time will tell.</li></ul><h3>Future Work</h3><p>We are fairly comfortable with the flow as is. It has proved very reliable and adaptable. The delay on container start imposed by the Init Container is quite minimal, usually dwarfed by the time to download the main container. A typical Init Container run time is in the order of 1 or 2 seconds.</p><p>One area for potential enhancement is the build of the Init Container. The deployer in the above process builds the Init Container and pushes it to a common Docker Registry. The content of the container is just the configuration files and templates that they already have access to. However, they do not strictly need the RoleID. One option we are considering is the have the SecretAPI actually build the Init Container and pass back an image name that can then be included in the Pod. If the Docker Init Registry is only readable by the target k8s cluster, and writable by the Secret API, then the RoleID would never be readable by the process deploying the Pod. Whilst the RoleID does not present a major attack vector, minimising access to it seems like a reasonable option.</p><h3>Conclusion</h3><p>If you have gotten this far, then we thank you for taking the time to read this and hope it has been informative. Kubernetes and Vault are excellent tools and can work together well, but proper integration is a non-trivial task.</p><p>We hope to release the bulk of the tooling used by the process in the following months. Similar, simpler, tools already exist and may be suitable for simpler requirements. Much of the design has been motivated by our multi-cluster configuration and should probably be avoided if you have that option. Ultimately we hope that this post, and the others to follow will be useful in discussing some of the more difficult aspects of production Kubernetes use, and help feed into more general solution that can benefit the whole community.</p><p><em>If you fancy tackling engineering challenges like this, check out the </em><a href="http://www.qubit.com/careers"><em>Qubit careers page</em></a><em> — we are hiring in a wide variety roles and locations.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a15b9f5a6c6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/qubit-engineering/kubernetes-up-integrated-secrets-configuration-5a15b9f5a6c6">Kubernetes: Up &amp; Integrated — Secrets &amp; Configuration</a> was originally published in <a href="https://medium.com/qubit-engineering">Qubit Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes: Up & Integrated — Authentication]]></title>
            <link>https://medium.com/qubit-engineering/kubernetes-up-integrated-authentication-5d2c908c2810?source=rss-caa286475a71------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d2c908c2810</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[gke]]></category>
            <category><![CDATA[helm]]></category>
            <category><![CDATA[google-cloud]]></category>
            <dc:creator><![CDATA[Tristan Colgate-McFarlane]]></dc:creator>
            <pubDate>Fri, 27 Oct 2017 14:45:41 GMT</pubDate>
            <atom:updated>2017-10-30T10:11:28.381Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the first in a four part series on how Qubit have built our production ready Kubernetes (k8s) environments. There are already many excellent tutorials on k8s. The title of these articles is an homage to <a href="http://shop.oreilly.com/product/0636920043874.do">Kubernetes Up and Running</a>, the (presumably excellent) k8s guide by Brendan Burns, Kelsey Hightower and Joe Beda. In these articles, we hope to cover the more advanced techniques we required to make k8s work at “<a href="https://www.youtube.com/watch?v=iFR_7AKkJFU">modern enterprise</a>” scale.</p><p>We hope to cover:</p><ul><li>Authentication and RBAC across multiple cloud providers.</li><li>Secret and configuration management, replacing Puppet with HashiCorp’s Vault.</li><li>Ingress, DNS, and migration strategies.</li><li>Observability.</li></ul><p>On the way we will briefly mention how the features map to our preexisting tools and policies, and how k8s has helped us build on them. Code samples will be provided where possible, and we do hope to open source more of our tooling in future. I will not hide the warts in our deploy, or the gaps in the tooling. The goal is to present a realistic picture of the reality of a Kubernetes deployment at scale.</p><h3>Becoming Cloud Agnostic</h3><p>Qubit have been early adopters of Cloud, PaaS, and container deployments. We have built features on everything from on-prem Hadoop, AWS Lambda and RDS, to Google Cloud Platform BigQuery and Dataflow. The on-prem and VM deploys were traditionally managed by Puppet, and our micro-services were either deployed directly to VMs, or via containers to Mesos/Marathon clusters hosted in AWS. As GKE appeared some teams began to take advantage of it leading to a split, with some internal tooling focused on Marathon, and various ad hoc deploys on GKE.</p><p>Since our micro-services require access to PaaS services from a variety of cloud providers, we wanted a deployment mechanism that was the same regardless of the actual underlying cloud provider. This allows us to co-locate services with their dependencies, simplifying access to PaaS services and minimising cross cloud data transfer and latency. A common deployment method also allows us to be more responsive to changes in contracts/costs as cloud provider offerings change.</p><p>As k8s development progressed it became a more obvious choice for a single platform to target. GKE had largely solved the problem of how to deploy k8s to Google Cloud (not without its own issues as we shall discuss later). After a review of the options for AWS k8s deploys we eventually settled on <a href="https://github.com/kubernetes/kops">kops</a>. Kops allows multi-master, multi-AZ cluster setup, and management of multiple instance groups. Kops VM base images are well maintained allowing us to avoid Puppet management of the underlying VMs. Kops updates, and rolling updates (especially with KOPS_FEATURE_FAGS=&quot;+DraingAndValidateRollingUpdate&quot;), actually seem to behave better than the GKE equivalent (where the master can frequently become unresponsive during updates).</p><h3>Kubernetes Authentication Webhooks</h3><p>Kubernetes Role Based Access Control (RBAC) was in its early stages during the beginning of our exploration of production k8s. Our initial attempts at GKE avoided the subject completely, but it was obvious from Day 1 that building larger, more efficient, multi-tenant clusters was going to require RBAC. If you are going to use RBAC you need to be know who is using the cluster. This is where Authentication comes in.</p><p>For GKE we disable all legacy authentication, enable RBAC, and enable IAM authentication. This is easy, but does have its limits. In particular, the permissions that can be granted are at a much coarser level than we would like. We’ll discuss this further when we come to our RBAC configuration.</p><p>Enabling RBAC on a kops cluster is easy enough, simply edit the cluster, update authorization to rbac: {}, and roll out the changes. At this time integrating authentication is not quite as smooth.</p><p>K8s API Server has support for authenticating users via a handful of options:</p><ul><li>File of static usernames/passwords for use via Basic Authentication to the API. These are convenient for bootstrapping, and could work for small teams, but would require configuration management, and would not integrate with an external auth provider.</li><li>File of static tokens. As above.</li><li>Certificates signed by the k8s CA. It is possible to integrate this with HashiCorp’s Vault, but that complicates the kops bootstrapping process. Vault did not support GCP authentication at the time, the option is now there so this may be a more practical solution, though support for verifying users Group Membership may not be easy/possible.</li><li>A webhook for verifying bearer tokens presented to the API.</li></ul><p>For our AWS clusters, the webhook was the obvious choice. The manner of configuration is somewhat awkward. A kubectlstyle configuration file must be placed on each master, the content is as follows.</p><pre>clusters:<br>  - name: authn-api<br>    cluster:<br>      certificate-authority: /etc/ssl/certs/ca-certificates.crt<br>      server: <a href="https://authn-api/oauth2/k8sTokenReview">https://authn-api/oauth2/k8sTokenReview</a></pre><pre>users:<br>  - name: authn-api</pre><pre>current-context: webhook<br>contexts:<br>- context:<br>    cluster: auth-api<br>    user: authn-api<br>  name: webhook</pre><p>The kops definition must also be updated:</p><pre>spec:<br>  kubeAPIServer:<br>    authenticationTokenWebhookCacheTtl: 2m0s<br>    authenticationTokenWebhookConfigFile: /srv/kubernetes/authn-webhook.yaml</pre><p>Unfortunately, there is no current way to set the content of the yaml webhook directly in the kops definition. This means that it must be copied to the server at a known path on each master. Stateful drives are mounted at different locations on each machine, and other storage is recreated when masters are updated. This means that when the masters are updated the file must be copied back up to the known location. Solutions for this are in the works, and there may be other options that your author has not considered. Master updates are not so frequent that this has become a major problem.</p><h3>Authentication: Tokens Everywhere</h3><p>We rely on Google’s G Suite for e-mail and much of our documentation, so basing our primary authentication on our Google G Suite credentials has always been the obvious choice. Service Accounts provide a means for us authenticate between micro-services. Google’s own APIs for JWT signing and authentication do not include Google Group membership, and only provide Authorization features for Google’s own APIs and products. For this reason Qubit have an internal service for signing JWTs, and performing OAuth 2.0 flows. Ours is a relatively simple service, <a href="https://github.com/coreos/dex">CoreOS Dex</a> would be the obvious choice for anyone starting out today.</p><p>Integrating our existing JWT token authentication with k8s has been a fun and refreshingly easy experience. The webhook request and response format can be found in the k8s <a href="https://kubernetes.io/docs/admin/authentication/#webhook-token-authentication">documentation</a>, and our implementation is simply a matter of verifying the passed in JWT token, and breaking out the groups from the JWT claim fields. The process is entirely stateless and could actually be run as a small service within the cluster. The process is not particularly latency sensitive, so we actually have the token verification endpoint on our token issuing/signing service.</p><p>The most pleasant aspect of the integration comes from an, almost hidden, feature of kubectl. If you already use GKE with IAM authentication, and happen to look in your .kube/config<em>, </em>you will see something like the following in the users: section.</p><pre>users:<br>- name: gke_project_us-central1-mycluster<br>  user:<br>    auth-provider:<br>      config:<br>        access-token: ya4......<br>        cmd-args: config config-helper --format=json<br>        cmd-path: /home/joe/google-cloud-sdk/bin/gcloud<br>        expiry: 2017-09-13 15:01:44<br>        expiry-key: &#39;{.credential.token_expiry}&#39;<br>        token-key: &#39;{.credential.access_token}&#39;<br>      name: gcp</pre><p>The <em>access-token</em> and <em>expiry</em> are cached values. The interesting part is the cmd-args and cmd-path. If <em>name</em> is set to “gcp”, kubectl will take credentials from the output of executing the given command. The output is treated as JSON, and the <em>-key</em> fields are JsonPath query expressions into the resulting data.</p><p>If we are devious enough to pretend, for a moment, that “gcp” does not have to stand for Google Cloud Platform, but could be General Cloudy Provider, we can leverage this for our own ends. At Qubit we already have a CLI tool used by our developers for various deployment tasks. It was a simple task to add an extra command to this to allow the issuing of a JWT token. When run, the standard OAuth 2.0 browser flow occurs, and all being well, a signed JWT is retrieved from our API server and dumped out in a sufficient compatible JSON format.</p><p>The end result is that a simple kubectl get podscommand will:</p><ol><li>Run our CLI tool to get a token.</li><li>Verify the user via OAuth.</li><li>Cache the token in kubectl.</li><li>Pass this token, which includes the users groups, as the API token.</li><li>The Authn API server calls the webhook to verify the token.</li><li>The Authn API server verifies the token and informs k8s of the user’s group membership.</li></ol><h3>Role Based Access Control and Helm</h3><p>Kubernetes has a powerful and elegant system for configuration of role and privilege. Users, and groups of users, can be granted various permissions, either cluster wide via ClusterRoleBindings, or within specific namespaces via RoleBinding. We will not attempt to describe the details of RBAC here, but one particular aspect is worth additional attention.</p><p>Our goal in configuring RBAC is to give the developer the freedom to work directly with the k8s API via any tools they wish, whilst simultaneously trying to provide a degree of protection for services required by our infrastructure team. We would like teams to be able to share clusters, but would also like to be able to segregate their jobs when required. The strategy we have settled on is to give developers full access to namespaces, based on their Google Cloud group membership. All teams share access to the default namespace. Teams can have their own namespace, or namespaces for specific applications. The infrastructure team have a namespace for running more privileged applications (for instance, requiring unavoidable, high value secrets). No teams deploy anything to, or interact with, the kube-system namespace.</p><p>There are several choices for how to go about provisioning your services into k8s clusters. Most tutorials focus on using kubectldirectly, there are also several templating solutions. For better or worse, we have settled on <a href="https://github.com/kubernetes/helm">Helm</a>. Helm’s concept of a release, with history and rollbacks, provides us a nice model for managing all aspects of a deploy. Rebuilding our existing deployment tool (that targets Docker and Marathon), to support Helm was relatively straightforward.</p><p>One downside of Helm is Tiller. Tiller is a small service deployed in your cluster which acts as the state store for Helm, keeping the required and previous configuration state in k8s configmaps. Tiller must be installed in the cluster, and must have permission to create resources. It is no longer our users doing the deploying, Tiller does this for them.</p><p>By default Tiller is installed to the kube-system namespace. A regular install would likely give Tiller, and by extension the developer using Helm to deploy to it, full access to all k8s namespaces. In multi-tenant clusters that is not acceptable. Fortunately this can be avoided.</p><p>Let us say we have a team called team-a. We will create a namespace for them, and grant them full privileges to a namespace, also called team-a.</p><pre>$ kubectl create namespace team-a<br>$ kubectl create rolebinding team-a-admin --namespace team-a \<br>  --clusterrole=cluster-admin --group=team-a</pre><p>This creates the namespace and assigns the cluster-admin ClusterRole, as a RoleBinding in the team-a namespace, to members of team-a. It is important to note that this is a RoleBinding tied to the namespace, not a ClusterRoleBinding, which would give cluster-admin rights to the entire cluster. It seems odd but you can bind a ClusterRole with a RoleBinding, with the subsequent access being allowed only to a specific namespace.</p><p>Now, if we deploy Tiller to this namespace, it will get the default service account. This account does not have sufficient privileges to manage resources in the namespace. Instead we create a service account for Tiller, and create it a RoleBinding that binds it to the cluster-admin ClusterRole in our team-a namespace.</p><pre>$ kubectl create --namespace team-a serviceaccount tiller<br>$ kubectl create --namespace team-a rolebinding team-a-tiller \<br>  --clusterrole=cluster-admin --serviceaccount=team-a:tiller</pre><p>We can now deploy Tiller:</p><pre>$ helm init --upgrade --tiller-namespace team-a \<br>  --service-account tiller</pre><p>And our developers can finally use it:</p><pre>$ helm --tiller-namespace team-a install alpha/hackernewsthing</pre><p>By restricting our developers to particular namespaces we gain an additional layer of security, and can also hide some of the guts of our internal cluster management tooling from them. It gives us more options for controlling resource quotas on a per-namespace basis, and potentially segregating work on the underlying VMs via namespaces too (this would require admission control, but should be possible).</p><h3>When is AWS is more GCP than GKE?</h3><p>One curious aspect of the configuration described above is worth further discussion. Our own token issuing service fully exposes the group membership of the user by embedding them in the JWT token. Google’s equivalent tokens, the ones we use when talking to GKE via IAM, do not. There are sound technical reasons for this. At Google’s scale, resolving group memberships is an expensive operation. At our scale it is not. The practical upshot of this though is that in GKE we cannot use RBAC rules to limit the namespaces a given user can manage.</p><p>In GKE we must grant the developer broad rights to, at the very least, see the cluster. It is technically possible, via <a href="https://stackoverflow.com/questions/45945074/iam-and-rbac-conflicts-on-google-cloud-container-engine-gke">custom IAM Policies</a>, to restrict this to a very minimal set of rights, however, our RBAC policies can only ever match specific users, or everyone that is authenticated, not groups. The practical upshot is that we must give the developer full access to the cluster, allowing them full visibility, and management, of all namespaces. As well as the obvious security implications, this also exposes the developer to having to see a large number of API objects which they have no interest in.</p><p>We can create smaller clusters, assigning IAM rights to entire clusters, but to smaller teams, however the extra clusters create an operational burden, and ultimately are less cost effective in terms of resource usage.</p><p>For the moment we are accepting the coarser IAM permissions. Google are working on this issue. It will be interesting to see how well integrated into RBAC their final approach will be. In the longer term, if a suitable solution is not found, we still have the option of building kops clusters on GCP. The gap in features between a GKE cluster and a kops GCE cluster is less than one might imagine. As you will see in Ingress and Observability sections later on, we leverage less GKE features than one might reasonably expect, and the additional access to direct Kubernetes API Server features may outweigh the benefits of GKE in the long run.</p><h3>Summary</h3><p>With the configuration described above we have a solid basis for multi-tenant clusters. Authentication is built on top of a preexisting company standard, and is relatively consistent between our two cloud providers. Google G Suite remains our single source of truth for group membership, and thus authentication and authorisation. kubectl’s cmd-path feature has allowed us to ensure that the developer’s experience of using the clusters is in line with what they will find in any Kubernetes tutorial on-line.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d2c908c2810" width="1" height="1" alt=""><hr><p><a href="https://medium.com/qubit-engineering/kubernetes-up-integrated-authentication-5d2c908c2810">Kubernetes: Up &amp; Integrated — Authentication</a> was originally published in <a href="https://medium.com/qubit-engineering">Qubit Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Seasonality in Prometheus alerting.]]></title>
            <link>https://medium.com/qubit-engineering/using-seasonality-in-prometheus-alerting-d90e68337a4c?source=rss-caa286475a71------2</link>
            <guid isPermaLink="false">https://medium.com/p/d90e68337a4c</guid>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[prometheus]]></category>
            <dc:creator><![CDATA[Tristan Colgate-McFarlane]]></dc:creator>
            <pubDate>Wed, 25 Jan 2017 13:27:44 GMT</pubDate>
            <atom:updated>2017-01-25T19:41:35.208Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>In this post, we will show a worked example of building a Prometheus alert for a typical user facing service.</blockquote><p>At Qubit we have recently completed a migration from our legacy<br>Shinken and Graphite based monitoring to a system built around<br><a href="https://prometheus.io/">Prometheus</a>, a modern time series database.</p><p>Prometheus has many features that are particularly well suited to our<br>current infrastructure. To pick a few at random,</p><ul><li>Works well in containerised environments.</li><li>Exporters are easy to write, and the existing client libraries are pleasant to use.</li><li>It was easy to get started, and has proved very adaptable to our more extreme use cases.</li></ul><p>One of its most appealing features is the rich query language. Once you are<br>over the initial learning curve, a world of possibilities awaits.</p><h4>Living with your errors.</h4><p>In high traffic environments, traditional check and threshold based alerting<br>begins to cause pain. Errors are a simple fact of life. For clients traversing<br>the internet, especially mobile clients, possibly travelling at high speed<br>through rolling green hills, timeouts are unavoidable. Anyone with a server directly connected to the Internet will know that not everyone is polite enough to send you perfectly formed HTTP request of the kind you intended to receive. As scale increases, failures within your infrastructure eventually become equally unavoidable.</p><p>If we have to live with a background of alerts, we need methods for determining when we should be worried, and when we should not. Fortunately statisticians have been hard at work for a great many year, creating the mathematical tools we need to achieve just that.</p><p>Imagine a simple service receiving traffic from the internet. If we have a<br>consistent rate of events, spotting anomalies should not be too difficult.<br>We could assume our traffic will remain within a fixed margin of this, and alert when levels go below or above the average level of traffic we have seen<br>recently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*nCD6Q28nNcNaGPvr." /><figcaption>Thresholds on steady traffic</figcaption></figure><p>Unfortunately, any service interacting with humans will be very unlikely to see traffic like this. Traffic isolated to one country will often show a “Camels<br>Hump” shape. Working out why you traffic is the shape it is can be fun, and quite enlightening.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*FIbnMQu5NK5PFct0." /><figcaption>Typical daily traffic pattern</figcaption></figure><p>On a global scale things do even out a little, but humans are not evenly distributed across the planet (distribution of land, and distribution of wealth over the surface of the earth have seen to that). People will talk of traffic following the sun, with peaks of traffic as each major region comes on line.</p><p>These factors make it hard for simple threshold based alerting to work. We cannot simply give a minimum and maximum level. No one set of thresholds will work reliably throughout the entire day.</p><h4>The Changing Seasons</h4><p>Rather than ask what the level of traffic is with respect to previous traffic today, we can instead ask if our expected traffic at this time is reasonable relative to some previous point in time that we expect to have approximately the same traffic levels. In statistics, this is termed “Seasonality”. In much the same way that we consider the weather in winter to to be similar from year to year, we can find the same similarity between traffic levels in our system over different time ranges.</p><p>The obvious choice is to compare our traffic today with our traffic 24 hours<br>ago. We can do this in Prometheus using the offset keyword. Let us assume we have a rule in place to create an aggregate of our average per-second rate of events over the previous hour.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/726291a50c239e6213fe7574d76b96fa/href">https://medium.com/media/726291a50c239e6213fe7574d76b96fa/href</a></iframe><p>We could create a rule to track the rate of events from yesterday, as follows.:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c6866bca9dd6f4bca658ed88de7aaa77/href">https://medium.com/media/c6866bca9dd6f4bca658ed88de7aaa77/href</a></iframe><p>This can be very useful indeed, and give you a very quick “at a glance”<br>indication if things are more or less at the right levels. We could now monitor the difference between our current rate of events, and the previous days, and perhaps pick a simple threshold again.</p><p>However, things become more interesting if we take several offsets and collect them together. In Prometheus we can achieve this with the following rule.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d854d0a1d185320bf0c406566eb844d/href">https://medium.com/media/6d854d0a1d185320bf0c406566eb844d/href</a></iframe><p>Building up these historical views of our data can become quite mesmerising. But beyond produce pretty graphs, we can put this to more direct use. If each days samples are similar, we can do the following.</p><ul><li>Take the average of the rates of events for each of our previous days</li><li>Calculate the Standard Deviation between the previous days rates of events</li></ul><p>Standard deviation gives us a measure of how much we can expect other days to vary from the 3 days worth of samples we have. We can the calculate upper and lower bounds for what is reasonable to expect, and alert if we move beyond those levels.</p><p>Effectively we are dynamically creating out thresholds. In Prometheus we do this as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba6cf3e35377fcd8ecd38b928b0f5914/href">https://medium.com/media/ba6cf3e35377fcd8ecd38b928b0f5914/href</a></iframe><p>And finally we create an alert to inform us when we’ve moved beyond our<br>threshold. We will suggest that if our traffic is between ±3 standard<br>deviations from our previous levels things are looking fine. If we move<br>outside of those levels, we will raise an alert.</p><p><strong>Note</strong>: Whether or not this is reliable enough to be considered worthy of paging someone is really down to your particular levels and shape of traffic.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3b702a3606ebb150ee5cfa576b256fdc/href">https://medium.com/media/3b702a3606ebb150ee5cfa576b256fdc/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*FljkSQ18Mc74zXlw." /><figcaption>Daily traffuc annotated with potential “safe levels”</figcaption></figure><h4>What is normal?</h4><p>If the underlying data samples conform to a <a href="https://en.wikipedia.org/wiki/Normal_distribution">normal distribution</a> ,3 standard deviations would suggest a 99.7% chance that we are experiencing a problem. In reality this is unlikely to be the case, but may be a reasonable estimation.</p><p>More traffic sample can help us tighten the our prediction. There is a further problem however. Just as our morning traffic and evening traffic are different, there are likely to be similar differences between individual days. If our weekend traffic differs in volume or shape from our weekday traffic, our calculation are off. Our alerts are likely to fire on Saturday, and fail to fire on a Monday morning. (This is caused by our sample points not actually being from a normal distribution.) We may see more correlation if we choose similar hours in each week, rather than simply each day.</p><p>One limitation you may run into with Prometheus, if trying to extend too far into the past, is with its retention periods. Prometheus is designed for alerting rather than data mining. The default retention period is 2 weeks. In very dynamic Environments it is often necessary to reduce this further.</p><p>This would seem to limit the historical series we can query, but we can perform a simple trick to “remember”, the old data for a specific set of queries.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e2fbe439a4e2e250e618db57ba53c80/href">https://medium.com/media/1e2fbe439a4e2e250e618db57ba53c80/href</a></iframe><p>This way, we can now produce an estimate based on 3 values of the last<br>3 weeks, even though our server may only actually hold 8 days worth of data. It is important to note that you should not mix these 1w samples in with your 1d samples above. The mean and stddev rules from above should be adjusted, perhaps as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8648268df3027e1f9730ac88447a0c58/href">https://medium.com/media/8648268df3027e1f9730ac88447a0c58/href</a></iframe><p>Alternatively we could store these with as one metric with a label. Adjusting<br>the final calculation and alert are left as an educational exercise for the<br>Reader.</p><h3>Conclusion</h3><p>Prometheus provides a powerful set of tools to help up build alerts based on a deeper understanding of our data than simple thresholds. This post has explored one such technique.</p><p>For those interested in more on this topic, I highly recommend this <a href="https://www.youtube.com/watch?v=gNmWzkGViAY">video</a> below (and the related Better Living Through Statistics talks), by Jamie Wilkinson, and his excellent contributions to <a href="http://shop.oreilly.com/product/0636920041528.do">O’Reilly’s Site Reliability Engineering</a> book.</p><p>Those interested in a more rigorous discussion of the maths can find many great books to choose from, but could do worse than <a href="https://www.amazon.co.uk/Statistics-Nutshell-Desktop-Reference-OReilly/dp/0596510497">Statistics in a Nutshell</a></p><p><em>Look out for future posts discussing how we’re leveraging Prometheus at Qubit.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d90e68337a4c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/qubit-engineering/using-seasonality-in-prometheus-alerting-d90e68337a4c">Using Seasonality in Prometheus alerting.</a> was originally published in <a href="https://medium.com/qubit-engineering">Qubit Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>