<?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 Lachlan Evenson on Medium]]></title>
        <description><![CDATA[Stories by Lachlan Evenson on Medium]]></description>
        <link>https://medium.com/@LachlanEvenson?source=rss-5d4f384fa574------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*PgdhDOukphwN-T3d.jpeg</url>
            <title>Stories by Lachlan Evenson on Medium</title>
            <link>https://medium.com/@LachlanEvenson?source=rss-5d4f384fa574------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 04:15:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@LachlanEvenson/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[Testing Gatekeeper constraints with gator CLI]]></title>
            <link>https://medium.com/@LachlanEvenson/testing-gatekeeper-constraints-with-gator-cli-da31050a6564?source=rss-5d4f384fa574------2</link>
            <guid isPermaLink="false">https://medium.com/p/da31050a6564</guid>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cncf]]></category>
            <dc:creator><![CDATA[Lachlan Evenson]]></dc:creator>
            <pubDate>Wed, 24 Nov 2021 19:47:43 GMT</pubDate>
            <atom:updated>2021-11-24T19:47:43.180Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2dTvWEHieSFJrynBsZQdcA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@mappingmegantravel?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Meg Jerrard</a> on <a href="https://unsplash.com/s/photos/gator?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Having worked with <a href="https://github.com/open-policy-agent/gatekeeper">Gatekeeper</a> for several years, one frequent ask I’ve heard from the community is <em>“How do I test Gatekeeper constraints before they are applied to Kubernetes?”.</em></p><p>I’ve always thought that testing policy as part of your CI/CD GitOps process was the destination. The <a href="https://github.com/open-policy-agent/gatekeeper/releases">Gatekeeper 3.7 release</a> introduces a new CLI tool called <em>gator</em> that allows you to test constraint and constraint templates <strong>BEFORE</strong> they are applied to a Kubernetes cluster. In this blog we are going to walk through an example of how to use the gator CLI.</p><p><strong>NOTE: </strong>At the time of writing this blog gator was not well documented and I had to do some Github sleuthing to piece together how to use. I share this blog in the hope that it might encourage the community to rally around this tool further develop it. Gator is currently in alpha.</p><h3>Setup</h3><p>First, you will need to download the gator CLI from the <a href="https://github.com/open-policy-agent/gatekeeper/releases/tag/v3.7.0">Gatekeeper releases site</a> for your platform. Once you have installed gator in your PATH, run it to check the version</p><pre>$ gator -v<br>gator version alpha</pre><h3>Testing constraints and constraint templates</h3><p>Next, we are going to clone the <a href="https://github.com/open-policy-agent/gatekeeper-library">Gatekeeper policy library</a> and walk through an example.</p><pre>$ git clone <a href="/service/mailto:git@github.com">git@github.com</a>:open-policy-agent/gatekeeper-library.git<br>$ cd gatekeeper-library</pre><p>No let’s run all test suites in the repository using the following command (I’ve edited the paths in the output for better readability):</p><pre>$ gator test ./...<br>ok library/general/allowedrepos/suite.yaml 0.136s<br>ok library/general/block-endpoint-edit-default-role/suite.yaml 0.150s<br>ok library/general/block-nodeport-services/suite.yaml 0.099s<br>ok library/general/containerlimits/suite.yaml 0.162s<br>PASS</pre><p>From the output above we see that a total of four test suites were run and that they were all <strong>ok</strong> which resulted in a <strong>PASS</strong>. You can obviously run specific suites however in this case I’ve run all suites identified in all paths under the current directory.</p><p>Let’s take a look at the library/general/allowedrepos/suite.yaml specifically.</p><pre>kind: Suite<br>apiVersion: test.gatekeeper.sh/v1alpha1<br>tests:<br>- name: allowed-repos<br>  template: template.yaml<br>  constraint: samples/repo-must-be-openpolicyagent/constraint.yaml<br>  cases:<br>  - name: example-allowed<br>    object: samples/repo-must-be-openpolicyagent/example_allowed.yaml<br>    assertions:<br>    - violations: no<br>  - name: example-disallowed<br>    object: samples/repo-must-be-openpolicyagent/example_disallowed.yaml<br>    assertions:<br>    - violations: yes</pre><p>The suite.yaml file defines the constraint template, the constraint, then a number of cases with their associated assertions. Checkout the <a href="https://open-policy-agent.github.io/gatekeeper/website/docs/constrainttemplates">docs</a> to learn more about constraint templates and constraints as I won’t cover them in this blog.</p><p>This constraint template and constraint enforces that containers only come from a defined list of repositories. In this test example, the only allowed repository is openpolicyagent/. The cases contain Kubernetes pod specifications, one that won’t violate the constraint and the other that will.</p><p>Let’s update the example-disallowed case from above and change the violation assertion to no. I would now expect this test to fail and provide an error. In the next command I’m going to run only the allowedrepos/suite.yaml to demonstrate.</p><pre>$ gator test library/general/allowedrepos/suite.yaml<br>    --- FAIL: example-disallowed (0.038s)<br>        unexpected number of violations: got 1 violations but want none: got messages [container &lt;nginx&gt; has an invalid image repo &lt;nginx&gt;, allowed repos are [&quot;openpolicyagent/&quot;]]<br>--- FAIL: allowed-repos (0.120s)<br>FAIL Users/laevenso/gocode/src/github.com/open-policy-agent/gatekeeper-library/library/general/allowedrepos/suite.yaml 0.120s<br>FAIL</pre><pre>Error: FAIL</pre><p>We can confirm that the output above failed as expected and provided an actionable error message.</p><h3>Summary</h3><p>The gator CLI is a new tool that ships with Gatekeeper version 3.7 and provides policy authors a way to test policy prior to being deployed to Kubernetes. I expect that more and more public policy libraries will be available in future and will ship with the appropriate tests. This allows policy authors to validate Gatekeeper constraint templates and constraints using gator as part of Gitops process.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da31050a6564" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Verifying container signatures on Kubernetes with Gatekeeper]]></title>
            <link>https://medium.com/@LachlanEvenson/verifying-container-signatures-on-kubernetes-with-gatekeeper-19a4519c3016?source=rss-5d4f384fa574------2</link>
            <guid isPermaLink="false">https://medium.com/p/19a4519c3016</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Lachlan Evenson]]></dc:creator>
            <pubDate>Tue, 23 Nov 2021 22:18:37 GMT</pubDate>
            <atom:updated>2021-11-23T22:18:37.541Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JFQ2_jFYAL4ZwRUXGAiCMQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@docusign?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">DocuSign</a> on <a href="https://unsplash.com/s/photos/signature?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Given the recent focus on container software supply chain security I’ve been increasingly asked how to verify container signatures before they are run on Kubernetes. There are a few solutions out there including <a href="https://github.com/sigstore/helm-charts/tree/main/charts/cosigned#enabling-admission-control">cosigned</a> which is a Kubernetes webhook admission controller that handles <a href="https://github.com/sigstore/cosign">cosign</a> signature verification. Another solution is <a href="https://github.com/open-policy-agent/gatekeeper">Gatekeeper</a> which is a Kubernetes policy controller built on Open Policy Agent. I’m going to focus on how you can use some new features in Gatekeeper to enable container signature verification. For this blog we are going to leverage the work of <a href="https://twitter.com/developerguyba">developer-guy</a> by walking through the following <a href="https://github.com/developer-guy/cosign-gatekeeper-provider">repo</a>. The reason I’m diving into Gatekeeper is that I’m a contributor to the project and it’s also likely that if you have an interest in policy and governance for your Kubernetes cluster that you likely already have it installed.</p><p><strong>NOTE: </strong>In order to verify the signatures we are going to us a new alpha feature in Gatekeeper called <a href="https://github.com/open-policy-agent/gatekeeper/pull/1677">external data</a>. This feature is not yet ready for production and I recommend keeping an eye on the project as it matures.</p><h3>Setup</h3><p>If you want to follow along you’re going to need a Kubernetes cluster. I use <a href="https://kind.sigs.k8s.io/">Kind</a> which is quick and easy to test with. I’m using the following config which configures Kind to create a cluster with one control-plane node and one worker node.</p><pre>$ cat kind-config.yaml<br>kind: Cluster<br>apiVersion: kind.x-k8s.io/v1alpha4<br>nodes:<br>- role: control-plane<br>- role: worker</pre><p>Create a Kubernetes cluster using Kind and the configuration with the following command:</p><pre>$ kind create cluster --image=kindest/node:v1.22.4@sha256:ca3587e6e545a96c07bf82e2c46503d9ef86fc704f44c17577fca7bcabf5f978 --config kind-config.yaml<br>Creating cluster &quot;kind&quot; ...<br> ✓ Ensuring node image (kindest/node:v1.22.4) 🖼<br> ✓ Preparing nodes 📦 📦<br> ✓ Writing configuration 📜<br> ✓ Starting control-plane 🕹️<br> ✓ Installing CNI 🔌<br> ✓ Installing StorageClass 💾<br> ✓ Joining worker nodes 🚜<br>Set kubectl context to &quot;kind-kind&quot;<br>You can now use your cluster with:</pre><pre>kubectl cluster-info --context kind-kind</pre><pre>Have a question, bug, or feature request? Let us know! <a href="https://kind.sigs.k8s.io/#community">https://kind.sigs.k8s.io/#community</a> 🙂</pre><p>Finally, let’s check out the repo that enables the signature verification functionality. This repo implements an external data provider for Gatekeeper which will perform cosign signature verification. Once you have the repo cloned navigate to the directory you have it cloned to.</p><pre>$ git clone <a href="https://github.com/developer-guy/cosign-gatekeeper-provider">https://github.com/developer-guy/cosign-gatekeeper-provider</a></pre><h3>Installation</h3><p>Let’s install Gatekeeper on the Kind cluster you just created with the following commands:</p><pre>$ helm repo add gatekeeper <a href="https://open-policy-agent.github.io/gatekeeper/charts">https://open-policy-agent.github.io/gatekeeper/charts</a><br>$ helm install gatekeeper/gatekeeper  \<br>    --name-template=gatekeeper \<br>    --namespace gatekeeper-system --create-namespace \<br>    --set enableExternalData=true \<br>    --set controllerManager.dnsPolicy=ClusterFirst,audit.dnsPolicy=ClusterFirst</pre><p>Gatekeeper will be installed into the gatekeeper-system namespace with the ExternalData feature configured. The output of running those commands should look similar to the following:</p><pre>$ helm repo add gatekeeper <a href="https://open-policy-agent.github.io/gatekeeper/charts">https://open-policy-agent.github.io/gatekeeper/charts</a><br>&quot;gatekeeper&quot; has been added to your repositories<br>$ helm install gatekeeper/gatekeeper  \<br>    --name-template=gatekeeper \<br>    --namespace gatekeeper-system --create-namespace \<br>    --set enableExternalData=true \<br>    --set controllerManager.dnsPolicy=ClusterFirst,audit.dnsPolicy=ClusterFirst<br>W1123 09:16:14.638113   19746 warnings.go:70] policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+<br>W1123 09:16:20.546423   19746 warnings.go:70] policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+<br>W1123 09:16:20.616861   19746 warnings.go:70] spec.template.metadata.annotations[container.seccomp.security.alpha.kubernetes.io/manager]: deprecated since v1.19; use the &quot;seccompProfile&quot; field instead<br>W1123 09:16:20.619963   19746 warnings.go:70] spec.template.metadata.annotations[container.seccomp.security.alpha.kubernetes.io/manager]: deprecated since v1.19; use the &quot;seccompProfile&quot; field instead<br>NAME: gatekeeper<br>LAST DEPLOYED: Tue Nov 23 09:16:13 2021<br>NAMESPACE: gatekeeper-system<br>STATUS: deployed<br>REVISION: 1<br>TEST SUITE: None</pre><p>You can verify that Gatekeeper is up and running using the following command:</p><pre>$ kubectl get pods -n gatekeeper-system<br>NAME                                            READY   STATUS    RESTARTS   AGE<br>gatekeeper-audit-7868876c65-...     1/1     Running   0          40s<br>gatekeeper-controller-manager-...   1/1     Running   0          40s<br>gatekeeper-controller-manager-...   1/1     Running   0          40s<br>gatekeeper-controller-manager-...   1/1     Running   0          40s</pre><p>Next, we’ll install the cosign-gatekeeper-provider which is responsible for verifying cosign signatures.</p><pre>$ kubectl apply -f manifest<br>namespace/cosign-gatekeeper-provider created<br>deployment.apps/cosign-gatekeeper-provider created<br>provider.externaldata.gatekeeper.sh/cosign-gatekeeper-provider created<br>service/cosign-gatekeeper-provider created</pre><p>The command above creates a dedicated namespace to run the provider, a service and a deployment for the provider, and a Gatekeeper specific provider configuration. Gatekeeper will look for any provider configurations and utilize them when configured via policy (more on that in a moment). Take a look at the provider manifest.</p><pre>apiVersion: externaldata.gatekeeper.sh/v1alpha1<br>kind: Provider<br>metadata:<br>  name: cosign-gatekeeper-provider<br>spec:<br>  url: <a href="http://cosign-gatekeeper-provider.cosign-gatekeeper-provider:8090/validate">http://cosign-gatekeeper-provider.cosign-gatekeeper-provider:8090/validate</a><br>  timeout: 30</pre><p>Take a look at the details in the provider configuration above. It contains a name and the URL of where the provider is running (which points to the service and deployment configured in the previous step). Next we are going to install the template and the constraint which will configure Gatekeeper with desired policy.</p><pre>$ kubectl apply -f policy/template.yaml<br>constrainttemplate.templates.gatekeeper.sh/k8sexternaldatacosign created<br>$ kubectl apply -f policy/constraint.yaml<br>k8sexternaldatacosign.constraints.gatekeeper.sh/cosign-gatekeeper-provider created</pre><p>Let’s take a closer look at those resources. I want to focus on a specific piece of the template configuration from lines 15–20.</p><pre>...<br>violation[{&quot;msg&quot;: msg}] {<br>          # build a list of keys containing images<br>          images := [img | img = input.review.object.spec.template.spec.containers[_].image]</pre><pre># send external data request<br>          response := external_data({&quot;provider&quot;: &quot;cosign-gatekeeper-provider&quot;, &quot;keys&quot;: images})<br>...</pre><p>The above snippet creates a list of container images then sends that list to the external data provider named cosign-gatekeeper-provider for verification.</p><p>Finally, let’s take a look at the constraint:</p><pre>apiVersion: constraints.gatekeeper.sh/v1beta1<br>kind: K8sExternalDataCosign<br>metadata:<br>  name: cosign-gatekeeper-provider<br>spec:<br>  enforcementAction: deny<br>  match:<br>    namespaces:<br>      - default<br>    kinds:<br>      - apiGroups: [&quot;apps&quot;]<br>        kinds: [&quot;Deployment&quot;]</pre><p>This constraint configures Gatekeeper to apply this policy to all deployments in the default namespace with an enforcement action of deny.</p><h3>Seeing it in action</h3><p>Now that we have everything setup, let’s see it in action.</p><p>First will apply a deployment manifest using an image that hasn’t been signed. <strong>NOTE: </strong>The demo uses container images provided by the repository maintainer. Feel free to replace these images with ones that you’ve signed/not signed. I verified that containers signed using the <a href="https://github.com/sigstore/cosign/blob/main/KEYLESS.md">keyless</a> method provided here also works with this provider.</p><pre>$ kubectl apply -f policy/examples/error.yaml<br>Error from server ([cosign-gatekeeper-provider] invalid response: {&quot;errors&quot;: [], &quot;responses&quot;: [], &quot;status_code&quot;: 200, &quot;system_error&quot;: &quot;VerifyImageSignatures: no matching signatures:\n&quot;}): error when creating &quot;policy/examples/error.yaml&quot;: admission webhook &quot;validation.gatekeeper.sh&quot; denied the request: [cosign-gatekeeper-provider] invalid response: {&quot;errors&quot;: [], &quot;responses&quot;: [], &quot;status_code&quot;: 200, &quot;system_error&quot;: &quot;VerifyImageSignatures: no matching signatures:\n&quot;}</pre><p>You see the following message from the output above.</p><pre>&quot;system_error&quot;: &quot;VerifyImageSignatures: no matching signatures</pre><p>Let’s try a signed container:</p><pre>$ kubectl apply -f policy/examples/valid.yaml<br>deployment.apps/valid-deployment created</pre><p>You can see that the signed container is created without error. We can also take a look at the cosign-gatekeeper-provider log file to see the verification in action.</p><pre>$ kubectl logs -f cosign-gatekeeper-provider-67798c57c8-kf77p -n cosign-gatekeeper-provider<br>starting server...<br>verify signature for: devopps/alpine:notsigned<br>no matching signatures:<br>verify signature for: devopps/alpine:signed<br>signature verified for: devopps/alpine:signed <br>1 number of valid signatures found for devopps/alpine:signed, found signatures: [0xc0003f7050]</pre><h3>The provider code</h3><p>Just in case you’re interested, the provider code (<a href="https://github.com/developer-guy/cosign-gatekeeper-provider/blob/master/provider.go">provider.go</a>) is pretty straight forward. Most of the work is done in the following block. It grabs the public root certs from Fulcio and checks that the container image was signed while the key was valid using Rekor.</p><pre>checkedSignatures, bundleVerified, err := cosign.VerifyImageSignatures(ctx, ref, &amp;cosign.CheckOpts{<br>   RekorURL:           &quot;<a href="https://rekor.sigstore.dev/">https://rekor.sigstore.dev</a>&quot;,<br>   RegistryClientOpts: co,<br>   RootCerts:          fulcio.GetRoots(),<br>  })</pre><h3>Wrap up</h3><p>Using external data in Gatekeeper allows for runtime configurable providers that enable a seamless way to hand off to some external system to make policy decisions. In this case, we demonstrated using cosign to validate container signatures before they are run on a Kubernetes cluster. The external data feature in Gatekeeper looks promising and I look forward to see how how software supply chain artifacts such as security scans and SBOMs are validated using the same provider model.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19a4519c3016" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Container signing with Notary v2]]></title>
            <link>https://medium.com/@LachlanEvenson/container-signing-with-notary-v2-13dd425e95d6?source=rss-5d4f384fa574------2</link>
            <guid isPermaLink="false">https://medium.com/p/13dd425e95d6</guid>
            <category><![CDATA[cloud-native-security]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[containers]]></category>
            <dc:creator><![CDATA[Lachlan Evenson]]></dc:creator>
            <pubDate>Fri, 05 Nov 2021 17:59:31 GMT</pubDate>
            <atom:updated>2021-11-05T17:59:31.373Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CgdM_gU5BAVA09f0_JrBjA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@toyamakanna?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">戸山 神奈</a> on <a href="https://unsplash.com/s/photos/wax-seal?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>With the recent release of <a href="https://github.com/notaryproject/notation/releases/tag/v0.7.0-alpha.1">Notary v2 alpha 1</a> I wanted to dive in and share how the Notation CLI can be used to sign and verify container images (full disclosure — I am a collaborator on the Notary v2 project). You can find more details in the announcement <a href="https://notaryproject.dev/blog/2021/announcing-notation-alpha1/">blog</a>. The blog also covers some interesting use cases including signing and attaching additional supply chain artifacts to a container image through the use of the <a href="https://github.com/oras-project/artifacts-spec/">ORAS artifacts spec</a>. The attachment of these artifacts to a container image makes it easy to discover a graph of supply chain artifacts for example signatures, SBOMs, and image scan results using a tool to query the container registry.</p><p>As denoted via the alpha stability marker on the release it’s early days for Notary v2 so keep an eye on this space as things are moving fast. In this blog I’m going to cover the following:</p><ul><li><strong>Signing and verification workflows</strong></li><li><strong>Adding and verifying additional signatures</strong></li><li><strong>Signing and storage of additional supply chain artifacts to a container image</strong></li></ul><p>At the end of this blog you will be able to sign, store, and verify the full graph of supply chain artifacts associated with a container image using Notary v2. If the image below doesn’t already blow your mind then it soon will.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NrGu5Tq2brBXe9JytIpP9g.png" /><figcaption>Full graph of signed supply chain artifacts associated with a container image</figcaption></figure><p>Let’s dive in…</p><h3>Setup</h3><p>First we’re going to download two different tools to run through this walkthrough. For the signing and verification part of the walkthrough we’re going to need the Notation CLI binary. Navigate to <a href="https://github.com/notaryproject/notation/releases/tag/v0.7.0-alpha.1">Notation releases page</a> for details on how to download and install notation.</p><pre>$ notation --version</pre><pre>notation version 0.7.0-alpha.1</pre><p><em>This next step is optional depending if you are interested in how to store a graph of supply chain artifacts in a registry and associate them with a specific container image.</em></p><p>(OPTIONAL) For the ORAS CLI — We’re going to build from source from the artifacts branch of the <a href="https://github.com/oras-project/oras/tree/artifacts">ORAS repo</a>. I’m on a Mac so I used the make build-mac command. Feel free to take a look at the <a href="https://github.com/oras-project/oras/blob/artifacts/Makefile">Makefile</a> to build for your platform.</p><pre>$ oras version</pre><pre>Version:        0.11.1+unreleased<br>Go version:     go1.17.1<br>Git commit:     7e9d3a890899a190f96fac617ec20beb2926f276<br>Git tree state: clean</pre><p>Finally, we can define some environment variables to help through the process. In this example I’m using a test Azure Container Registry endpoint which supports the <a href="https://github.com/oras-project/artifacts-spec/">ORAS artifacts spec</a>. If you don’t have access to registry that support ORAS artifacts spec you can run a version of the CNCF Distribution registry that provides support for the ORAS Artifacts spec. Please refer to the <strong>Local Setup</strong> section below for more details.</p><pre>export ACR_NAME=wabbitnetworks<br>export REGISTRY=$ACR_NAME.azurecr-test.io<br>export REPO=${REGISTRY}/lachie/net-monitor<br>export IMAGE=${REPO}:v1</pre><pre># AUTH TOKENS FOR REGISTRY ACCESS<br>export NOTATION_USERNAME=&#39;&lt;TOKEN_USERNAME&gt;&#39;<br>export NOTATION_PASSWORD=&#39;&lt;SECRET_TOKEN&gt;&#39;</pre><pre>docker login $REGISTRY -u $NOTATION_USERNAME -p $NOTATION_PASSWORD</pre><h3>Local Setup</h3><p>In the case that you don’t have access to a container registry that support ORAS artifacts spec you can run through the following demo using a local setup. You will need Docker setup on your machine for this work. Run a local container registry by running the following command:</p><pre>docker run -d -p ${PORT}:5000 ghcr.io/oras-project/registry:v0.0.3-alpha</pre><p>Now configure Notation to be able to use a registry without HTTPS (remember, this is only to test the demo). I’m using a Mac so the PATH to this file may be different, I’ve seen ~/.config/notation on Linux hosts.</p><pre>echo &#39;{&quot;insecureRegistries&quot;: [&quot;localhost:5000&quot;]}&#39; &gt; /Users/&lt;USER&gt;/Library/Application Support/notation/config.json</pre><p>Finally, set the following environment variables.</p><pre>export PORT=5000<br>export REGISTRY=localhost:${PORT}<br>export REPO=${REGISTRY}/lachie/net-monitor<br>export IMAGE=${REPO}:v1</pre><h3>Signing your Container image</h3><p>In this section we are going to use the Notation CLI to sign a container and push the signature to container registry with ORAS artifacts spec support. We will then verify the signature. Here is the container we are going to be working on throughout this blog (In order to change this to your own container registry simply update the REGISTRY environment variable to your own):</p><pre>$ echo $IMAGE</pre><pre>wabbitnetworks.azurecr-test.io/lachie/net-monitor:v1</pre><p>Build and push the container image. (Again you can use a local registry to test this out — check out the setup section for details on how to run that locally).</p><pre>$ docker build -t $IMAGE <a href="https://github.com/wabbit-networks/net-monitor.git#main">https://github.com/wabbit-networks/net-monitor.git#main</a></pre><pre>$ docker push $IMAGE<br>...<br>The push refers to repository [wabbitnetworks.azurecr-test.io/lachie/net-monitor]<br>e2eb06d8af82: Mounted from net-monitor<br>v1: digest: sha256:a0fc570a245b09ed752c42d600ee3bb5b4f77bbd70d889... size: 527</pre><p>Now that we have a container image in a container registry we can use the Notation CLI to sign that container image. First we need to generate a key and certificate to sign the image. You can do that using the following command:</p><pre>$ notation cert generate-test --default &quot;wabbit-networks.io&quot;</pre><pre>generating RSA Key with 2048 bits<br>generated certificates expiring on 2022-10-29T21:15:32Z<br>wrote key: /Users/&lt;USER&gt;/Library/Application Support/notation/key/wabbit-networks.io.key<br>wrote certificate: /Users/&lt;USER&gt;/Library/Application Support/notation/certificate/wabbit-networks.io.crt<br>wabbit-networks.io: added to the key list<br>wabbit-networks.io: marked as default</pre><p>Now that we have a key and certificate we can sign the container image.</p><pre>$ notation sign $IMAGE</pre><pre>sha256:a0fc570a245b09ed752c42d600ee3bb5b4f77bbd70...</pre><p>The previous step signed the container image and pushed that signature to the container registry we configured as part of the setup. Now we can list the signatures associated with the container registry using the following command:</p><pre>$ notation list $IMAGE</pre><pre>sha256:54553368a416f44a6bcb7aabbb14b5b6da9ceafbea02f0d34...</pre><h3>Verifying the signature</h3><p>Now that we’ve signed the container image and pushed the signature to a container registry, let’s verify the signature using the Notation CLI.</p><pre>$ notation verify $IMAGE</pre><pre>2021/10/29 14:17:55 trust certificate not specified</pre><p>The output of the command above indicates that we haven’t yet configured a certificate that we trust for verification. Let’s go ahead and add that then perform the verify again. We will use the notation cert add command to tell the Notation CLI that we want to trust the certificate we created earlier.</p><pre>$ notation cert add --name &quot;wabbit-networks.io&quot; /Users/&lt;USER&gt;/Library/Application\ Support/notation/certificate/wabbit-networks.io.crt<br>wabbit-networks.io</pre><p>If we run the verify command again we can now verify the signature on the container image.</p><pre>$ notation verify $IMAGE</pre><pre>sha256:a0fc570a245b09ed752c42d600ee3bb5b4f77bbd70d...</pre><p>Let’s also take a look at the Notation CLI config file to see which keys we are using to sign and which ones we trust for verification (Remember I’m on a Mac so the PATH of this config file may change depending on your platform).</p><pre>$ cat /Users/&lt;USER&gt;/Library/Application\ Support/notation/config.json</pre><pre>{<br>    &quot;verificationCerts&quot;: {<br>        &quot;certs&quot;: [<br>            {<br>                &quot;name&quot;: &quot;wabbit-networks.io&quot;,<br>                &quot;path&quot;: &quot;/Users/&lt;USER&gt;/Library/Application Support/notation/certificate/wabbit-networks.io.crt&quot;<br>            }<br>        ]<br>    },<br>    &quot;signingKeys&quot;: {<br>        &quot;default&quot;: &quot;wabbit-networks.io&quot;,<br>        &quot;keys&quot;: [<br>            {<br>                &quot;name&quot;: &quot;wabbit-networks.io&quot;,<br>                &quot;keyPath&quot;: &quot;/Users/&lt;USER&gt;/Library/Application Support/notation/key/wabbit-networks.io.key&quot;,<br>                &quot;certPath&quot;: &quot;/Users/&lt;USER&gt;/Library/Application Support/notation/certificate/wabbit-networks.io.crt&quot;<br>            }<br>        ]<br>    },<br>    &quot;insecureRegistries&quot;: []<br>}</pre><h3>Discovering supply chain artifacts associated with a container image</h3><p>This part is really cool — using the ORAS cli we can query the container registry for supply chain artifacts associated with a specific container image. Remember, you need a registry that supports ORAS artifacts specification. There are details for how to run a local container registry with support in the setup section. In this example I’m using an Azure Container Registry endpoint that supports the ORAS artifacts spec.</p><pre>$ oras discover -o tree -u $NOTATION_USERNAME -p $NOTATION_PASSWORD $IMAGE</pre><pre>wabbitnetworks.azurecr-test.io/lachie/net-monitor:v1<br>└── application/vnd.cncf.notary.v2.signature<br>    └── sha256:db09eb93b235fd5135feff3cae49e48955e3d5...</pre><p>The output above shows that there is a Notary v2 signature associated with the container image. We can also pull the manifests from the registry to take a look at how they are stored. In the output below we see the digest of the container image itself with the v1 tag. In addition, the signature digest without tags. You may have noticed that this digest is identical to the sha256 output from the command above.</p><pre>$ az configure --default acr=wabbitnetworks</pre><pre>$ az acr repository show-manifests -n wabbitnetworks  --repository lachie/net-monitor -o jsonc</pre><pre>[<br>  {<br>    &quot;digest&quot;: &quot;sha256:a0fc570a245b09ed752c42d600ee3bb5b4f77bbd70d8898780b7ab43454530eb&quot;,<br>    &quot;tags&quot;: [<br>      &quot;v1&quot;<br>    ],<br>    &quot;timestamp&quot;: &quot;2021-10-29T21:12:28.7396899Z&quot;<br>  },<br>  {<br>    &quot;digest&quot;: &quot;sha256:db09eb93b235fd5135feff3cae49e48955e3d504fbac82683a853d5f1e32a0dc&quot;,<br>    &quot;tags&quot;: [],<br>    &quot;timestamp&quot;: &quot;2021-10-29T21:16:16.6682125Z&quot;<br>  }<br>]</pre><h3>Adding a Second Signature</h3><p>In some cases you will want to use a signed image from an upstream source, store it in your container registry and sign it with your own signing key. Let’s walk through how that works using the Notation CLI. For the purposes of the demo I’m going to run the next commands on different dev machine without any prior Notation CLI configuration.</p><p>First lets generate a new signing key.</p><pre>$ notation cert generate-test --default &quot;acme-rockets.io-library&quot;</pre><pre>generating RSA Key with 2048 bits<br>generated certificates expiring on 2022-10-29T21:41:45Z<br>wrote key: /Users/&lt;USER&gt;/Library/Application Support/notation/key/acme-rockets.io-library.key<br>wrote certificate: /Users/&lt;USER&gt;/Library/Application Support/notation/certificate/acme-rockets.io-library.crt<br>acme-rockets.io-library: added to the key list<br>acme-rockets.io-library: marked as default</pre><p>We can also add the signing key we just created for verification to Notation CLI.</p><pre>$ notation cert add --name &quot;acme-rockets.io-library&quot; /Users/&lt;USER&gt;/Library/Application\ Support/notation/certificate/acme-rockets.io-library.crt</pre><pre>acme-rockets.io-library</pre><p>Let’s confirm our signing key and certificate in the Notation CLI configuration.</p><pre>$ cat /Users/&lt;USER&gt;/Library/Application\ Support/notation/config.json</pre><pre>{<br>    &quot;verificationCerts&quot;: {<br>        &quot;certs&quot;: [<br>            {<br>                &quot;name&quot;: &quot;acme-rockets.io-library&quot;,<br>                &quot;path&quot;: &quot;/Users/&lt;USER&gt;/Library/Application Support/notation/certificate/acme-rockets.io-library.crt&quot;<br>            }<br>        ]<br>    },<br>    &quot;signingKeys&quot;: {<br>        &quot;default&quot;: &quot;acme-rockets.io-library&quot;,<br>        &quot;keys&quot;: [<br>            {<br>                &quot;name&quot;: &quot;acme-rockets.io-library&quot;,<br>                &quot;keyPath&quot;: &quot;/Users/&lt;USER&gt;/Library/Application Support/notation/key/acme-rockets.io-library.key&quot;,<br>                &quot;certPath&quot;: &quot;/Users/&lt;USER&gt;/Library/Application Support/notation/certificate/acme-rockets.io-library.crt&quot;<br>            }<br>        ]<br>    },<br>    &quot;insecureRegistries&quot;: []<br>}</pre><p>Now we are ready to add an additional signature to the container image using the acme-rockets key that we just created.</p><pre>$ notation sign $IMAGE</pre><pre>sha256:a0fc570a245b09ed752c42d600ee3bb5b4f77bbd70d88...</pre><p>Now let’s verify the signature.</p><pre>$ notation verify $IMAGE </pre><pre>sha256:a0fc570a245b09ed752c42d600ee3bb5b4f77bbd70d...</pre><p>Finally we can confirm that the container image does indeed have two signatures associated with it.</p><pre>$ oras discover -o tree \<br>  -u $NOTATION_USERNAME -p $NOTATION_PASSWORD $IMAGE</pre><pre>wabbitnetworks.azurecr-test.io/lachie/net-monitor:v1<br>└── application/vnd.cncf.notary.v2.signature<br>    ├── sha256:db09eb93b235fd5135feff3cae49e48955e3d...<br>    └── sha256:d12da8f8c7c31177805018952cc99e9e0813f...</pre><p>How cool is that! Adding multiple signatures enables you to verify those images using specific certificates.</p><h3>Adding and signing additional supply artifacts</h3><p>Another use case I would like to demonstrate is how to add and sign additional supply chain artifacts and associate them with a container image.</p><p>Keeping the importance of container supply chain security in mind we may want to add a signed SBOM (that we can verify) along with image scan results for example. Let’s walk through doing that.</p><p>We are going to generate an example SBOM and push that to the container registry.</p><pre>echo &#39;{&quot;version&quot;: &quot;0.0.0.0&quot;, &quot;artifact&quot;: &quot;&#39;${IMAGE}&#39;&quot;, &quot;contents&quot;: &quot;good&quot;}&#39; &gt; sbom.json</pre><pre>oras push $REPO \<br>  --artifact-type &#39;sbom/example&#39; \<br>  --subject $IMAGE \<br>  -u $NOTATION_USERNAME -p $NOTATION_PASSWORD \<br>  ./sbom.json:application/json</pre><pre>Uploading 2a1ee8cf78a2 sbom.json<br>Pushed wabbitnetworks.azurecr-test.io/lachie/net-monitor<br>Digest: sha256:40eb5d4598166a735ca99f14a6f81456c284...</pre><p>Now we can sign the SBOM which allows us to again verify that signature against a configured trusted source. To do that we need the digest of the SBOM (this could be made easier with an SBOM tool that discovers SBOMs associated with a container image) that we just pushed from the registry. Once we have that, we can sign it.</p><pre>$ SBOM_DIGEST=$(oras discover -o json \<br>                --artifact-type sbom/example \<br>                -u $NOTATION_USERNAME -p $NOTATION_PASSWORD \<br>                $IMAGE | jq -r &quot;.references[0].digest&quot;)</pre><pre>$ notation sign $REPO@$SBOM_DIGEST</pre><pre>sha256:40eb5d4598166a735ca99f14a6f81...</pre><p>Now we can verify the graph of resources associated with the container image which should now include not only two signatures, but also an SBOM with an associated signature.</p><pre>$ oras discover -o tree \<br>  -u $NOTATION_USERNAME -p $NOTATION_PASSWORD $IMAGE</pre><pre>wabbitnetworks.azurecr-test.io/lachie/net-monitor:v1<br>├── application/vnd.cncf.notary.v2.signature<br>│   ├── sha256:db09eb93b235fd51...<br>│   └── sha256:d12da8f8c7c31177...<br>└── sbom/example<br>    └── sha256:40eb5d4598166a735...<br>        └── application/vnd.cncf.notary.v2.signature<br>            └── sha256:8c0192b56...</pre><p>I cannot stress how important it is to be able to associate and discover the supply chain artifacts associated with a container image.</p><p>Now we are going to scan the container image using Snyk and again sign and store the scan results and signature in the container registry associated with that container image.</p><pre>$ docker scan --json $IMAGE &gt; scan-results.json</pre><pre>$ cat scan-results.json | jq</pre><pre>{<br>  &quot;vulnerabilities&quot;: [],<br>  &quot;ok&quot;: true,<br>  &quot;dependencyCount&quot;: 14,<br>  &quot;policy&quot;: &quot;# Snyk (<a href="https://snyk.io/">https://snyk.io</a>) policy file, ...,<br>  &quot;isPrivate&quot;: true,<br>  &quot;licensesPolicy&quot;: null,<br>  &quot;packageManager&quot;: &quot;apk&quot;,<br>  &quot;ignoreSettings&quot;: null,<br>  &quot;docker&quot;: {<br>    &quot;baseImage&quot;: &quot;alpine:3.14.2&quot;,<br>    &quot;baseImageRemediation&quot;: {<br>      &quot;code&quot;: &quot;NO_REMEDIATION_AVAILABLE&quot;,<br>      &quot;advice&quot;: [<br>        {<br>          ...<br>        }<br>      ]<br>    }<br>  },<br>  &quot;summary&quot;: &quot;No known vulnerabilities&quot;,<br>  &quot;filesystemPolicy&quot;: false,<br>  &quot;uniqueCount&quot;: 0,<br>  &quot;projectName&quot;: &quot;docker-image|wabbitnetworks.azurecr-test.io/lachie/net-monitor&quot;,<br>  &quot;platform&quot;: &quot;linux/amd64&quot;,<br>  &quot;path&quot;: &quot;wabbitnetworks.azurecr-test.io/lachie/net-monitor:v1/lachie/net-monitor&quot;<br>}</pre><p>Now we can push the scan results to the container registry.</p><pre>$ oras push $REPO \<br>  --artifact-type application/vnd.org.snyk.results.v0 \<br>  --subject $IMAGE \<br>  -u $NOTATION_USERNAME -p $NOTATION_PASSWORD \<br>  scan-results.json:application/json</pre><pre>Pushed wabbitnetworks.azurecr-test.io/lachie/net-monitor<br>Digest: sha256:84f0a6d3c75ea30b17cd8f269f1b153b...</pre><p>We will sign the scan results and store the signature in the container registry associated with the container image.</p><pre>$ SCAN_DIGEST=$(oras discover -o json \<br>               --artifact-type application/vnd.org.snyk.results.v0 \<br>               -u $NOTATION_USERNAME -p $NOTATION_PASSWORD \<br>               $IMAGE | jq -r &quot;.references[0].digest&quot;)</pre><pre>$ notation sign $REPO@$SCAN_DIGEST</pre><pre>sha256:84f0a6d3c75ea30b17cd8f269f1b153b4a736d48df...</pre><p>Finally, let’s confirm that we see the complete graph of supply chain artifacts associated with out container image.</p><pre>$ oras discover -o tree -u $NOTATION_USERNAME -p $NOTATION_PASSWORD $IMAGE</pre><pre>wabbitnetworks.azurecr-test.io/lachie/net-monitor:v1<br>├── application/vnd.cncf.notary.v2.signature<br>│   ├── sha256:db09eb93b235fd5135feff3cae49e489...<br>│   └── sha256:d12da8f8c7c31177805018952cc99e9e...<br>├── sbom/example<br>│   └── sha256:40eb5d4598166a735ca99f14a6f81456...<br>│       └── application/vnd.cncf.notary.v2.signature<br>│           └── sha256:8c0192b567004fa7461d33f7...<br>└── application/vnd.org.snyk.results.v0<br>    └── sha256:84f0a6d3c75ea30b17cd8f269f1b153b...<br>        └── application/vnd.cncf.notary.v2.signature<br>            └── sha256:53ee353f0be08e8edba731cc...</pre><h3>Summary</h3><p>It’s still early days for the Notary v2 project and I’m really excited to see the progress. The additional work that’s happening in the ORAS artifacts spec is also really promising when used in context of container supply chain security.</p><p>If you’re interested in learning more of have any questions feel free to reach out to me on Twitter or in the Notary community. Also — <a href="https://twitter.com/SteveLasker">Steve Lasker</a> has a recorded version of the same <a href="https://youtu.be/9zRMqtr0nWQ">demo</a> if you would like to see it in action.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13dd425e95d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes hardening using Kubescape]]></title>
            <link>https://medium.com/@LachlanEvenson/kubernetes-hardening-using-kubescape-ab7f9df341cc?source=rss-5d4f384fa574------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab7f9df341cc</guid>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[cloud-native-security]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Lachlan Evenson]]></dc:creator>
            <pubDate>Sat, 11 Sep 2021 04:51:14 GMT</pubDate>
            <atom:updated>2021-09-11T04:51:14.446Z</atom:updated>
            <content:encoded><![CDATA[<p>A friend of mine recommended that I should take a look at <a href="https://github.com/armosec/kubescape">Kubescape</a> as we were chatting about Kubernetes cluster hardening. Kubescape is an open source tool that codifies the <a href="https://www.nsa.gov/News-Features/Feature-Stories/Article-View/Article/2716980/nsa-cisa-release-kubernetes-hardening-guidance/">Kubernetes hardening guidance by the NSA and CISA</a>. I will detail my journey of discovery using Kubescape in the hope that it helps the you achieve higher security baselines for your Kubernetes clusters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rrSUuOrVfoioxwH0nJc0Kg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@j0rt?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">🇻🇪 Jose G. Ortega Castro 🇲🇽</a> on <a href="https://unsplash.com/s/photos/escape?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Installation</h3><p>Kubescape is a binary that you download and execute. They have the install setup process defined <a href="https://github.com/armosec/kubescape#install">here</a> however I’m not a fan of curl to pipe commands and instead went to the <a href="https://github.com/armosec/kubescape/releases/tag/v1.0.71">releases</a> section and downloaded the appropriate binary for my platform and placed it in my path. From my shell I could then test that the installation of the binary was successful by running the following command.</p><pre>$ kubescape -h<br>Kubescape is a tool for testing Kubernetes security posture based on NSA specifications.</pre><pre>Usage:<br>  kubescape [command]</pre><pre>Available Commands:<br>  completion  generate the autocompletion script for the specified shell<br>  download    Download framework controls<br>  help        Help about any command<br>  scan        Scan the current running cluster or yaml files</pre><pre>Flags:<br>  -h, --help   help for kubescape</pre><pre>Use &quot;kubescape [command] --help&quot; for more information about a command.</pre><h3>Running Kubescape</h3><p>There are two main ways to run Kubescape. You can either perform a scan of a running Kubernetes cluster OR scan the location of Kubernetes resource manifests. The output of the tool is pass/fail/warning guidance on whether or not your Kubernetes resources are compliant to the hardening guidance. Let’s try running Kubescape on a running cluster. You can do that by running the following command. This command assumes that you have a kubeconfig file in the default location. The following command performs a scan all the resources in all namespaces EXCEPT those that are excluded by the flag.</p><pre>$ kubescape scan framework nsa --exclude-namespaces kube-system,kube-public<br>ARMO security scanner starting<br>[progress] Downloading/Loading framework definitions<br>[success] Downloaded/Loaded framework<br>[progress] Accessing Kubernetes objects<br>W0910 21:29:44.139597   38285 warnings.go:70] batch/v1beta1 CronJob is deprecated in v1.21+, unavailable in v1.25+; use batch/v1 CronJob<br>[success] Accessed successfully to Kubernetes objects, let’s start!!!<br>[progress] Scanning cluster<br>◑ [success] Done scanning cluster<br>[control: Allow privilege escalation] passed 👍<br>Description: Attackers may gain access to a container and uplift its privilege to enable excessive capabilities.<br>Summary - Passed:8   Warning:0   Failed:0   Total:8</pre><pre>[control: Allowed hostPath] failed 😥<br>Description: Mounting host directory to the container can be abused to get access to sensitive data and gain persistence on the host machine.<br>   Namespace security-profiles-operator<br>      DaemonSet - spod</pre><pre>...</pre><p>From the output above you can see the scan is started and then you can see the output of each individual test that is run. For each test that’s run the output provides details of the resources that aren’t compliant to that specific policy. I have intentionally trimmed the output above because it’s quite long. I will dig into some individual sections below. Let’s take a look at the scan summary which is at the end of the scan output. You can see all the tests that have been run and the outcomes of each test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RfPVZqYbFiCB59u-hspQZg.png" /></figure><p>Let’s also take a look at the output from a specific test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6XUQGJCeA3VckG3IdpKQ2A.png" /></figure><p>You can see the for this test name Automatic mapping of service account that 12 resources failed. You can also the names of the resources that aren’t compliant. The summary of the same output is also present in the summary table above.</p><p>You can also run Kubescape against Kubernetes manifests which is a great way to stop violations before the resources are deployed to a Kubernetes cluster. The output is identical as scanning a running Kubernetes cluster as seen above. Here is an example command:</p><pre>$ kubescape scan framework nsa nginx.yaml</pre><p>You can also run it against a directory, URL, or wildcard filenames.</p><h3>Summary</h3><p>Kubescape is an easy way to determine if Kubernetes resources meet the guidelines provided in the NSA and CISA Kubernetes hardening guide. Using tools like this makes it easy to improve the overall security posture of the workloads running on your Kubernetes clusters and I hope to see many new frameworks being integrated into tools like Kubescape.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab7f9df341cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managing Kubernetes seccomp profiles with security profiles operator]]></title>
            <link>https://medium.com/@LachlanEvenson/managing-kubernetes-seccomp-profiles-with-security-profiles-operator-c768cff58b0?source=rss-5d4f384fa574------2</link>
            <guid isPermaLink="false">https://medium.com/p/c768cff58b0</guid>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[seccomp]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Lachlan Evenson]]></dc:creator>
            <pubDate>Fri, 27 Aug 2021 05:02:41 GMT</pubDate>
            <atom:updated>2021-08-27T05:02:41.705Z</atom:updated>
            <content:encoded><![CDATA[<p>In my last <a href="https://medium.com/@LachlanEvenson/how-to-enable-kubernetes-container-runtimedefault-seccomp-profile-for-all-workloads-6795624fcbcc">blog</a>, we learned about setting the RuntimeDefault flag in Kubernetes which configures all Pods to use a specific seccomp profile. While this is a great addition to improve your Kubernetes security posture, the runtime default seccomp profile might expose more syscalls than your application needs. In addition, the creation and management of seccomp profiles is cumbersome and error prone for cluster administrators. This is problem space is what the <a href="https://github.com/kubernetes-sigs/security-profiles-operator">security profile operator</a> sets out to solve. In this blog we’ll cover the features of the security profile operator and how to use it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B0t6pcqamnaIbzRAkBUyuQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@scienceinhd?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Science in HD</a> on <a href="https://unsplash.com/s/photos/operator?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Security Profile Operator features</h3><p>The security profile operator ships with the following features to manage seccomp profiles:</p><ul><li>Seccomp profile CRD</li><li>Profile binding CRD to bind seccomp profiles to Pods</li><li>Profile recording CRD to create seccomp profiles from running Pods</li><li>Seccomp profile synchronization and node support validation</li><li>Metrics</li><li>Log enricher</li></ul><h3>Installation</h3><p>We will be loosely following the <a href="https://github.com/kubernetes-sigs/security-profiles-operator/blob/master/installation-usage.md">installation instructions</a> from the project repository on GitHub. For best experience, I recommend using a Kubernetes cluster version of v1.19 or higher. Let’s assume you have a Kubernetes cluster ready to test out the security profile operator. <em>Standard Disclaimer: Don’t test in PROD.</em></p><p>First you will need to install cert-manager as a dependency.</p><pre>$ kubectl apply -f <a href="https://github.com/jetstack/cert-manager/releases/download/v1.4.2/cert-manager.yaml">https://github.com/jetstack/cert-manager/releases/download/v1.4.2/cert-manager.yaml</a><br>customresourcedefinition.apiextensions.k8s.io/certificaterequests.cert-manager.io created<br>customresourcedefinition.apiextensions.k8s.io/certificates.cert-manager.io created<br>customresourcedefinition.apiextensions.k8s.io/challenges.acme.cert-manager.io created<br>customresourcedefinition.apiextensions.k8s.io/clusterissuers.cert-manager.io created<br>customresourcedefinition.apiextensions.k8s.io/issuers.cert-manager.io created<br>customresourcedefinition.apiextensions.k8s.io/orders.acme.cert-manager.io created<br>namespace/cert-manager created<br>serviceaccount/cert-manager-cainjector created<br>serviceaccount/cert-manager created<br>serviceaccount/cert-manager-webhook created<br>clusterrole.rbac.authorization.k8s.io/cert-manager-cainjector created<br>clusterrole.rbac.authorization.k8s.io/cert-manager-controller-issuers created<br>clusterrole.rbac.authorization.k8s.io/cert-manager-controller-clusterissuers created<br>clusterrole.rbac.authorization.k8s.io/cert-manager-controller-certificates created<br>clusterrole.rbac.authorization.k8s.io/cert-manager-controller-orders created<br>clusterrole.rbac.authorization.k8s.io/cert-manager-controller-challenges created<br>clusterrole.rbac.authorization.k8s.io/cert-manager-controller-ingress-shim created<br>clusterrole.rbac.authorization.k8s.io/cert-manager-view created<br>clusterrole.rbac.authorization.k8s.io/cert-manager-edit created<br>clusterrole.rbac.authorization.k8s.io/cert-manager-controller-approve:cert-manager-io created<br>clusterrole.rbac.authorization.k8s.io/cert-manager-controller-certificatesigningrequests created<br>clusterrole.rbac.authorization.k8s.io/cert-manager-webhook:subjectaccessreviews created<br>clusterrolebinding.rbac.authorization.k8s.io/cert-manager-cainjector created<br>clusterrolebinding.rbac.authorization.k8s.io/cert-manager-controller-issuers created<br>clusterrolebinding.rbac.authorization.k8s.io/cert-manager-controller-clusterissuers created<br>clusterrolebinding.rbac.authorization.k8s.io/cert-manager-controller-certificates created<br>clusterrolebinding.rbac.authorization.k8s.io/cert-manager-controller-orders created<br>clusterrolebinding.rbac.authorization.k8s.io/cert-manager-controller-challenges created<br>clusterrolebinding.rbac.authorization.k8s.io/cert-manager-controller-ingress-shim created<br>clusterrolebinding.rbac.authorization.k8s.io/cert-manager-controller-approve:cert-manager-io created<br>clusterrolebinding.rbac.authorization.k8s.io/cert-manager-controller-certificatesigningrequests created<br>clusterrolebinding.rbac.authorization.k8s.io/cert-manager-webhook:subjectaccessreviews created<br>role.rbac.authorization.k8s.io/cert-manager-cainjector:leaderelection created<br>role.rbac.authorization.k8s.io/cert-manager:leaderelection created<br>role.rbac.authorization.k8s.io/cert-manager-webhook:dynamic-serving created<br>rolebinding.rbac.authorization.k8s.io/cert-manager-cainjector:leaderelection created<br>rolebinding.rbac.authorization.k8s.io/cert-manager:leaderelection created<br>rolebinding.rbac.authorization.k8s.io/cert-manager-webhook:dynamic-serving created<br>service/cert-manager created<br>service/cert-manager-webhook created<br>deployment.apps/cert-manager-cainjector created<br>deployment.apps/cert-manager created<br>deployment.apps/cert-manager-webhook created<br>mutatingwebhookconfiguration.admissionregistration.k8s.io/cert-manager-webhook created<br>validatingwebhookconfiguration.admissionregistration.k8s.io/cert-manager-webhook created</pre><pre>$ kubectl --namespace cert-manager wait --for condition=ready pod -l app.kubernetes.io/instance=cert-manager<br>pod/cert-manager-5c9c77dbd4-5rjq4 condition met<br>pod/cert-manager-cainjector-6c8595ff6c-tfwqt condition met<br>pod/cert-manager-webhook-7c9c4c5cdb-ffm6c condition met</pre><p>Next, install the service profile operator</p><pre>$ kubectl apply -f <a href="https://raw.githubusercontent.com/kubernetes-sigs/security-profiles-operator/master/deploy/operator.yaml">https://raw.githubusercontent.com/kubernetes-sigs/security-profiles-operator/master/deploy/operator.yaml</a>customresourcedefinition.apiextensions.k8s.io/profilebindings.security-profiles-operator.x-k8s.io created<br>customresourcedefinition.apiextensions.k8s.io/profilerecordings.security-profiles-operator.x-k8s.io created<br>customresourcedefinition.apiextensions.k8s.io/seccompprofiles.security-profiles-operator.x-k8s.io created<br>customresourcedefinition.apiextensions.k8s.io/securityprofilenodestatuses.security-profiles-operator.x-k8s.io created<br>customresourcedefinition.apiextensions.k8s.io/securityprofilesoperatordaemons.security-profiles-operator.x-k8s.io created<br>customresourcedefinition.apiextensions.k8s.io/selinuxprofiles.security-profiles-operator.x-k8s.io created<br>namespace/security-profiles-operator created<br>serviceaccount/security-profiles-operator created<br>serviceaccount/spod created<br>serviceaccount/spo-webhook created<br>clusterrole.rbac.authorization.k8s.io/security-profiles-operator created<br>role.rbac.authorization.k8s.io/security-profiles-operator created<br>clusterrole.rbac.authorization.k8s.io/spod created<br>role.rbac.authorization.k8s.io/spod created<br>clusterrole.rbac.authorization.k8s.io/spo-webhook created<br>role.rbac.authorization.k8s.io/spo-webhook created<br>clusterrolebinding.rbac.authorization.k8s.io/security-profiles-operator created<br>rolebinding.rbac.authorization.k8s.io/security-profiles-operator created<br>clusterrolebinding.rbac.authorization.k8s.io/spod created<br>rolebinding.rbac.authorization.k8s.io/spod created<br>clusterrolebinding.rbac.authorization.k8s.io/spo-webhook created<br>rolebinding.rbac.authorization.k8s.io/spo-webhook created<br>Warning: spec.template.metadata.annotations[seccomp.security.alpha.kubernetes.io/pod]: deprecated since v1.19; use the &quot;seccompProfile&quot; field instead<br>deployment.apps/security-profiles-operator created<br>deployment.apps/security-profiles-operator-webhook created<br>mutatingwebhookconfiguration.admissionregistration.k8s.io/spo-mutating-webhook-configuration created<br>issuer.cert-manager.io/selfsigned-issuer created<br>certificate.cert-manager.io/webhook-cert created<br>certificate.cert-manager.io/metrics-cert created<br>service/webhook-service created<br>service/metrics created<br>clusterrole.rbac.authorization.k8s.io/spo-metrics-client created<br>clusterrolebinding.rbac.authorization.k8s.io/spo-metrics-client created<br>secret/metrics-token created<br>configmap/security-profiles-operator-profile created</pre><h3>Creating a seccomp profile</h3><p>The SeccompProfile CRD is used to store seccomp profiles (obviously!). The profile below sets only a default action of SCMP_ACT_LOG. This profile is should only be used as an example as it doesn’t explicitly block any syscalls (it only logs syscalls). Add the resource below to a file called profile1.yaml.</p><pre>apiVersion: security-profiles-operator.x-k8s.io/v1alpha1<br>kind: SeccompProfile<br>metadata:<br>  namespace: default<br>  name: profile1<br>spec:<br>  defaultAction: SCMP_ACT_LOG</pre><p>Create the seccomp profile using the following command:</p><pre>$ kubectl apply -f profile1.yaml<br>seccompprofile.security-profiles-operator.x-k8s.io/profile1 created</pre><p>Now that the profile has been created. Let’s confirm that it has been synchronized to a node’s filesystem. The profile can be found under the following path /var/lib/kubelet/seccomp/operator/&lt;namespace&gt;/&lt;profile name&gt;.json.</p><pre>$ ssh k8s-pool1-18290975-vmss000000 sudo cat /var/lib/kubelet/seccomp/operator/default/profile1.json<br>{&quot;defaultAction&quot;:&quot;SCMP_ACT_LOG&quot;}</pre><p>We can also check the installation status using kubectl</p><pre>$ kubectl get seccompprofile profile1 --output wide<br>NAME       STATUS      AGE     LOCALHOSTPROFILE<br>profile1   Installed   7m21s   operator/default/profile1.json</pre><h3>Using a seccomp profile</h3><p>Now that we’ve created the seccomp profile and confirmed that the operator has synchronized it to the filesystem on all nodes, we can configure a Pod to use the profile as follows:</p><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: nginx<br>spec:<br>  securityContext:<br>    seccompProfile:<br>      type: Localhost<br>      localhostProfile: operator/default/profile1.json<br>  containers:<br>    - name: nginx<br>      image: nginx</pre><h3>Profile inheritance using base profiles</h3><p>In addition to creating seccomp profiles you can also combine profiles using one as a base to create a new custom profile. In the example below you can see the baseProfileName of base-profile1 which is just another resource of kind SeccompProfile.</p><pre>apiVersion: security-profiles-operator.x-k8s.io/v1alpha1<br>kind: SeccompProfile<br>metadata:<br>  namespace: default<br>  name: profile1<br>spec:<br>  defaultAction: SCMP_ACT_ERRNO<br>  baseProfileName: base-profile1<br>  syscalls:<br>    - action: SCMP_ACT_ALLOW<br>      names:<br>        - mkdir</pre><h3>Using profile bindings</h3><p>In the case that you don’t want to modify the Pod spec directly to include the seccompProfile you can use the ProfileBinding resource to bind a seccomp profile to a specific container. The following is an example ProfileBinding resource that will apply profile1 to all containers using an image of nginx:1.21.1</p><pre>apiVersion: security-profiles-operator.x-k8s.io/v1alpha1<br>kind: ProfileBinding<br>metadata:<br>  name: nginx-binding<br>spec:<br>  profileRef:<br>    kind: SeccompProfile<br>    name: profile1<br>  image: nginx:1.21.1</pre><p>Let’s save the previous profile binding to a file called nginx-binding.yaml and run the following command:</p><pre>$ kubectl apply -f nginx-binding.yaml<br>profilebinding.security-profiles-operator.x-k8s.io/nginx-binding created</pre><p>Create a Pod with a container image of nginx:1.21.1 which will match the binding we created above.</p><pre>$ cat &lt;&lt;EOF kubectl create -f -<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: nginx<br>spec:<br>  containers:<br>    - name: nginx<br>      image: nginx:1.21.1<br>EOF<br>pod/nginx created</pre><p>Confirm that the correct seccomp profile was applied using the following command:</p><pre>$ kubectl get pod nginx -o jsonpath=&#39;{.spec.containers[*].securityContext.seccompProfile}&#39;<br>{&quot;localhostProfile&quot;:&quot;operator/default/profile1.json&quot;,&quot;type&quot;:&quot;Localhost&quot;}</pre><p>The profile binding resource uses a mutating admission webhook to add the seccomp profile to a Pod. This means that it can only be applied when a Pod is created and cannot be added to a running Pod.</p><h3>Recording Profiles</h3><p>Unfortunately I don’t have a cluster with CRI-O installed on hand so I’m going to go through how profile recording works without providing and in depth examples. You can always learn more via the official project <a href="https://github.com/kubernetes-sigs/security-profiles-operator/blob/master/installation-usage.md#record-profiles-from-workloads-with-profilerecordings">documentation</a>. The following is an example ProfileRecording resource.</p><pre>apiVersion: security-profiles-operator.x-k8s.io/v1alpha1<br>kind: ProfileRecording<br>metadata:<br>  name: recording<br>spec:<br>  kind: SeccompProfile<br>  recorder: hook<br>  podSelector:<br>    matchLabels:<br>      app: nginx</pre><p>Once created, any Pod that is created that matches the label app: nginx will start being recorded and once that pod is deleted a seccomp profile resource (per Pod) will be create and then can be used. This is one of the coolest parts of the security profile operator and I encourage you to check it out.</p><h3>Metrics and Log enrichment</h3><p>The operator exposes a metrics endpoint which can be scraped by Prometheus to provide more detailed insight into policy installation status. You can see a list of metrics in the <a href="https://github.com/kubernetes-sigs/security-profiles-operator/blob/master/installation-usage.md#using-metrics">official documentation</a>.</p><p>There is also a log enrichment feature that is off by default which adds additional Kubernetes metadata to system audit and logging facilities to assist with debugging.</p><h3>Wrap</h3><p>After investing time in understanding how seccomp profiles can be used to add to your overall security posture you quickly realize that you need a way to a manage and distribute seccomp policies so that they can be uniformly applied. The security profile operator is a promising project that tackles the most challenging aspects of seccomp profile creation and management. I encourage you to check it out. A big thanks to the maintainers of this project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c768cff58b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to enable Kubernetes container RuntimeDefault seccomp profile for all workloads]]></title>
            <link>https://medium.com/@LachlanEvenson/how-to-enable-kubernetes-container-runtimedefault-seccomp-profile-for-all-workloads-6795624fcbcc?source=rss-5d4f384fa574------2</link>
            <guid isPermaLink="false">https://medium.com/p/6795624fcbcc</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[seccomp]]></category>
            <category><![CDATA[cloud-native]]></category>
            <dc:creator><![CDATA[Lachlan Evenson]]></dc:creator>
            <pubDate>Sun, 22 Aug 2021 05:34:15 GMT</pubDate>
            <atom:updated>2021-08-26T22:33:56.251Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PqdhwlVN4yzqSoPzS6sOyQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@mroz?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Filip Mroz</a> on <a href="https://unsplash.com/s/photos/running-fence?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Kubernetes v1.22 shipped with a new feature in alpha that provides a way to use the container <a href="https://kubernetes.io/docs/tutorials/clusters/seccomp/#enable-the-use-of-runtimedefault-as-the-default-seccomp-profile-for-all-workloads">RuntimeDefault</a> as the default seccomp profile for all workloads. At this point you might be asking, <strong>“What are RuntimeDefaults and why should I care?”</strong> By default, when Kubernetes makes a call to the container runtime to create a container it provides a seccomp profile of Unconfined. This means that seccomp filtering is disabled. This is the default Kubernetes behavior as it ensures maximum application compatibility at the risk of leaving a larger surface area of the Linux kernel open to exploit by a compromised container.</p><p>Before we take a deeper look, I would like to say thank you to <a href="https://twitter.com/mauilion">Duffie Cooley</a> for taking the time to educate me on this topic. I was inspired to look deeper after watching “<a href="https://www.twitch.tv/videos/1120357279">This Week in Cloud Native</a>” which Duffie hosts. You should check it out.</p><p><em>NOTE: Kubernetes features that are in alpha aren’t typically available for use by managed Kubernetes services like AKS, EKS, GKE for stability reasons. Please check your providers documentation</em></p><h3>Seccomp profile what?</h3><p><a href="https://lwn.net/Articles/656307/">Seccomp</a> (Secure Computing) is a feature in the Linux kernel that allows a userspace program to create syscall filters. In the context of containers, these syscall filters are collated into seccomp profiles that can be used to restrict which syscalls and arguments are permitted. Applying seccomp profiles to containers reduces the chance that a Linux kernel vulnerability will be exploited.</p><p>All container runtimes ship with a default seccomp profile (or RuntimeDefault) that is applied to containers. These default seccomp profiles aim to strike the balance between a secure set of defaults without sacrificing the functionality of the workload. The problem arrises when these container runtimes are integrated with Kubernetes, Kubernetes will explicitly set the seccomp profile to Unconfined which disables seccomp filtering.</p><p>Docker desktop ships with a <a href="https://github.com/moby/moby/blob/master/profiles/seccomp/default.json">default seccomp profile </a>that is used whenever you run a container directly using the Docker CLI. The default profile disables approximately 44 system calls of the 300+ currently availble. At this point most other well known container runtimes also ship with a default seccomp profile and they are very similar if not the same as the one Docker uses (I’ve only done some light research). The <a href="https://docs.docker.com/engine/security/seccomp/">Docker documentation</a> on seccomp profiles is great and I recommend the read.</p><p>We can easily test that the default seccomp profile is being applied on Docker desktop by running the following commands.</p><pre>$ docker run -it bash bash<br>bash-5.1# apk add curl<br>fetch <a href="http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz">http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz</a><br>fetch <a href="http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz">http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz</a><br>(1/4) Installing ca-certificates (20191127-r4)<br>(2/4) Installing nghttp2-libs (1.41.0-r0)<br>(3/4) Installing libcurl (7.78.0-r0)<br>(4/4) Installing curl (7.78.0-r0)<br>Executing busybox-1.31.1-r20.trigger<br>Executing ca-certificates-20191127-r4.trigger<br>OK: 8 MiB in 21 packages<br>  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current<br>                                 Dload  Upload   Total   Spent    Left  Speed<br>100   237  100   237    0     0   1022      0 --:--:-- --:--:-- --:--:--  1025<br>100 5936k  100 5936k    0     0  4069k      0  0:00:01  0:00:01 --:--:-- 6415k<br>bash-5.1# curl -LO k8s.work/amicontained<br>bash-5.1# chmod +x amicontained<br>bash-5.1#./amicontainedContainer<br>Runtime: docker<br>Has Namespaces:<br> pid: true<br> user: false<br>AppArmor Profile: unconfined<br>Capabilities:<br> BOUNDING -&gt; chown dac_override fowner fsetid kill setgid setuid setpcap net_bind_service net_raw sys_chroot mknod audit_write setfcap<br>Seccomp: filtering<br>Blocked Syscalls (60):<br> MSGRCV SYSLOG SETSID USELIB USTAT SYSFS VHANGUP PIVOT_ROOT _SYSCTL ACCT SETTIMEOFDAY MOUNT UMOUNT2 SWAPON SWAPOFF REBOOT SETHOSTNAME SETDOMAINNAME IOPL IOPERM CREATE_MODULE INIT_MODULE DELETE_MODULE GET_KERNEL_SYMS QUERY_MODULE QUOTACTL NFSSERVCTL GETPMSG PUTPMSG AFS_SYSCALL TUXCALL SECURITY LOOKUP_DCOOKIE CLOCK_SETTIME VSERVER MBIND SET_MEMPOLICY GET_MEMPOLICY KEXEC_LOAD ADD_KEY REQUEST_KEY KEYCTL MIGRATE_PAGES UNSHARE MOVE_PAGES PERF_EVENT_OPEN FANOTIFY_INIT NAME_TO_HANDLE_AT OPEN_BY_HANDLE_AT SETNS PROCESS_VM_READV PROCESS_VM_WRITEV KCMP FINIT_MODULE KEXEC_FILE_LOAD BPF USERFAULTFD PKEY_MPROTECT PKEY_ALLOC PKEY_FREE<br>Looking for Docker.sock</pre><p>In the output above you can see the following which states that seccomp filtering is enabled at that 60 syscalls are being blocked:</p><pre>Seccomp: filtering<br>Blocked Syscalls (60):</pre><p>Here are the commands that I used to run the test, you can use them to test yourself. Massive thanks to <a href="https://twitter.com/mauilion">Duffie</a> from providing me with these commands.</p><pre>docker run -it bash bash<br>apk add curl<br>curl -LO k8s.work/amicontained<br>chmod +x amicontained<br>./amicontained</pre><h3>Configuring Kubernetes RuntimeDefault</h3><p>Now that we know all about seccomp profiles and RuntimeDefault let’s take a look at how we can configure Kubernetes to use the RuntimeDefault seccomp profile rather that using Unconfined. First, I would like to demonstrate how a default Kubernetes cluster without this new feature enabled operates. We are going to prove that Kubernetes sets the seccomp profile to Unconfined.</p><p>We will need a Kubernetes cluster to run the tests. I use <a href="https://kind.sigs.k8s.io/">Kind</a> to quickly and easily spin up a Kubernetes cluster locally. Create the following config file called kind-config.yaml.</p><pre>kind: Cluster<br>apiVersion: kind.x-k8s.io/v1alpha4<br>nodes:<br>- role: control-plane<br>- role: worker</pre><p>Create a Kubernetes cluster using Kind.</p><pre>$ kind create cluster --image=kindest/node:v1.22.0@sha256:b8bda84bb3a190e6e028b1760d277454a72267a5454b57db34437c34a588d047 --config kind-config.yaml<br>Creating cluster &quot;kind&quot; ...<br> ✓ Ensuring node image (kindest/node:v1.22.0) 🖼<br> ✓ Preparing nodes 📦 📦<br> ✓ Writing configuration 📜<br> ✓ Starting control-plane 🕹️<br> ✓ Installing CNI 🔌<br> ✓ Installing StorageClass 💾<br> ✓ Joining worker nodes 🚜<br>Set kubectl context to &quot;kind-kind&quot;<br>You can now use your cluster with:</pre><pre>kubectl cluster-info --context kind-kind</pre><pre>Thanks for using kind!</pre><p>Let’s again run the same test as we did in the previous section but this time on the Kubernetes cluster.</p><pre>$ kubectl run -it bash --image=bash --restart=Never bash</pre><pre>If you don&#39;t see a command prompt, try pressing enter.</pre><pre>bash-5.1# apk add curl<br>fetch <a href="http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz">http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz</a><br>fetch <a href="http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz">http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz</a><br>(1/4) Installing ca-certificates (20191127-r4)<br>(2/4) Installing nghttp2-libs (1.41.0-r0)<br>(3/4) Installing libcurl (7.78.0-r0)<br>(4/4) Installing curl (7.78.0-r0)<br>Executing busybox-1.31.1-r20.trigger<br>Executing ca-certificates-20191127-r4.trigger<br>OK: 8 MiB in 21 packages<br>bash-5.1# curl -LO k8s.work/amicontained<br>  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current<br>                                 Dload  Upload   Total   Spent    Left  Speed<br>100   237  100   237    0     0   1032      0 --:--:-- --:--:-- --:--:--  1034<br>100 5936k  100 5936k    0     0  4580k      0  0:00:01  0:00:01 --:--:-- 16.6M<br>bash-5.1# chmod +x amicontained<br>bash-5.1# ./amicontained<br>Container Runtime: docker<br>Has Namespaces:<br> pid: true<br> user: false<br>AppArmor Profile: unconfined<br>Capabilities:<br> BOUNDING -&gt; chown dac_override fowner fsetid kill setgid setuid setpcap net_bind_service net_raw sys_chroot mknod audit_write setfcap<br>Seccomp: disabled<br>Blocked Syscalls (21):<br> MSGRCV SYSLOG SETSID VHANGUP PIVOT_ROOT ACCT SETTIMEOFDAY SWAPON SWAPOFF REBOOT SETHOSTNAME SETDOMAINNAME INIT_MODULE DELETE_MODULE LOOKUP_DCOOKIE KEXEC_LOAD FANOTIFY_INIT OPEN_BY_HANDLE_AT FINIT_MODULE KEXEC_FILE_LOAD BPF<br>Looking for Docker.sock</pre><p>In the output above you can see that seccomp is disabled and that 21 syscalls are being blocked. In comparison with the output of the same test running on Docker on my dev machine using the Docker CLI, seccomp is filtering and 60 syscalls are being blocked. Now that we can see the baseline. Let’s create a cluster with and configure the new RuntimeDefault feature.</p><p>Delete the last Kind Kubernetes cluster using the following command:</p><pre>$ kind delete cluster<br>Deleting cluster &quot;kind&quot; ...</pre><p>Now let’s create a new config file called kind-runtimedefault-config.yaml with the following content. You may notice that we are setting the SeccompDefault feature gate to true which enables the new feature:</p><pre>kind: Cluster<br>apiVersion: kind.x-k8s.io/v1alpha4<br>featureGates:<br>  SeccompDefault: true<br>nodes:<br>- role: control-plane<br>  kubeadmConfigPatches:<br>  - |<br>    kind: InitConfiguration<br>    nodeRegistration:<br>      kubeletExtraArgs:<br>        seccomp-default: &quot;true&quot;<br>        feature-gates: &quot;SeccompDefault=true&quot;<br>- role: worker<br>  kubeadmConfigPatches:<br>  - |<br>    kind: JoinConfiguration<br>    nodeRegistration:<br>      kubeletExtraArgs:<br>        seccomp-default: &quot;true&quot;<br>        feature-gates: &quot;SeccompDefault=true&quot;</pre><p>Create a Kubernetes cluster using Kind and the config file you just created:</p><pre>$ kind create cluster --image=kindest/node:v1.22.0@sha256:b8bda84bb3a190e6e028b1760d277454a72267a5454b57db34437c34a588d047 --config ~/Downloads/kind-runtimedefault-config.yaml<br>Creating cluster &quot;kind&quot; ...<br> ✓ Ensuring node image (kindest/node:v1.22.0) 🖼<br> ✓ Preparing nodes 📦 📦<br> ✓ Writing configuration 📜<br> ✓ Starting control-plane 🕹️<br> ✓ Installing CNI 🔌<br> ✓ Installing StorageClass 💾<br> ✓ Joining worker nodes 🚜<br>Set kubectl context to &quot;kind-kind&quot;<br>You can now use your cluster with:</pre><pre>kubectl cluster-info --context kind-kind</pre><pre>Have a nice day! 👋</pre><p>Let’s again run the same test however we would expect the RuntimeDefault seccomp profile to be applied.</p><pre>$ kubectl run -it bash --image=bash --restart=Never bash<br>If you don&#39;t see a command prompt, try pressing enter.<br>bash-5.1# apk add curl<br>fetch <a href="http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz">http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz</a><br>fetch <a href="http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz">http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz</a></pre><pre>(1/4) Installing ca-certificates (20191127-r4)<br>(2/4) Installing nghttp2-libs (1.41.0-r0)<br>(3/4) Installing libcurl (7.78.0-r0)<br>(4/4) Installing curl (7.78.0-r0)<br>Executing busybox-1.31.1-r20.trigger<br>Executing ca-certificates-20191127-r4.trigger<br>OK: 8 MiB in 21 packages<br>bash-5.1#<br>bash-5.1# curl -LO k8s.work/amicontained<br>  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current<br>                                 Dload  Upload   Total   Spent    Left  Speed<br>100   237  100   237    0     0    916      0 --:--:-- --:--:-- --:--:--   915<br>100 5936k  100 5936k    0     0  4313k      0  0:00:01  0:00:01 --:--:-- 14.8M<br>bash-5.1# chmod +x amicontained<br>bash-5.1# ./amicontained<br>Container Runtime: docker<br>Has Namespaces:<br> pid: true<br> user: false<br>AppArmor Profile: unconfined<br>Capabilities:<br> BOUNDING -&gt; chown dac_override fowner fsetid kill setgid setuid setpcap net_bind_service net_raw sys_chroot mknod audit_write setfcap<br>Seccomp: filtering<br>Blocked Syscalls (61):<br> MSGRCV PTRACE SYSLOG SETSID USELIB USTAT SYSFS VHANGUP PIVOT_ROOT _SYSCTL ACCT SETTIMEOFDAY MOUNT UMOUNT2 SWAPON SWAPOFF REBOOT SETHOSTNAME SETDOMAINNAME IOPL IOPERM CREATE_MODULE INIT_MODULE DELETE_MODULE GET_KERNEL_SYMS QUERY_MODULE QUOTACTL NFSSERVCTL GETPMSG PUTPMSG AFS_SYSCALL TUXCALL SECURITY LOOKUP_DCOOKIE CLOCK_SETTIME VSERVER MBIND SET_MEMPOLICY GET_MEMPOLICY KEXEC_LOAD ADD_KEY REQUEST_KEY KEYCTL MIGRATE_PAGES UNSHARE MOVE_PAGES PERF_EVENT_OPEN FANOTIFY_INIT NAME_TO_HANDLE_AT OPEN_BY_HANDLE_AT SETNS PROCESS_VM_READV PROCESS_VM_WRITEV KCMP FINIT_MODULE KEXEC_FILE_LOAD BPF USERFAULTFD PKEY_MPROTECT PKEY_ALLOC PKEY_FREE<br>Looking for Docker.sock<br>bash-5.1#</pre><p>In the output above you can see that seccomp is filtering and that 61 syscalls are being blocked. This validates that the RuntimeDefault seccomp profile is being successfully applied.</p><h3>Rolling this out in production</h3><p>Now that you know how to configure this on a Kubernetes cluster you probable want to know how to roll it out. The <a href="https://kubernetes.io/docs/tutorials/clusters/seccomp/#enable-the-use-of-runtimedefault-as-the-default-seccomp-profile-for-all-workloads">Kubernetes documentation</a> recommends enabling this feature flag on a subset of nodes and test your workloads thoroughly before rolling it out to an entire Kubernetes cluster.</p><p><em>It’s also worth mentioning again that this feature is in alpha so it might be worth waiting for it to mature before enabling it in production.</em></p><p>The jury is out on whether or not we can make the syscall filter responses be more application friendly especially for new applications that use libraries that depend on newer syscalls that may not yet be in allowed by the RuntimeDefault seccomp profile. Currently the RuntimeDefault seccomp profile responds to the application with the equivalent of “You don’t have permission” or <strong>EPERM </strong>for blocked syscalls which might include newer syscalls that haven’t yet been allowed. The other suggestion is to respond with “function not implemented” or <strong>ENOSYS </strong>by default for blocked syscalls so that applications that use newer libraries call “fallback” to other syscalls. You can read more on this discussion in the following <a href="https://github.com/opencontainers/runc/issues/2151">GitHub issue</a>. Thanks to <a href="https://twitter.com/cpuguy83">Brian Goff</a> for educating me on the up to date happenings regarding seccomp profiles in container runtimes.</p><h3>Conclusion</h3><p>We covered a lot of ground in this blog starting with seccomp profiles and how they are used in the context of container runtimes. We then enabled a new feature that enables Kubernetes to use the RuntimeDefault seccomp profile. The question now is <strong>“How much does this matter?”</strong> and that’s something I will leave you to answer. Certainly, anything you can do to reduce the attack surface area on the Linux kernel from a container is an incremental improvement on the overall security posture of the Kubernetes cluster. Let me know what you think?</p><p>Finally, I will leave you with a great resource from Duffie. <a href="https://www.pulumi.com/resources/kubernetes-seccomp-profiles/">Kubernetes Seccomp Profiles: A Practical Guide</a> if you are looking for a more in depth look at seccomp profiles.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6795624fcbcc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mutating Kubernetes resources with Gatekeeper]]></title>
            <link>https://medium.com/@LachlanEvenson/mutating-kubernetes-resources-with-gatekeeper-3e5585d49ead?source=rss-5d4f384fa574------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e5585d49ead</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[policy]]></category>
            <dc:creator><![CDATA[Lachlan Evenson]]></dc:creator>
            <pubDate>Sat, 21 Aug 2021 07:15:51 GMT</pubDate>
            <atom:updated>2021-08-21T07:15:51.929Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*joEn-BTmfX2pVFt4h00WQA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@3dparadise?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Braňo</a> on <a href="https://unsplash.com/s/photos/dna?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><a href="https://open-policy-agent.github.io/gatekeeper/">Gatekeeper</a> is a Kubernetes policy controller that allows you to define policy to enforce which fields and values are permitted in Kubernetes resources. It operates as a <a href="https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/">Kubernetes admission controller</a> and utilizes <a href="https://www.openpolicyagent.org/">Open Policy Agent</a> as its policy engine. Up until recently, Gatekeeper could only validate Kubernetes resources. This meant it was on the user to update resources to be compliant with policy before they can be successfully created.</p><p>Gatekeeper has recently introduced the ability to <a href="https://open-policy-agent.github.io/gatekeeper/website/docs/mutation">mutate</a> resources. Mutation means that policy can change Kubernetes resources based on different criteria. A common example of a mutation policy might be changing privileged Pods to be unprivileged, another example might be setting the imagePullPolicy to Always for all Pods. Having the ability to mutate resources server-side on behalf of the user is a really easy way to enforce best practices, or apply standard labelling, or simply apply a baseline security policy to all resources.</p><p>In this blog we are going to cover how to use mutation in Gatekeeper by sharing several examples. <strong>DISCLAIMER: </strong>The mutation feature in Gatekeeper is still in <strong>ALPHA</strong> and shouldn’t be used in production until it becomes more mature.</p><h3>Installing Gatekeeper</h3><p>First, we are going to install Gatekeeper with the mutation feature enabled. Please don’t do this on a production Kubernetes cluster as this may cause disrupts to your workloads. I typically use <a href="https://kind.sigs.k8s.io/">Kind</a> to create local Kubernetes clusters to test on. Create a file called kind-config.yaml with the following content:</p><pre>kind: Cluster<br>apiVersion: kind.x-k8s.io/v1alpha4<br>featureGates:<br>nodes:<br>- role: control-plane<br>- role: worker</pre><p>Create a Kubernetes cluster using Kind with the following command:</p><pre>$ kind create cluster --image=kindest/node:v1.22.0@sha256:b8bda84bb3a190e6e028b1760d277454a72267a5454b57db34437c34a588d047 --config ~/Downloads/kind-config.yaml<br>Creating cluster &quot;kind&quot; ...<br> ✓ Ensuring node image (kindest/node:v1.22.0) 🖼<br> ✓ Preparing nodes 📦 📦<br> ✓ Writing configuration 📜<br> ✓ Starting control-plane 🕹️<br> ✓ Installing CNI 🔌<br> ✓ Installing StorageClass 💾<br> ✓ Joining worker nodes 🚜<br>Set kubectl context to &quot;kind-kind&quot;<br>You can now use your cluster with:</pre><pre>kubectl cluster-info --context kind-kind</pre><pre>Have a question, bug, or feature request? Let us know! <a href="https://kind.sigs.k8s.io/#community">https://kind.sigs.k8s.io/#community</a> 🙂</pre><p>Next, install Gatekeeper with the following command:</p><p><strong><em>NOTE</em></strong><em>: It’s not best practice to blindly install Kubernetes resources from a URL without taking the time to understand what’s being installed. I’m providing for ease of installation as to demonstrate mutation.</em></p><pre>$ kubectl apply -f <a href="https://raw.githubusercontent.com/open-policy-agent/gatekeeper/v3.5.1/deploy/experimental/gatekeeper-mutation.yaml">https://raw.githubusercontent.com/open-policy-agent/gatekeeper/v3.5.1/deploy/experimental/gatekeeper-mutation.yaml</a><br> namespace/gatekeeper-system created<br>customresourcedefinition.apiextensions.k8s.io/assign.mutations.gatekeeper.sh created<br>customresourcedefinition.apiextensions.k8s.io/assignmetadata.mutations.gatekeeper.sh created<br>resourcequota/gatekeeper-critical-pods created<br>customresourcedefinition.apiextensions.k8s.io/configs.config.gatekeeper.sh created<br>customresourcedefinition.apiextensions.k8s.io/constraintpodstatuses.status.gatekeeper.sh created<br>customresourcedefinition.apiextensions.k8s.io/constrainttemplatepodstatuses.status.gatekeeper.sh created<br>customresourcedefinition.apiextensions.k8s.io/constrainttemplates.templates.gatekeeper.sh created<br>mutatingwebhookconfiguration.admissionregistration.k8s.io/gatekeeper-mutating-webhook-configuration created<br>customresourcedefinition.apiextensions.k8s.io/mutatorpodstatuses.status.gatekeeper.sh created<br>serviceaccount/gatekeeper-admin created<br>Warning: policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+<br>podsecuritypolicy.policy/gatekeeper-admin created<br>role.rbac.authorization.k8s.io/gatekeeper-manager-role created<br>clusterrole.rbac.authorization.k8s.io/gatekeeper-manager-role created<br>rolebinding.rbac.authorization.k8s.io/gatekeeper-manager-rolebinding created<br>clusterrolebinding.rbac.authorization.k8s.io/gatekeeper-manager-rolebinding created<br>secret/gatekeeper-webhook-server-cert created<br>service/gatekeeper-webhook-service created<br>Warning: spec.template.metadata.annotations[container.seccomp.security.alpha.kubernetes.io/manager]: deprecated since v1.19; use the &quot;seccom<br>apiVersion: v1<br>pProfile&quot; field instead<br>deployment.apps/gatekeeper-audit created<br>deployment.apps/gatekeeper-controller-manager created<br>Warning: policy/v1beta1 PodDisruptionBudget is deprecated in v1.21+, unavailable in v1.25+; use policy/v1 PodDisruptionBudget<br>poddisruptionbudget.policy/gatekeeper-controller-manager created<br>validatingwebhookconfiguration.admissionregistration.k8s.io/gatekeeper-validating-webhook-configuration created</pre><p>You can confirm that Gatekeeper is up and running with the following command:</p><pre>$ kubectl get pods -n gatekeeper-system<br>NAME                                             READY   STATUS    RESTARTS   AGE<br>gatekeeper-audit-54c9759898-pdqqh                1/1     Running   0          40m<br>gatekeeper-controller-manager-6fdb4b697c-5ll8g   1/1     Running   0          40m<br>gatekeeper-controller-manager-6fdb4b697c-6gqc6   1/1     Running   0          40m<br>gatekeeper-controller-manager-6fdb4b697c-qzvfb   1/1     Running   0          40m</pre><h3>Types of mutation policies</h3><p>There are two types of mutation policies:</p><ul><li><strong>AssignMetadata</strong> — changes to resource metadata</li><li><strong>Assign</strong> — changes to all fields except resource metadata</li></ul><p>The <strong>AssignMetadata</strong> mutation policy is much more strict than the <strong>Assign</strong> policy. The metadata section of a resource is very sensitive and allowing changes to all metadata fields could result in unintended consequences. Given the sensitivity, mutation is restricted to only the addition of labels and annotations.</p><h3>Anatomy of a mutation policy</h3><p>Each mutation policy is made up of three parts:</p><ul><li>mutation scope— which resources are to be mutated</li><li>intent — the field and value to be mutated</li><li>conditions — conditions to apply the mutation</li></ul><p>Mutation scope defines which resources to apply the mutation and allows filtering as follows:</p><pre>applyTo:<br>- groups: [&quot;&quot;]<br>  kinds: [&quot;Pod&quot;]<br>  versions: [&quot;v1&quot;]<br>match:<br>  scope: Namespaced | Cluster<br>  kinds:<br>  - APIGroups: []<br>    kinds: []<br>  labelSelector: []<br>  namespaces: []<br>  namespaceSelector: []<br>  excludedNamespaces: []</pre><p>Intent defines the field to be mutated. In the following example, a container with the name <strong>test</strong> will have the <strong>securityContext.privileged</strong> field set to <em>false</em>.</p><pre>  location: &quot;spec.containers[name:test].securityContext.privileged&quot;<br>  parameters:<br>    assign:<br>      value: false</pre><p>There are two types of conditions for mutation resources.</p><ul><li>path test — mutate the resource if the path exists/doesn’t exist</li><li>value test — mutate the resource if the value is/is not in the list of values</li></ul><pre>parameters:<br>  pathTests:<br>  - subPath: &quot;spec.containers[name:foo]&quot;<br>    condition: MustExist<br>  - subPath: spec.containers[name:foo].securityContext.capabilities<br>    condition: MustNotExist</pre><pre>assignIf:<br>    in: [&lt;value 1&gt;, &lt;value 2&gt;, &lt;value 3&gt;, ...]<br>    notIn: [&lt;value 1&gt;, &lt;value 2&gt;, &lt;value 3&gt;, ...]</pre><h3>Defining mutation policies</h3><p>Now that we understand the basics of mutation policies, lets work through some examples.</p><p>In this first example we are going create an <strong>AssignMetadata</strong> policy that adds a label location with a value of europeto all resources.</p><pre>$ cat &lt;&lt;EOF | kubectl create -f -<br>apiVersion: mutations.gatekeeper.sh/v1alpha1<br>kind: AssignMetadata<br>metadata:<br>  name: label-location<br>spec:<br>  match:<br>    scope: Namespaced<br>  location: &quot;metadata.labels.location&quot;<br>  parameters:<br>    assign:<br>      value: &quot;europe&quot;<br>EOF<br>assignmetadata.mutations.gatekeeper.sh/label-location created</pre><p>Now that we’ve created the policy, let’s create a Pod. Note that the Pod has no labels.</p><pre>$ cat &lt;&lt;EOF | kubectl create -f -<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: nginx<br>spec:<br>  containers:<br>    - image: nginx<br>      name: nginx<br>      ports:<br>        - containerPort: 80<br>EOF<br>pod/nginx created</pre><p>Confirm that the labels were successfully applied using the following command:</p><pre>$ kubectl get pods nginx -o=jsonpath=&#39;{.metadata.labels}&#39;<br>{&quot;location&quot;:&quot;europe&quot;}</pre><p>In the next example we will create an <strong>Assign</strong> mutation policy that set the securityContext.privilegedfield to false in all namespace except the <strong>kube-system</strong> namespace.</p><pre>$ cat &lt;&lt;EOF | kubectl create -f -<br>apiVersion: mutations.gatekeeper.sh/v1alpha1<br>kind: Assign<br>metadata:<br>  name: set-privileged-false<br>spec:<br>  applyTo:<br>  - groups: [&quot;&quot;]<br>    kinds: [&quot;Pod&quot;]<br>    versions: [&quot;v1&quot;]<br>  match:<br>    scope: Namespaced<br>    kinds:<br>    - apiGroups: [&quot;*&quot;]<br>      kinds: [&quot;Pod&quot;]<br>    excludedNamespaces: [&quot;system&quot;]<br>  location: &quot;spec.containers[name:*].securityContext.privileged&quot;<br>  parameters:<br>    assign:<br>      value: false<br>EOF</pre><p>Let’s create a Pod that has the securityContext.privilege field set to false.</p><pre>$ cat &lt;&lt;EOF | kubectl create -f -<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: nginx<br>spec:<br>  containers:<br>    - image: nginx<br>      name: nginx<br>      ports:<br>        - containerPort: 80<br>      securityContext:<br>        privileged: true<br>EOF</pre><p>Confirm that the <strong>Assign</strong> mutation policy has been successfully applied.</p><pre>$ kubectl get pods nginx -o=jsonpath=&#39;{.spec.containers[*].securityContext}&#39;<br>{&quot;privileged&quot;:false}</pre><h3>Using Gatekeeper mutation with Pod Security Admission</h3><p>In a recent blog I took a hands on look at <a href="https://medium.com/@LachlanEvenson/hands-on-with-kubernetes-pod-security-admission-b6cac495cd11">Pod Security Admission</a>. One of the biggest changes to Pod Security Admission from its successor Pod Security Policy is that it is validation only (mutation is not supported). Because mutation is not supported, users must modify resources that aren’t compliant. I wanted to explore auto-remediation using Gatekeeper mutation so that resources do not violate Pod Security Admission policy. Let’s again use the Pod from the previous example that has securityContext.privilegedfield to true.</p><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: nginx<br>spec:<br>  containers:<br>    - image: nginx<br>      name: nginx<br>      ports:<br>        - containerPort: 80<br>      securityContext:<br>        privileged: true</pre><p>We are going to label the default namespace so that Pod Security Admission enforces the baseline security policy. The above Pod will violate that policy.</p><pre>$ kubectl label --overwrite ns default \<br>  pod-security.kubernetes.io/enforce=baseline \<br>  pod-security.kubernetes.io/enforce-version=v1.22<br>namespace/default not labeled</pre><p>Let’s try creating the Pod</p><pre>$ cat &lt;&lt;EOF | kubectl create -f -<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: nginx<br>spec:<br>  containers:<br>    - image: nginx<br>      name: nginx<br>      ports:<br>        - containerPort: 80<br>      securityContext:<br>        privileged: true<br>EOF<br>Error from server (Failure): error when creating &quot;STDIN&quot;: privileged (container &quot;nginx&quot; must not set securityContext.privileged=true)</pre><p>We get an error because the Pod violated the security policy. Now let’s create an <strong>Assign</strong> policy that mutates securityContext.privileged=true</p><pre>$ cat &lt;&lt;EOF | kubectl create -f -<br>apiVersion: mutations.gatekeeper.sh/v1alpha1<br>kind: Assign<br>metadata:<br>  name: set-privileged-false<br>spec:<br>  applyTo:<br>  - groups: [&quot;&quot;]<br>    kinds: [&quot;Pod&quot;]<br>    versions: [&quot;v1&quot;]<br>  match:<br>    scope: Namespaced<br>    kinds:<br>    - apiGroups: [&quot;*&quot;]<br>      kinds: [&quot;Pod&quot;]<br>    excludedNamespaces: [&quot;system&quot;]<br>  location: &quot;spec.containers[name:*].securityContext.privileged&quot;<br>  parameters:<br>    assign:<br>      value: false<br>EOF</pre><p>Now that this Assign mutation policy is created, well try to create the Pod again</p><pre>$ cat &lt;&lt;EOF | kubectl create -f -<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: nginx<br>spec:<br>  containers:<br>    - image: nginx<br>      name: nginx<br>      ports:<br>        - containerPort: 80<br>      securityContext:<br>        privileged: true<br>EOF<br>pod/nginx created</pre><p>Finally, let’s confirm that the securityContext.privileged is indeed set to false</p><pre>$ kubectl get pods nginx -o=jsonpath=&#39;{.spec.containers[*].securityContext}&#39;<br>{&quot;privileged&quot;:false}</pre><h3>Conclusion</h3><p>Having the ability to mutate resources is a powerful way to enforce policy, best practices, security standards, on behalf of the end user. Having a way to predictably apply mutations via Gatekeeper looks extremely promising and I’m excited to see this feature mature. If you have any feedback on this feature, I suggest creating an issue on the <a href="https://github.com/open-policy-agent/gatekeeper">Gatekeeper</a> GitHub repository.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e5585d49ead" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hands on with Kubernetes Pod Security Admission]]></title>
            <link>https://medium.com/@LachlanEvenson/hands-on-with-kubernetes-pod-security-admission-b6cac495cd11?source=rss-5d4f384fa574------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6cac495cd11</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cloud-native]]></category>
            <dc:creator><![CDATA[Lachlan Evenson]]></dc:creator>
            <pubDate>Thu, 19 Aug 2021 05:43:19 GMT</pubDate>
            <atom:updated>2021-08-26T22:33:17.727Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gl6GSFjMuz8KsOlAkNBK-w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@eprouzet?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Eric Prouzet</a> on <a href="https://unsplash.com/s/photos/security-gate?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Kubernetes v1.22 provides an alpha release for the successor of <a href="https://kubernetes.io/docs/concepts/policy/pod-security-policy/">Pod Security Policy (PSP)</a> (which is scheduled for deprecation in v1.25). This new enhancement is called <a href="https://kubernetes.io/docs/concepts/security/pod-security-admission/">Pod Security Admission</a> (PSA). I’ve taken an initial look at PSA and will cover what you need to know about how it works and how you can start playing with it. This will not be a deep dive into the architecture or reasoning behind the implementation. If you want to learn more about that you can find details in the <a href="https://github.com/kubernetes/enhancements/blob/master/keps/sig-auth/2579-psp-replacement/README.md">Kubernetes Enhancement Proposal (KEP)</a>.</p><p>One obvious difference between PSP and PSA is that PSA only appears to operate as a validating admission controller and doesn’t appear to support mutating resources like PSP.</p><p><em>NOTE: Kubernetes features that are in alpha aren’t typically available for use by managed Kubernetes services like AKS, EKS, GKE for stability reasons. Please check your providers documentation</em></p><h3>Enabling Pod Security Admission</h3><p>To enable Pod Security Admission you will need a v1.22 Kubernetes cluster with the following feature flag enabled --feature-gates=&quot;...,PodSecurity=true&quot;. When testing new alpha features, I like to use a tool called <a href="https://kind.sigs.k8s.io/">KinD</a> which allows you to quickly spin up a Kubernetes cluster locally. Below is the cluster configuration I used to spin up a v1.22 Kubernetes cluster with this feature enabled. Save the YAML below to a file named kind-config.yaml. <em>Special callout to </em><a href="https://twitter.com/JimmAngel/status/1424898747868356610?s=20"><em>Jim Angel</em></a><em> who provided this KinD configuration.</em></p><pre>kind: Cluster<br>apiVersion: kind.x-k8s.io/v1alpha4<br>featureGates:<br> PodSecurity: true<br>nodes:<br>- role: control-plane<br>- role: worker</pre><p>You can then start a new cluster using the following command:</p><pre>$ kind create cluster — image=kindest/node:v1.22.0@sha256:b8bda84bb3a190e6e028b1760d277454a72267a5454b57db34437c34a588d047 — config kind-config.yaml`<br>Creating cluster &quot;kind&quot; ...<br> ✓ Ensuring node image (kindest/node:v1.22.0) 🖼<br> ✓ Preparing nodes 📦 📦<br> ✓ Writing configuration 📜<br> ✓ Starting control-plane 🕹️<br> ✓ Installing CNI 🔌<br> ✓ Installing StorageClass 💾<br> ✓ Joining worker nodes 🚜<br>Set kubectl context to &quot;kind-kind&quot;<br>You can now use your cluster with:</pre><pre>kubectl cluster-info --context kind-kind</pre><pre>Thanks for using kind! 😊</pre><h3>Configuring Policy</h3><p>Now that you have a cluster up and running the next thing you will need to do is configure policies. Before we cover how to configure policies we need to understand <a href="https://kubernetes.io/docs/concepts/security/pod-security-standards/">Pod Security Standards</a>. These standards define three different policies that range from permissive to restrictive. These three policies are as follows:</p><ul><li>Privileged — open and unrestricted</li><li>Baseline — Covers most common known privilege escalations and provides an easier onboarding</li><li>Restricted — Highly restricted, covering best practices. May cause compatibility issues</li></ul><p>Each of these policies define which fields are restricted within a Pod specification and the allowed values. Some of the fields restricted by these policies include:</p><ul><li>spec.containers[*].ports</li><li>spec.volumes[*].hostPath</li><li>spec.securityContext</li><li>spec.containers[*].securityContext</li></ul><p>Now that we know what policies are available they can be applied in two different ways either via namespace labels or an AdmissionConfiguration resource. Using namespace labels allows for granulator per namespace policy selection whereas using AdmissionConfiguration allows cluster-level defaulting along with exemptions.</p><h3>Policy Modes</h3><p>Policies are applied using modes. Here is a list of modes:</p><ul><li><strong>enforce</strong> — Any Pods that violate the policy will be rejected</li><li><strong>audit</strong> — Pods with violations will be allowed and an audit annotation will be added</li><li><strong>warn</strong> — Pods that violate the policy will be allowed and a warning message will be sent back to the user.</li></ul><p>In addition to modes you can also pin the policy to a specific version for example v1.22. Pinning to a specific version allows the behavior to remain consistent as policy changes happen over Kubernetes releases.</p><h3>Applying Policy to a namespace</h3><p>Policies are applied to a namespace via labels. These labels are as follows:</p><ul><li>REQUIRED: pod-security.kubernetes.io/&lt;MODE&gt;: &lt;LEVEL&gt;</li><li>OPTIONAL: pod-security.kubernetes.io/&lt;MODE&gt;-version: &lt;VERSION&gt; (defaults to latest)</li></ul><p>The following command <strong>warns</strong> the <strong>baseline</strong> Pod Security Standard pinned to <strong>v1.22</strong> of the policy on the <strong>test-ns</strong> namespace. Be</p><pre>kubectl label --overwrite ns test-ns <strong>\<br></strong>  pod-security.kubernetes.io/warn=baseline <strong>\<br></strong>  pod-security.kubernetes.io/warn-version=v1.22</pre><p>As you can imagine, enforcing policy on a namespace with existing workloads could be disruptive. You can run the following command on a cluster to evaluate existing workloads against the policy and determine which workloads will need to be modified so they won’t violate the policy.</p><pre>$ kubectl label --dry-run=server --overwrite ns --all \<br>    pod-security.kubernetes.io/enforce=baseline<br>Warning: kuard: privileged<br>namespace/default labeled<br>namespace/kube-node-lease labeled<br>namespace/kube-public labeled<br>Warning: kube-proxy-vxjwb: host namespaces, hostPath volumes, privileged<br>Warning: kube-proxy-zxqzz: host namespaces, hostPath volumes, privileged<br>Warning: kube-apiserver-kind-control-plane: host namespaces, hostPath volumes<br>Warning: etcd-kind-control-plane: host namespaces, hostPath volumes<br>Warning: kube-controller-manager-kind-control-plane: host namespaces, hostPath volumes<br>Warning: kindnet-cl5ln: non-default capabilities, host namespaces, hostPath volumes<br>Warning: kube-scheduler-kind-control-plane: host namespaces, hostPath volumes<br>Warning: kindnet-6ptww: non-default capabilities, host namespaces, hostPath volumes<br>namespace/kube-system labeled<br>namespace/local-path-storage labeled</pre><p>Another really neat trick is that you can apply more than a single mode to a specific namespace. This is helpful to <strong>enforce</strong> at one policy standard and <strong>warn</strong> and <strong>audit</strong> at another. In the following example Pods that violate the <strong>baseline</strong> policy won’t be allowed and Pods that violate the <strong>restricted</strong> policy will <strong>warn</strong> and <strong>audit</strong>.</p><pre>apiVersion: v1<br>kind: Namespace<br>metadata:<br>  name: test-ns<br>  labels:<br>    pod-security.kubernetes.io/enforce: baseline<br>    pod-security.kubernetes.io/audit: restricted<br>    pod-security.kubernetes.io/warn: restricted</pre><p>To demonstrate the behavior of the configuration above lets create a NGINX Pod with the following manifest.</p><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: nginx<br>spec:<br>  containers:<br>    - image: nginx<br>      name: nginx<br>      ports:<br>        - containerPort: 80</pre><p>In the output below we can see that we receive a <strong>warning</strong> as the Pod violates the <strong>restricted</strong> policy and lists how to remediate<em>. </em>The Pod does not violate the <strong>baseline</strong> policy which is being <strong>enforced</strong> and hence is created.</p><pre>$ kubectl apply -f pod.yaml<br>Warning: would violate &quot;latest&quot; version of &quot;restricted&quot; PodSecurity profile: allowPrivilegeEscalation != false (container &quot;nginx&quot; must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container &quot;nginx&quot; must set securityContext.capabilities.drop=[&quot;ALL&quot;]), runAsNonRoot != true (pod or container &quot;nginx&quot; must set securityContext.runAsNonRoot=true), seccompProfile (pod or container &quot;nginx&quot; must set securityContext.seccompProfile.type to &quot;RuntimeDefault&quot; or &quot;Localhost&quot;)<br><strong>pod/nginx created</strong></pre><pre>laevenso@feu [(⎈ |kind-kind:test-ns)]  in ~<br>$ kubectl get pods<br>NAME    READY   STATUS    RESTARTS   AGE<br>nginx   1/1     Running   0          6s</pre><p>If you have <a href="https://kubernetes.io/docs/tasks/debug-application-cluster/audit/">Kubernetes audit logging</a> enabled you can see an audit message for <strong>restricted</strong> policy violations as configured by the namespace labels. Audit logging isn’t currently supported natively in Kind however <a href="https://twitter.com/JimmAngel">Jim Angel</a> as provided the following <a href="https://gist.github.com/jimangel/f899a734ad780340ac9aa682333bba30">Kind config</a> that enables audit logging. Thanks Jim!</p><pre>{&quot;kind&quot;:&quot;Event&quot;,&quot;apiVersion&quot;:&quot;audit.k8s.io/v1&quot;,&quot;level&quot;:&quot;Metadata&quot;,&quot;auditID&quot;:&quot;808ca159-914c-43fa-b4c8-dee5cb2fc440&quot;,&quot;stage&quot;:&quot;ResponseComplete&quot;,&quot;requestURI&quot;:&quot;/api/v1/namespaces/default/pods?fieldManager=kubectl-create&quot;,&quot;verb&quot;:&quot;create&quot;,&quot;user&quot;:{&quot;username&quot;:&quot;kubernetes-admin&quot;,&quot;groups&quot;:[&quot;system:masters&quot;,&quot;system:authenticated&quot;]},&quot;sourceIPs&quot;:[&quot;172.18.0.1&quot;],&quot;userAgent&quot;:&quot;kubectl/v1.22.0 (darwin/amd64) kubernetes/c2b5237&quot;,&quot;objectRef&quot;:{&quot;resource&quot;:&quot;pods&quot;,&quot;namespace&quot;:&quot;default&quot;,&quot;name&quot;:&quot;nginx&quot;,&quot;apiVersion&quot;:&quot;v1&quot;},&quot;responseStatus&quot;:{&quot;metadata&quot;:{},&quot;code&quot;:201},&quot;requestReceivedTimestamp&quot;:&quot;2021-08-21T03:30:26.605589Z&quot;,&quot;stageTimestamp&quot;:&quot;2021-08-21T03:30:26.627123Z&quot;,&quot;annotations&quot;:{&quot;authorization.k8s.io/decision&quot;:&quot;allow&quot;,&quot;authorization.k8s.io/reason&quot;:&quot;&quot;,&quot;pod-security.kubernetes.io/audit&quot;:&quot;allowPrivilegeEscalation != false (container \&quot;nginx\&quot; must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container \&quot;nginx\&quot; must set securityContext.capabilities.drop=[\&quot;ALL\&quot;]), runAsNonRoot != true (pod or container \&quot;nginx\&quot; must set securityContext.runAsNonRoot=true), seccompProfile (pod or container \&quot;nginx\&quot; must set securityContext.seccompProfile.type to \&quot;RuntimeDefault\&quot; or \&quot;Localhost\&quot;)&quot;}}</pre><h3>Applying cluster-wide policy</h3><p>In addition to applying labels to namespaces to configure policy you can also configure cluster-wide policies and exemptions using the AdmissionConfiguration resource. Using this resource, policy definitions are applied cluster-wide by default and any policy that is applied via namespace labels will take precedence. There is no runtime configurable API for this resource and a cluster administrator would need to specify a path to the file below via the --admission-control-config-fileflag on the API server. In this resource we are <strong>enforcing</strong> the <strong>baseline</strong> policy and <strong>warning</strong> and <strong>auditing</strong> the <strong>restricted</strong> policy. We are also making the <em>kube-system</em> namespace exempt from this policy.</p><pre><strong>apiVersion</strong>: apiserver.config.k8s.io/v1<br><strong>kind</strong>: AdmissionConfiguration<br><strong>plugins</strong>:<br>- <strong>name</strong>: DefaultPodSecurity<br>  <strong>configuration</strong>:<br>    <strong>apiVersion</strong>: pod-security.admission.config.k8s.io/v1alpha1<br>    <strong>kind</strong>: PodSecurityConfiguration<br>    <strong>defaults</strong>:<br>      <strong>enforce</strong>: &quot;baseline&quot;<br>      <strong>enforce-version</strong>: &quot;latest&quot;<br>      <strong>audit</strong>: &quot;restricted&quot;<br>      <strong>audit-version</strong>: &quot;latest&quot;<br>      <strong>warn</strong>: &quot;restricted&quot;<br>      <strong>warn-version</strong>: &quot;latest&quot;<br>    <strong>exemptions</strong>:<br>      <strong>usernames</strong>: []<br>      <strong>runtimeClassNames</strong>: []<br>      <strong>namespaces</strong>: [kube-system]</pre><h3>Migrating from PSP to PSA</h3><p>I haven’t yet taken an in-depth look at migration from PSP to PSA however here are the <a href="https://kubernetes.io/docs/tasks/configure-pod-container/migrate-from-psp/">docs</a> if you’re interested.</p><h3><strong>Summary</strong></h3><p>Having spent a considerable amount of time working with PSP, the successor PSA appears to be a much simpler implementation and achieves the same result. Pod Security Standards make it much easier for users to apply security best practices without going into painstaking detail to understand each and every security related field in a Pod specification. Namespace labelling also makes it easy to apply policy and choose the mode the policy operates. I suspect that Pod Security Policy will be easier to use and hence will be widely adopted. Overall this is a good thing for Kubernetes security. Finally, it’s worth mentioning again that this feature is still in alpha (at the time of writing) and is subject to change. Always consult the <a href="https://kubernetes.io/docs/home/">Kubernetes official documentation</a> for the most up to date docs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6cac495cd11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes Policy — Turning CNCF projects into products, responsibly]]></title>
            <link>https://medium.com/microsoft/kubernetes-policy-turning-cncf-projects-into-products-responsibly-7610ecb43c15?source=rss-5d4f384fa574------2</link>
            <guid isPermaLink="false">https://medium.com/p/7610ecb43c15</guid>
            <category><![CDATA[cncf]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Lachlan Evenson]]></dc:creator>
            <pubDate>Wed, 22 May 2019 06:36:24 GMT</pubDate>
            <atom:updated>2019-05-22T16:11:14.454Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vZkSy6ylxnHYiw6v.png" /></figure><h3>Kubernetes Policy — Turning CNCF projects into products, responsibly</h3><p>During <a href="https://www.microsoft.com/build">Build</a>, we announced a new service integration <a href="https://azure.microsoft.com/en-us/blog/partnering-with-the-community-to-make-kubernetes-easier/">“Azure Policy for AKS”</a>. With this integration, you can apply at-scale enforcements and safeguards for AKS clusters in a centralized, consistent manner through Azure Policy. In this blog, we will cover the background of the development process leading up to the announcement of this integration and share how we are embracing open source to build better software for the community and our customers.</p><p>Microsoft has over a 30-year heritage of working with enterprises. Of all the enterprise customers that we serve, we pay special attention to provide the appropriate level of products and feature for those that operate under regulated industries like financial services, healthcare and government. This is evident by the number of regions, compliance certifications and enterprise features in Azure.</p><h3>Enterprises want Kubernetes policy</h3><p>Given these operational environments, it comes as no surprise that enterprises are asking us for better policy and compliance for their Kubernetes clusters. Specifically, they want the ability to limit what end-users can do on clusters and ensure they are always in compliance with defined policy. For example:</p><ul><li>Which applications can be exposed to the Internet</li><li>What container images can be run</li></ul><p>In addition, they would like to be able to write custom rules that map to their organizational policy so whatever the solution is, it needs to be flexible enough to enable these workflows.</p><h3>Building consensus upstream</h3><p>Last December, we announced “Azure Policy Controller” which was built to solve these customer needs. This project was built from the ground-up as an open source project. Whilst this approach went well, it left us asking, “Why is this the Azure Policy Controller?”, and “Is it really in our best interest to keep this tied to Azure?”. We came to the realization that we were building a generic policy component that could be utilized on any Kubernetes cluster so, why not broaden the scope of the project? We subsequently renamed the project to “Kubernetes Policy Controller” and wrote documentation on how to use this on any Kubernetes cluster, created process around project governance and onboarded external contributors.</p><p>As it turned out, we weren’t the only ones in the community trying to solve the policy on Kubernetes. The Open Policy Agent (part of CNCF) community is excellent and was also exploring similar integrations. Utilizing projects from the OPA community allowed us to leverage an established, open source, policy engine and alleviate the need for us to build our own. We therefore thought it fitting that we would work in collaboration with the OPA community to bring “Kubernetes Policy Controller” under the OPA umbrella of projects.</p><p>Once donated to OPA in early 2019, the community decided to rename the project to Gatekeeper. Gatekeeper is now the standard admission controller for enforcing policy on any Kubernetes cluster. The community is growing and consists of many companies and end-users from the Kubernetes community such as Google, Red Hat, and Styra.</p><h3>Azure Policy for AKS</h3><p>When it comes to the needs of enterprise customers, it isn’t just enough to deliver an OSS project. They need products that are supported, integrated and built upon industry-standard open source. We took Gatekeeper and integrated it into our Azure Governance suite. Azure Policy for AKS allows policy to be applied to your clusters which will deny non-compliant resources upon create and update operations. In addition, the service also provides audit capability which will display cluster resources that do not comply with your defined policy. This feature is powered by two open source CNCF projects, Gatekeeper and Open Policy Agent. As part of the preview, the service provides predefined policy that can be applied to any AKS cluster. Here are some of the predefined policies.</p><ul><li>Ensure LoadBalancers don’t have public IPs</li><li>Only allow containers from whitelisted container registries</li><li>Ensure ingress hostnames don’t overlap</li><li>Ensure that all ingresses only use HTTPS</li></ul><p>In additional to predefined policy, we are investigating providing the integration of user-defined policy. Given that the policies are defined as OPA <a href="https://www.openpolicyagent.org/docs/v0.10.7/how-do-i-write-policies/">Rego</a>, we hope to see an ecosystem of policy libraries become available that users may wish to into their set of policies. This is the power of utilizing OPA and allows for portable policies, no matter how they are implemented on cluster.</p><h3>The future of cloud computing is open</h3><p>At Microsoft, we believe that the future of cloud computing is open source. As with projects such as <a href="https://github.com/open-policy-agent/gatekeeper">Gatekeeper</a>, we are committed to building upstream-first wherever possible and this has been demonstrated with contributions to Kubernetes, Helm, <a href="https://virtual-kubelet.io/">Virtual-Kubelet</a>, <a href="https://brigade.sh/">Brigade</a> and more. Come visit the Microsoft booth whilst at KubeCon Barcelona for a demo and to learn more about <a href="https://aka.ms/k8slearning">Kubernetes,</a> Gatekeeper and our other projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7610ecb43c15" width="1" height="1" alt=""><hr><p><a href="https://medium.com/microsoft/kubernetes-policy-turning-cncf-projects-into-products-responsibly-7610ecb43c15">Kubernetes Policy — Turning CNCF projects into products, responsibly</a> was originally published in <a href="https://medium.com/microsoft">Microsoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lachie’s 7 step guide to writing a winning tech conference CFP]]></title>
            <link>https://medium.com/@LachlanEvenson/lachies-7-step-guide-to-writing-a-winning-tech-conference-cfp-4fa36a0d2672?source=rss-5d4f384fa574------2</link>
            <guid isPermaLink="false">https://medium.com/p/4fa36a0d2672</guid>
            <category><![CDATA[conference]]></category>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[cfp]]></category>
            <category><![CDATA[tech-conference]]></category>
            <dc:creator><![CDATA[Lachlan Evenson]]></dc:creator>
            <pubDate>Fri, 24 Aug 2018 20:27:42 GMT</pubDate>
            <atom:updated>2019-01-14T21:31:52.113Z</atom:updated>
            <content:encoded><![CDATA[<p>What’s the winning formula for writing a tech conference CFP you ask? This is a question that has been playing on my mind recently and I thought I would take the time to share what I have learned over the years. This is by no means perfect and is simply my subjective point of view. My hope is that you find it useful.</p><h3>Why should I listen to Lachie?</h3><p>Right about now you’re probably asking yourself. “Why should I listen to Lachie?” Fact is, you’re right, you don’t have to listen to me at all but I feel that this information is important to share. A little background about myself, I’ve been on the tech conference scene for about 5 years now. During that time I have delivered over 30 presentations including keynotes and have also served on selection committees of some of the largest tech conferences in the industry. I also spend time reviewing CFPs for community members before they click submit. All that to say, this is my experience. Feel free to take it or leave it.</p><h3>How do I write an effective tech conference CFP?</h3><p>Let’s get into why you are all here. “How do I write an effective tech conference CFP?”</p><p>First I want to plant an idea that you need to keep in your front brain when writing a CFP - Who will be reading this? There are two main personas at play here:</p><ul><li>Selection Commitee</li><li>Possible Attendees</li></ul><p>Truth is that your CFP, once selected, is instantly placed on the schedule as-is. That makes it important not only for selection but also for attendance.</p><h3>Lachie’s 7 steps to writing a winning tech conference CFP</h3><h4>Make the title <strong>POP!</strong></h4><p>This might seem obvious but you influence the readers mind by framing what they are about to read. Be creative but not too clever, overdoing it could make the reader shy away. This is also important for live attendance. Think of all those titles on a screen with an attendee trying to choose. All you have is the title.</p><h4>It’s all about the first sentence</h4><p>You only really have the first sentence to have the reader commit to reading the rest. At the very least, you need to shape their expectations. Crafting that first sentence is key. Helping the reader answer “Why should I keep reading?” is what you need to target.</p><h4>Tell a story</h4><p>Create a narrative around sharing an experience rather than just laying out fact. People relate to and appreciate story telling. Take the reader on a journey with you.</p><h4>Target a persona</h4><p>Readers want to understand. “Is this for me?” Shape the narrative around a persona. Is this for a developer or an operator for example. Making it relatable to the reader frames the content and also the narrative arc.</p><h4>Less is more</h4><p>This is by far the most important. If you cannot tell the reader what you are going to share and the takeaways in 3 to 6 sentences, then chances are you won’t be able to do it in a 30m presentation. Don’t try to be wordy just because the CFP has a word limit. Just sayin’.</p><h4>Tangible Takeaways</h4><p>Something the reader always wants to answer is “If I’m going to spend 30 odd minutes on this presentation, what am I going to leave with?” Will you enable the attendee to be equipped to do the same thing when they return home? Make it tangible. Architecture diagrams, sample code, repositories are just some ways you could do this.</p><h4>Callout advantages for the live audience</h4><p>To encourage attendance on the actual day, leave snippets of things that only the live audience will have access to. Like any live event, you want to provide access to something the folks at home, or on Youtube don’t.</p><h3>Examples</h3><p>Here are some example of CFPs I’ve submitted that were selected over the years that I believe follow a similar formula.</p><ul><li><a href="https://kccncna17.sched.com/event/CU85/setting-sail-with-istio-b-lachlan-evenson-microsoft">KubeCon + CloudNativeCon North America 2017: Setting Sail with Istio [B] - Lachlan Ev...</a></li><li><a href="https://kccncna17.sched.com/event/CU6U/democratizing-machine-learning-on-kubernetes-i-joy-qiao-lachlan-evenson-microsoft">KubeCon + CloudNativeCon North America 2017: Democratizing Machine Learning on Kubern...</a></li><li><a href="https://cloudnativeeu2017.sched.com/event/9TcY/delve-into-helm-advanced-devops-i-lachlan-evenson-adam-reese-deis">CloudNativeCon + KubeCon Europe 2017: Delve into Helm: Advanced DevOps [I] - L...</a></li><li><a href="https://www.openstack.org/summit/austin-2016/summit-schedule/events/8695/your-cicd-infrastructure-is-a-monolith-too">Your CI/CD Infrastructure is a Monolith Too</a></li></ul><h3>Wrap up</h3><p>So there you have it. That’s the little nugget of wisdom I wanted to share. I’m very interested in what you all have to say and if you feel like I missed anything — let me know. Please remember — following all these steps will <strong>not guarantee acceptance</strong>. Gracefully accepting rejections is a less fun, but no less important skill. It is worth nothing that I’ve had many submissions not-accepted over the years. Good luck and happy CFPing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4fa36a0d2672" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>