<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://brokenco.de//feed/by_tag/infrastructure.xml" rel="self" type="application/atom+xml" /><link href="https://brokenco.de//" rel="alternate" type="text/html" /><updated>2026-10-31T17:58:32+00:00</updated><id>https://brokenco.de//feed/by_tag/infrastructure.xml</id><title type="html">rtyler</title><subtitle>a moderately technical blog</subtitle><author><name>R. Tyler Croy</name></author><entry><title type="html">It’s no secret where GitOps falls down</title><link href="https://brokenco.de//2018/08/14/gitops-and-secrets.html" rel="alternate" type="text/html" title="It’s no secret where GitOps falls down" /><published>2018-08-14T00:00:00+00:00</published><updated>2018-08-14T00:00:00+00:00</updated><id>https://brokenco.de//2018/08/14/gitops-and-secrets</id><content type="html" xml:base="https://brokenco.de//2018/08/14/gitops-and-secrets.html"><![CDATA[<p>This year I have started to see a new buzzword get thrown around, one which I
can feel especially hipstery about: GitOps. While the folks over <a href="https://www.weave.works/blog/gitops-operations-by-pull-request">at
WeaveWorks</a>
have made the term fashionable in the Kubernetes ecosystem, stodgy old-timer
Puppet users might recognize the same practices they’ve used for a few years
now by combining <a href="https://puppet.com/blog/git-workflows-puppet-and-r10k">R10k and
Git</a>. In fact, I was
first introduced to the concept by <a href="http://garylarizza.com/blog/2014/08/31/r10k-plus-directory-environments/">Gary
Larizza</a>,
an absolutely loud, foul-mouthed, and wonderful hacker. The concepts Gary
blogged about I rapidly
introduced to the Jenkins project’s <a href="https://github.com/jenkins-infra/jenkins-infra">own Puppet-based
infrastructure</a>. This blog post
isn’t about how sunglasses-at-night cool all us Puppet users have been, but
instead I wished to clarify some areas where “GitOps” as a practice falls
short, and what is needed to compensate.</p>

<p>GitOps, in essence, is using Git as the source of truth to drive infrastructure
changes through environments using pull request and branches. Many
organizations dress it up with additional trappings which may benefit their
particular needs, but fundamentally it boils down to: infrastructure as code,
using Git for environment/pipeline management.</p>

<p>For example, with the Jenkins project’s Puppet-based infrastructure, we follow
the following branching model sand workflow:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>+----------------+
| pull-request-1 |
+-----------x----+
             \
              \ (review and merge, runs acceptance tests)
staging        \
|---------------o--x--x--x----------------&gt;
                          \
                           \ (manual merge, auto-deploys to prod hosts)
production                  \
|----------------------------o-------------&gt;
</code></pre></div></div>

<p>This same model works rather well for Kubernetes resources where one might
progress an application deployment through a series of stages before reaching
production.</p>

<p>In addition to the hopefully obvious benefits of infrastructure as code, this
approach couples nicely with ephemeral environments, and strong automated test
practices which allow developers to validate their infrastructure changes in
pull requests before reaching production, which is only a merge away!</p>

<p>It is not all rainbows and <code class="language-plaintext highlighter-rouge">:tada:</code> emojis. “What they don’t tell you” is how
to manage secrets effectively.</p>

<hr />

<p>Consider a simple  web application, “Hiya!”, wherein a user enters an email into a form
field, clicks a button, and receives a “Hello World!” email in their inbox.
“Hiya!” is effectively stateless, but requires a
<a href="https://sendgrid.com">SendGrid</a> API token in order to send the user an email.
Naturally for our “staging” environment, the application should using a
SendGrid staging API token and URL, whereas for the “production” environment it
should be using a different token backed by a very big credit card for our
high-scale email sending application.</p>

<p>For most organizations, it would be reasonable for all the devs to have access
to the SendGrid staging API token for testing their applications, so that can
probably be checked into the <code class="language-plaintext highlighter-rouge">hiya.git</code> repository.</p>

<p>What about production credentials?</p>

<p>A couple options come to mind:</p>

<ol>
  <li>Check those credentials into <code class="language-plaintext highlighter-rouge">hiya.git</code> in an encrypted form, which the
<a href="https://jenkins.io/">Jenkins</a> Pipeline can properly decrypt and deploy into
the Kubernetes, or other, production environment.</li>
  <li>Use a separate “shadow” development and delivery flow strictly for secrets and
credentials. This delivery pipeline would only be visible to a select few,
typically operations staff.</li>
  <li>Connect some external secrets management tool (Vault, Amazon Key Management
Service, Azure Key Value)to remove any kind of “GitOps” development workflow
for secrets.</li>
</ol>

<p>Thus far, I have not found a consistently useful approach for managing secrets
across GitOps workflows between conventional and Kubernetes-based
infrastructure.</p>

<p>For the Jenkins project’s infrastructure, we rely on a hybrid approach:
encrypting credentials <em>and</em> managing them in a somewhat separate “shadow”
delivery pipeline using Puppet and
<a href="https://puppet.com/docs/puppet/5.3/hiera_intro.html">hiera</a> (with
hiera-eyaml).</p>

<p>The trade-off with the approaches 2 &amp; 3 above, and the hybrid model the Jenkins
project utilizes is that “ops” has to be informed and involved with changes
going to production. Our involvement is typically only to make sure that a
“shadow” pull request is being developed with the production credentials
alongside the actual application deployment code. More than once I’ve
inadvertently deployed an application to production, only later to realize that
that application was using staging credentials because a shadow pull request
hadn’t yet been merged.</p>

<p>Using the example flow from above as a reference, our combined workflow might
look something like this:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>+----------------------------------+
| pull-request-1 (requires secret) |
+--------------------------x-------+
                            \
                             \ (review and merge, runs acceptance tests)
               staging        \
               |---------------o--x--x--x----------------&gt;
                                         \
                                          \ (manual merge, auto-deploys to prod hosts)
               production                  \
               |----------------------------o---O---------&gt;
                                               /
                                              /
                            ------------------
                            production deploy
                            -----------------
secrets repository                  |
|-----------------o-----------------O---------------------&gt;
                 / (merge ahead of pr#1)
                /
   +-----------x---------------------+
   | pull request for secret in pr#1 |
   +---------------------------------+
</code></pre></div></div>

<p><strong>Not ideal</strong>. But unfortunately I have not found a better approach for
managing secrets with the “GitOps” development flow. That said, having two
Git-based flows is a reasonable middle ground, but typically cross-repository
traffic-policing challenges do apply</p>

<hr />

<p>I’m very interested to learn about how other folks are solving the problem of
managing secrets with a Git-based infrastructure deployment flow. Whether we’re
talking about secrets and certificates being delivered by a tool like Puppet,
or something uploading secrets into different namespaces in Kubernetes.</p>

<p>Some other challenges with Git-based infrastructure delivery approaches
(GITOPS!!1), particularly with Kubernetes, which I find interesting:</p>

<ul>
  <li>Enforcing compliance with security standards.</li>
  <li>Preventing configuration/state drift, which is where Puppet excels.</li>
  <li>Blending pipelines from multiple repositories, such that different
applications could reasonably maintain their own configurations, without
needing to run fully separate deployment pipelines.</li>
</ul>

<p>While these challenges exist, I still fundamentally agree that “GitOps” should
be the preferred approach for auditability and tracking of state as
infrastructure and application code moves towards production.</p>

<p>It’s not all rainbows and <code class="language-plaintext highlighter-rouge">:tada:</code> emojis, but I think we’re getting there.</p>]]></content><author><name>R. Tyler Croy</name></author><category term="gitops" /><category term="infrastructure" /><category term="puppet" /><category term="jenkins" /><category term="kubernetes" /><summary type="html"><![CDATA[This year I have started to see a new buzzword get thrown around, one which I can feel especially hipstery about: GitOps. While the folks over at WeaveWorks have made the term fashionable in the Kubernetes ecosystem, stodgy old-timer Puppet users might recognize the same practices they’ve used for a few years now by combining R10k and Git. In fact, I was first introduced to the concept by Gary Larizza, an absolutely loud, foul-mouthed, and wonderful hacker. The concepts Gary blogged about I rapidly introduced to the Jenkins project’s own Puppet-based infrastructure. This blog post isn’t about how sunglasses-at-night cool all us Puppet users have been, but instead I wished to clarify some areas where “GitOps” as a practice falls short, and what is needed to compensate.]]></summary></entry></feed>