<?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 Zoe McCormick on Medium]]></title>
        <description><![CDATA[Stories by Zoe McCormick on Medium]]></description>
        <link>https://medium.com/@zoemccormick?source=rss-54c56f824df6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*M3C54IRJZdWAZmp2WLGaVw.jpeg</url>
            <title>Stories by Zoe McCormick on Medium</title>
            <link>https://medium.com/@zoemccormick?source=rss-54c56f824df6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 19:31:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zoemccormick/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[Getting started with Envoy, SPIFFE, and Kubernetes]]></title>
            <link>https://zoemccormick.medium.com/getting-started-with-envoy-spiffe-and-kubernetes-32f34cda5f35?source=rss-54c56f824df6------2</link>
            <guid isPermaLink="false">https://medium.com/p/32f34cda5f35</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[spiffe]]></category>
            <category><![CDATA[envoy-proxy]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Zoe McCormick]]></dc:creator>
            <pubDate>Mon, 28 Jun 2021 15:34:35 GMT</pubDate>
            <atom:updated>2021-06-28T15:34:35.248Z</atom:updated>
            <content:encoded><![CDATA[<p>This guide will get you started with <a href="https://spiffe.io/docs/latest/spire-about/">SPIRE</a> and <a href="https://www.envoyproxy.io/docs/envoy/latest/configuration/security/secret">Envoy SDS</a> by walking through the deployment and configuration of an edge Envoy proxy and an Envoy sidecar in front of a simple app, configured to communicate with each other using SPIRE for mTLS.</p><h4>A quick intro</h4><p><a href="https://spiffe.io/">SPIFFE</a>, the Secure Production Identity Framework for Everyone, defines a set of standards to provide secure identities to individual workloads and can be leveraged to create a zero trust security model within your microservice architecture. The SPIFFE runtime environment, <a href="https://spiffe.io/docs/latest/spire-about/spire-concepts/">SPIRE</a>, is available to implement it.</p><p>I’ve recently spent time integrating SPIRE into the <a href="https://greymatter.io/">Grey Matter</a> platform, and I learned a lot about configuring and troubleshooting both SPIRE itself and its interaction with Envoy. With that experience, in this post I hope to provide a quick and easy guide for getting started with SPIRE on Kubernetes and how to configure <a href="https://www.envoyproxy.io/docs/envoy/latest/configuration/security/secret">Envoy SDS</a> to use it for service to service mTLS.</p><p><em>If you’re not sure about Envoy and/or SPIFFE/SPIRE, you can read more on SPIFFE — what it is, how it works, and who is using it </em><a href="https://spiffe.io/docs/latest/spiffe-about/overview/"><em>here</em></a><em>, and check out Envoy </em><a href="https://www.envoyproxy.io/"><em>here</em></a><em>.</em></p><h3>The setup</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*aWbDY1avKVv8kz6YppEKwA.png" /></figure><h3>Prerequisites</h3><p>To follow this guide, have the following:</p><ol><li>A running Kubernetes cluster with access to the environment. <em>Note that this deployment of SPIRE requires host networking access</em>.</li><li>Clone the repo for this guide:</li></ol><p>git clone https://github.com/zoemccormick/spire-envoy-example</p><p><a href="https://github.com/zoemccormick/spire-envoy-example">zoemccormick/spire-envoy-example</a></p><h3>Step 1: Install SPIRE</h3><h4>Note on the SPIRE Kubernetes Workload Registrar</h4><p>For this deployment, we will use the <a href="https://github.com/spiffe/spire/tree/main/support/k8s/k8s-workload-registrar#spire-kubernetes-workload-registrar">Kubernetes Workload Registrar service</a> provided by SPIRE.</p><p>This service runs alongside the SPIRE server and uses a ValidatingWebhookConfiguration to watch pods in the Kubernetes cluster as they are created. As pods come up, the registrar tells the server to create their unique identities, based on their pod information.</p><p>This is useful for automatic entry creation rather than manual, and hardens the attestation process by ensuring selectors (the specifications SPIRE uses to determine whether a workload can access a particular identity, see <a href="https://spiffe.io/docs/latest/deploying/registering/">the docs</a>) are properly added to identities.</p><h4>Configuration</h4><p><em>There are many complex internals for the server and agent configurations that I won’t go into detail on in this post — but the SPIRE project provides docs, examples, and information on each element. See </em><a href="https://github.com/spiffe/spire/blob/main/doc/spire_server.md#spire-server-configuration-reference"><em>here</em></a><em> for full server configuration docs, and </em><a href="https://github.com/spiffe/spire/blob/main/doc/spire_agent.md#spire-agent-configuration-reference"><em>here</em></a><em> for the agent.</em></p><p><em>It should be noted that the certificates used by the server &amp; agent for this guide are generated and checked into the repo — in a production environment these would need to be changed.</em></p><p>The pieces of SPIRE server/registrar configuration that are relevant to the future Envoy SDS configuration are:</p><ol><li><a href="https://github.com/zoemccormick/spire-envoy-example/blob/14ecdf31a053a612195b784eb685c45b63b367a1/spire/server_template.yaml#L75">trust_domain</a>: configured for the server and determines the format of the generated SPIFFE ID’s</li><li><a href="https://github.com/zoemccormick/spire-envoy-example/blob/14ecdf31a053a612195b784eb685c45b63b367a1/spire/server_template.yaml#L69">pod_label</a>: configured for the registrar service and determines if a SPIFFE identity is created for a new pod and (if so) the second piece of the format</li></ol><p>With these configurations — the server will generate SPIFFE identities with format spiffe://&lt;trust-domain&gt;/&lt;pod_label-value&gt; . This value is how Envoy’s request their identities from an SDS (which in our case is SPIRE).</p><p>For our example, we can see that we are using the <a href="https://github.com/zoemccormick/spire-envoy-example/blob/14ecdf31a053a612195b784eb685c45b63b367a1/spire/server_template.yaml#L75">trust_domain value </a><a href="https://github.com/zoemccormick/spire-envoy-example/blob/14ecdf31a053a612195b784eb685c45b63b367a1/spire/server_template.yaml#L75">quickstart.spire.io</a> , and <a href="https://github.com/zoemccormick/spire-envoy-example/blob/14ecdf31a053a612195b784eb685c45b63b367a1/spire/server_template.yaml#L69">pod_label value </a><a href="https://github.com/zoemccormick/spire-envoy-example/blob/14ecdf31a053a612195b784eb685c45b63b367a1/spire/server_template.yaml#L69">spire-discover</a>. For any pod created that has the Kubernetes label spire-discover , say spire-discover: example-service , it’s SPIFFE identity will be:</p><pre>spiffe://quickstart.spire.io/example-service</pre><h4>Install</h4><p>With the above configurations noted, install the server:</p><pre>kubectl apply -f spire/server_template.yaml</pre><p>Run kubectl get pods -n spire -w and wait for the spire server pod to come up with 2/2 containers. This is a limitation of using the registrar service and is necessary to ensure the service is watching to create identities when the spire agent pods are created.</p><p>When the server is 2/2, apply the agent:</p><pre>kubectl apply -f spire/agent_template.yaml</pre><p>The agent runs in a daemonset, so you should see a pod for each node of the cluster.</p><h3>Step 2: Install services</h3><h4>Configuration</h4><p>For this example, we will create a deployment running an edge Envoy proxy for ingress, and a deployment running a hello world service with a sidecar. To create these proxy images, I followed <a href="https://blog.markvincze.com/how-to-use-envoy-as-a-load-balancer-in-kubernetes/">this guide</a> from Mark Vinzce and pushed the docker images used in the deployment files.</p><p>Both Envoy proxies in this example, edge and the sidecar, will have the following <a href="https://www.envoyproxy.io/docs/envoy/v1.17.2/api-v2/api/v2/cluster.proto#cluster-configuration">cluster</a>:</p><pre>- name: spire_agent<br>    connect_timeout: 0.25s<br>    http2_protocol_options: {}<br>    load_assignment:<br>      cluster_name: spire_agent<br>      endpoints:<br>        - lb_endpoints:<br>          - endpoint:<br>              address:<br>                pipe:<br>                  path: /run/spire/socket/agent.sock</pre><p>We’ll point to this cluster in the TLS context for either a listener or cluster in order to tell Envoy SDS that it should talk to the spire agent over a unix socket at /run/spire/socket/agent.sock to get its certificates.</p><p><em>Note that there is a </em><a href="https://github.com/zoemccormick/spire-envoy-example/blob/14ecdf31a053a612195b784eb685c45b63b367a1/services/edge-deployment.yaml#L59-L67"><em>volume mount</em></a><em> on each deployment creating this socket.</em></p><h4>Edge proxy</h4><p>The full edge Envoy proxy configuration can be found <a href="https://github.com/zoemccormick/spire-envoy-example/blob/main/services/edge-deployment.yaml">here</a>. The important piece to talk through for this guide is the SDS configuration.</p><p>First, see that the <a href="https://github.com/zoemccormick/spire-envoy-example/blob/14ecdf31a053a612195b784eb685c45b63b367a1/services/edge-deployment.yaml#L39">edge deployment</a> contains the label spire-discover: edge-proxy — so we know it’s registered SPIFFE identity will be:</p><pre>spiffe://quickstart.spire.io/edge-proxy</pre><p>Now inspect the configuration. The proxy has a listener at port 10808 that is routing http traffic with path prefix &quot;/&quot; to the cluster named helloworld.</p><p>This cluster helloworld points at the sidecar at port 10808.</p><p>Take a look at the <a href="https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/transport_sockets/tls/v3/tls.proto#tls-transport-socket">transport_socket</a> for this cluster. This is where the connection from this edge-proxy to the sidecar in front of the helloworld app is configured to use its SPIFFE certificates.</p><pre>transport_socket:<br>      name: envoy.transport_sockets.tls<br>      typed_config:<br>        &quot;<a href="http://twitter.com/type">@type</a>&quot;: type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext<br>        common_tls_context:<br>          tls_certificate_sds_secret_configs:<br>          - name: spiffe://quickstart.spire.io/edge-proxy<br>            sds_config:<br>              api_config_source:<br>                api_type: gRPC<br>                grpc_services:<br>                  envoy_grpc:<br>                    cluster_name: spire_agent<br>          combined_validation_context:<br>            default_validation_context:<br>              match_subject_alt_names:<br>                exact: spiffe://quickstart.spire.io/helloworld<br>            validation_context_sds_secret_config:<br>              name: spiffe://quickstart.spire.io<br>              sds_config:<br>                api_config_source:<br>                  api_type: gRPC<br>                  grpc_services:<br>                    envoy_grpc:<br>                      cluster_name: spire_agent<br>          tls_params:<br>             ecdh_curves:<br>              - X25519:P-256:P-521:P-384</pre><p>The tls_certificate_sds_secret_configs configuration is telling Envoy SDS to ask the cluster spire_agent for the SPIFFE identity spiffe://quickstart.spire.io/edge-proxy . Since this identity was created for this proxy, the workload will be able to get this certificate from SPIRE.</p><p>Next, the combined validation context will verify the trust_domain, and match_subject_alt_names says to only allow the connection if the certificate presented by the connection has SAN spiffe://quickstart.spire.io/helloworld .</p><h4>Sidecar</h4><p>The second Envoy proxy runs in the same pod as a simple helloworld app. All communication to the app will go through the proxy. The full configuration for this proxy can be found <a href="https://github.com/zoemccormick/spire-envoy-example/blob/main/services/hello-world/envoy.yaml">here</a>.</p><p>See that the <a href="https://github.com/zoemccormick/spire-envoy-example/blob/main/services/backend-deployment.yaml#L21">backend deployment</a> contains the label spire-discover: helloworld— so this proxy’s registered SPIFFE identity will be:</p><pre>spiffe://quickstart.spire.io/helloworld</pre><p>This proxy also has a listener at port 10808, and this time the transport_socket is set on the listener rather than on a cluster. This is important to the flow — the edge proxy is configured to use SPIFFE certificates on its egress to the sidecar, and the sidecar is configured to use SPIFFE certificates on its ingress listener.</p><pre>transport_socket:<br>        name: envoy.transport_sockets.tls<br>        typed_config:<br>          &quot;<a href="http://twitter.com/type">@type</a>&quot;: type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext<br>          common_tls_context:<br>            tls_certificate_sds_secret_configs:<br>            - name: spiffe://quickstart.spire.io/helloworld<br>              sds_config:<br>                api_config_source:<br>                  api_type: gRPC<br>                  grpc_services:<br>                    envoy_grpc:<br>                      cluster_name: spire_agent<br>            combined_validation_context:<br>              default_validation_context:<br>                match_subject_alt_names:<br>                  exact: spiffe://quickstart.spire.io/edge-proxy<br>              validation_context_sds_secret_config:<br>                name: spiffe://quickstart.spire.io<br>                sds_config:<br>                  api_config_source:<br>                    api_type: gRPC<br>                    grpc_services:<br>                      envoy_grpc:<br>                        cluster_name: spire_agent<br>            tls_params:<br>               ecdh_curves:<br>                - X25519:P-256:P-521:P-384</pre><p>The configuration is nearly identical, but the identity name being requested is now spiffe://quickstart.spire.io/helloworld since that is the identity for this proxy, and the match subject alternative names is now spiffe://quickstart.spire.io/edge-proxy since that will be the SAN of the certificate coming from the edge proxy.</p><p>The sidecar has a cluster named local , that points to the helloworld app and connects over localhost in the same pod.</p><h4>Install</h4><p>Install both deployments:</p><pre>kubectl apply -f services/edge-deployment.yaml</pre><pre>kubectl apply -f services/backend-deployment.yaml</pre><p>Once these pods come up (they will be in the default namespace), you should be able to access the deployment via the ingress service deployed as a load balancer in your environment.</p><h3>Testing</h3><p>Grab the external IP address for your ingress load balancer from kubectl get svc edge-proxy .</p><p>Navigate to http://{external-IP}:10808/ in a browser or via curl, and you should receive the response:</p><pre>Hello, world!<br>Version: 1.0.0<br>Hostname: helloworld-56b5668bc5-tpgkr</pre><p>If this is the response you receive, you have successfully deployed Envoy proxies to connect using SPIFFE mTLS! If you don’t see this, try some of <a href="https://docs.greymatter.io/usage/security/spire/troubleshoot-spire">our troubleshooting tips</a> at Grey Matter.</p><p>There are a couple of ways to check out what is going on internally, if you port-forward either pod to 8001:8001 , you can curl the Envoy admin endpoint.</p><ul><li>curl localhost:8001/config_dump to see the entire proxy configuration</li><li>curl localhost:8001/certs to see the certificates for the proxy — they will be the SPIFFE certificates with that proxies identity</li><li>curl localhost:8001/stats to see statistics — grep for ssl for security specific stats</li></ul><h3>Final Thoughts</h3><p>If you’ve made it this far, thanks for following along! Hopefully someone may have found this helpful. Feel free to reach out with thoughts/feedback — I can be found in the Envoy slack.</p><h3>References</h3><ul><li><a href="https://blog.markvincze.com/how-to-use-envoy-as-a-load-balancer-in-kubernetes/">https://blog.markvincze.com/how-to-use-envoy-as-a-load-balancer-in-kubernetes/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32f34cda5f35" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>