<?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 Tyler Wanner on Medium]]></title>
        <description><![CDATA[Stories by Tyler Wanner on Medium]]></description>
        <link>https://medium.com/@wanner_tyler?source=rss-4ca3ed5b0ddc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*6E5LULiYTOm0lolo.jpg</url>
            <title>Stories by Tyler Wanner on Medium</title>
            <link>https://medium.com/@wanner_tyler?source=rss-4ca3ed5b0ddc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 02:47:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wanner_tyler/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[HandsFree mTLS in Kubernetes]]></title>
            <link>https://medium.com/the-prefect-blog/handsfree-mtls-in-kubernetes-e3acd59834d1?source=rss-4ca3ed5b0ddc------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3acd59834d1</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[cert-manager]]></category>
            <category><![CDATA[linkerd]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[helm]]></category>
            <dc:creator><![CDATA[Tyler Wanner]]></dc:creator>
            <pubDate>Wed, 13 Oct 2021 17:33:38 GMT</pubDate>
            <atom:updated>2021-10-19T03:02:16.359Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Mutual TLS involves validating both client and server certificates during connection handshakes. This in-transit encryption is a key part of a zero trust framework, mitigating risks such as man-in-the-middle attacks and replay attacks. Linkerd provides a lightweight, fastest-in-class, easy-to-deploy service mesh that provides mTLS out of the box, along with other security, observability, and performance lifts. Using Helm to provision Linkerd service mesh and cert-manager, all CNCF projects like Kubernetes, we can accomplish this as a layer of configuration without concerning application development. For more on mTLS, visit </em><a href="https://www.docusign.com/blog/dsdev-mutual-tls-stuff-know"><em>here</em></a></p><h3></h3><p>Can&#39;t imagine building @kubernetesio based distributed systems without @linkerd! Nobody got time for building gRPC load balancing, mTLS, automatic retries and timeouts from scratch. Plus... IT. JUST. WORKS. https://t.co/JBh6Lu5W5S</p><h3>Infrastructure as Code</h3><p>Transparency and predictability are key to resilience engineering. To those ends, we at Prefect Technologies have a strong commitment to <a href="https://docs.microsoft.com/en-us/devops/deliver/what-is-infrastructure-as-code">Infrastructure as Code</a> and prefer to define our infrastructure declaratively, using Terraform to manage dynamic configuration across many different dimensions of the stack. From root certs to GCP Projects to Helm releases, we have confidence that we know the state of all of our infrastructure because it’s baked right into the software pipeline (Terraform is not without limitation, but it’s quite helpful). Our self-documenting infrastructure code serves as a Single Point of Truth, making replication and atomic changes effortless and predictable.</p><h3>Declarative vs Imperative</h3><p>Declarative and Imperative programming are competing paradigms not limited to infrastructure. “Competing” is a strong word, but you know how the Internet is.</p><p>Declarative infrastructure code is the art of writing infrastructure “as it should be,” whereas imperative infrastructure code is about defining the steps to get to the desired state. Terraform is a widely-used declarative infrastructure code tool with incredibly powerful dynamic configuration and change workflow. It can detect and explain configuration changes, and run them atomically, with special attention to dependencies.</p><h3>Getting Started</h3><p>Before we get started, make sure you have the following at your disposal (versions as tested):</p><ul><li>Terraform</li><li>GCP credentials with permission to create a project</li><li>gcloud CLI</li></ul><p>This demo has been tested with:</p><p><a href="https://www.terraform.io/downloads.html">Terraform</a> v1.0.6</p><p><a href="https://www.terraform.io/docs/providers/google/index.html">google cloud provider</a> v3.85.0</p><p><a href="https://cloud.google.com/sdk/docs/install">gcloud CLI</a> v288.0.0</p><p>You can use an environment variable to set which service account key to use during provisioning:</p><pre>export GOOGLE_APPLICATION_CREDENTIALS=/path/to/key </pre><p>Otherwise, it will use your active gcloud config. Check your configured gcloud config with gcloud auth list</p><h3>Getting Started With Terraform</h3><p>In order to configure a Terraform component, you’ll need to declare a few things — where to keep your <a href="https://www.terraform.io/docs/state/index.html">state</a> file, which <a href="https://www.terraform.io/docs/configuration/variables.html">variables</a> you’ll be supporting, and which <a href="https://www.terraform.io/docs/providers/index.html">Providers</a> you will be using. These are the bones of each component. Each provider is configured for defaults/ authentication and provides you a library of resources to declare. State files will allow us to cross-reference component attributes. We’ll create a directory for each logically-separated-though-related component for flexibility, and one for our state files.</p><p>mkdir states cluster cert_manager issuers linkerd</p><p>In the cluster directory, we’ll create our state file in backend.tf as follows:</p><pre><em>terraform</em> {<br>  backend &quot;local&quot; {<br>    path = &quot;../states/cluster.tfstate&quot;<br>  }<br>}</pre><p>This will instruct terraform to keep the state file in the states/ directory. In these state files, terraform will hold important information like the cluster endpoint. In other components, we’ll use a data source called terraform_remote_state which will provide a reference to our outputs.</p><p>The separation of files in terraform does not generally matter — all .tf files in the directory will be merged by terraform unless otherwise specified — feel free to leave everything in one file if that is your cup of tea, but we’ve broken things up here for clarity.</p><p>We’ll then declare, in variables.tf, two variables.</p><pre><em>variable</em> &quot;zone&quot; {}<br><em>variable</em> &quot;project&quot; {}</pre><p>Variables expect Strings by default, and can take default values here or we can define them in any file that ends in .auto.tfvars, as we will do in cluster.auto.tfvars (feel free to use any zone you wish).</p><pre>zone = &quot;us-east1-b&quot;</pre><p>As of terraform 0.13, terraform requires defining provider and terraform versions, which we’ll do in versions.tf</p><pre>terraform {<br>  required_providers {<br>    google = {<br>      source  = &quot;hashicorp/google&quot;<br>      version = &quot;3.85.0&quot;<br>    }<br>  }<br>  required_version = &quot;&gt;= 1&quot;<br>}</pre><p>We then will create a terraform.tf file where we declare any outputs and provider configuration (again, this is just a personal convention, organize your code however it makes sense for you, all .tf files are equal). For now, we’ll just add the providers since we don’t know which outputs we need yet.</p><pre><em>provider</em> google {<br>  project = var.project<br>  zone    = var.zone<br>}</pre><p>Now any google resources we create in this component will default to using the project and zone specified in your variables, and terraform will know to use version 3.42 or higher of the <a href="https://www.terraform.io/docs/providers/google/index.html">google terraform provider</a>. If you don’t define them in a .auto.tfvars file, terraform will ask you interactively for them when you go to make changes.</p><h3>OK, Let’s Get Provisioning Already!</h3><p>We’re ready now to build some infrastructure — all we’ll need from our GCP project is a k8s cluster we can play in. In cluster.tf we will create a GKE cluster, kill its default pool, and create a small node pool for it to run our applications. The gist below includes the code above, plus a new file for our GKE Cluster with basic example configuration incluster.tf. In wterraform.tf we will add some outputs which we’ll need to know for authentication with the cluster.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd407bad36c63a5d6398d5706cbf2bf9/href">https://medium.com/media/dd407bad36c63a5d6398d5706cbf2bf9/href</a></iframe><p>Traverse into the cluster directory and initialize your component with terraform init — this will create your state file, download the providers you need, etc. Now we can run terraform apply</p><figure><img alt="An example of the diff generated by Terraform when running terraform apply" src="https://cdn-images-1.medium.com/max/1024/1*Wffyjqq4nyiLHh1_8j2xow.png" /><figcaption>Terraform will render this diff and ask for a `yes` to proceed</figcaption></figure><p>Terraform will ask for approval — type ‘yes’ or use terraform apply -auto-approve. When successful, terraform will give us our outputs at the bottom. You won’t need to write them down, as we’ll reference them dynamically from here.</p><p>We’re going to do the same thing for the rest of the components —next, we’ll apply cert-manager, then we’ll create our cert-manager resources, and, finally, the linkerd service mesh control plane. As we go along, I’ll explain each component’s role in this stack.</p><h4>Helm</h4><p>Helm is The Kubernetes Package Manager. Helm’s “charts” are declarative YAML templates of a given cloud-native application’s Kubernetes structures. This makes installing and upgrading cloud-native applications more elegant. It also comes with its own assumptions and drawbacks, but it can be a powerful delivery tool. We’ll see it in action via terraform as we use it to install cert-manager and linkerd, but it also has its own CLI. It’s important to note that Helm generally refers to Helm 3, and Helm 2 should not be used (Helm2&#39;s server-side controller was more security vulnerability than feature).</p><h4>Cert-Manager</h4><p><a href="https://cert-manager.io/docs/">Cert-manager</a> is an open source project which acts as a controller that performs certificate management tasks using a suite of different Kubernetes Custom Resource Definitions (CRDs) for Certificates, CertificateRequests, Issuers, etc. We use cert-manager to rotate the TLS certificates served by the ingresses inside many of our clusters. Using some token credentials to a DNS provider, cert-manager is able to create Challenges and then Webhooks to answer those Challenges. This proves to letsencrypt that the instance of cert-manager has ownership of the domain and therefore can be issued a verified certificate.</p><p>Below, in our next gist, we define the helm release with a name, a namespace to put it in, and a reference to the chart location, which is hosted by JetStack. Any custom values we need to supply, we can add to values.yaml.</p><p>Here’s the fun part — when authenticating with the cluster, we’ll use the cluster’s generated CA Certificate and a Google-generated auth token from our gcloud profile to authenticate to the Host, both of which dynamically reference the outputs from the cluster component. We can (but won’t, in this demo) use terraform <a href="https://www.terraform.io/docs/state/workspaces.html">workspaces</a> then to manage independent stacks, so that your dev Helm Release will know to release in your dev cluster!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c54b0aba60dc961cf52c17ff487a109b/href">https://medium.com/media/c54b0aba60dc961cf52c17ff487a109b/href</a></iframe><h4>CRDs</h4><p>Custom Resource Definitions (known as CRDs) are additional Kubernetes APIs/ structures specifically designed for consumption or response by certain cloud-native apps.</p><p>Be mindful that when you install CRDs using Helm, if you delete your release, all of your CRD objects such as signed Certificates will be deleted as well. To get around this, you may want to follow <a href="https://cert-manager.io/docs/installation/helm/">Option 1 here</a>.</p><h4>Cert-Manager CRDs</h4><p>In the “issuers” directory, we’ll use the <a href="https://registry.terraform.io/providers/hashicorp/tls/latest/docs">TLS provider</a> to generate a self-signed <a href="https://stackoverflow.com/questions/56061101/trust-anchor-certificates-in-pki">trust anchor</a> for our linkerd identity service. This resource will export attributes for its private and public keys. We’ll create a secret to hold this trust anchor.</p><p>Terraform has recently made headway in supporting raw yaml manifests in Terraform configuration. We’ll enable the experimental feature “manifest_resource” in our Kubernetes provider and use the new `kubernetes_manifest` resource to apply raw yaml as hcl for the Certificate and Issuer directly.</p><p>This is how we’ll create a Certificate resource, which cert-manager will reference to create and rotate a tls secret that will serve as the issuing CA for linkerd’s identity service. Cert-manager will use our trust anchor secret when generating that certificate. So, the full chain of the certificate presented by the linkerd proxies will be some leaf generated by linkerd-identity, from this new Certificate CA, from the original trust anchor. Certs are fun, I know.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d05f52cadac222aff66c895bf07b7af/href">https://medium.com/media/5d05f52cadac222aff66c895bf07b7af/href</a></iframe><h4>The Linkerd Control Plane</h4><p>Now, the easy part! We’re jUsT going to apply our transparent service mesh!</p><p>We need to tell the Helm release about the trust anchor PEM and issuer, and supply a set of standard HA values.</p><p>The values-ha.yaml file is pulled from the public helm chart and is used to add more replicas to the critical components, resources configs, and <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/">anti-affinity</a> to spread the pods across nodes. See <a href="https://artifacthub.io/packages/helm/linkerd2/linkerd2#setting-high-availability">note</a> from the helm chart</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f6e4a282e945ea3a1189579ac0e5ec3/href">https://medium.com/media/9f6e4a282e945ea3a1189579ac0e5ec3/href</a></iframe><h3>Now What?</h3><p>Now, any pods we run will be injected (unless specified otherwise) with a Linkerd proxy (the fastest in the industry, written in Rust) which will use the Linkerd control plane to not only validate mTLS but also provide latency-based load balancing, network metrics in the linkerd dashboard (consumable by any prometheus), configurable retries, etc.</p><p>From here, you might want to add trace header propagation for your distributed tracing, add Flagger to control Linkerd’s routing (i.e. for canary deploys), etc. The folks at Buoyant have also recently took Buoyant Cloud to General Availability, an observability and governance tool for your fully meshed network, across clusters, etc.</p><p>Congratulations to the Linkerd team for <a href="https://linkerd.io/2021/07/28/announcing-cncf-graduation/">achieving graduation from the CNCF</a>!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YECeOxlko9KoOJNw8RNm3A.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3acd59834d1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-prefect-blog/handsfree-mtls-in-kubernetes-e3acd59834d1">HandsFree mTLS in Kubernetes</a> was originally published in <a href="https://medium.com/the-prefect-blog">The Prefect Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>