<p>In my project, we let developers update a repo containing all of the kubernetes manifests. The repo uses kustomize. I've decided to add a validation / lint step to our CI to catch mistakes early.</p>
<p>To do so, I'm trying to run <code>kustomize build</code> on everything in the repo. Where I'm running into trouble is our use of ksops. In this scenario, it's not important to actually decode the secrets. I don't want to install the appropriate key on the CI server or allow it to be pulled.  What I'd really like to do is skip all the ksops stuff. I'm looking for something like this (doesn't seems to exist)</p>
<pre><code>kustomize build --ignore-kind=ksops ./apps/myapp/production
</code></pre>
<p>If I don't skip the ksops stuff, I get this:</p>
<blockquote>
<p>trouble decrypting file Error getting data key: 0 successful groups required, got 0Error: failure in plugin configured via /tmp/kust-plugin-config-24824323; exit status 1: exit status 1</p>
</blockquote>
<p>I noticed that someone else thought this was important too. <a href="https://github.com/argyle-engineering/ksops" rel="nofollow noreferrer">They made a patched version of ksops that can handle my scenario.</a> I'm hoping to do this with the unpatched stuff. Reason: because the folks that come after me will wonder what this is all about.</p>
<hr />
<p>Update: For reference, I'm doing this in Docker.</p>
<p>Trying out larsks' solution, here's the code I tried:</p>
<p>Dockerfile</p>
<pre><code>FROM alpine

RUN apk add bash curl git

RUN curl -s https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh | bash \
    &amp;&amp; mv kustomize /usr/bin/kustomize \
    &amp;&amp; kustomize version

ENV XDG_CONFIG_HOME=/root/.config
RUN mkdir -p /root/.config/kustomize/plugin

RUN mkdir -p /root/.config/kustomize/plugin/viaduct.ai/v1/ksops \
    &amp;&amp; ln -s /bin/true /root/.config/kustomize/plugin/viaduct.ai/v1/ksops/ksops
ENV KUSTOMIZE_PLUGIN_HOME=/root/.config/kustomize/plugin

WORKDIR /code

COPY . /code

RUN ./validate.sh
</code></pre>
<p>validate.sh</p>
<pre><code>#! /bin/bash

set -e

for i in `find . -name kustomization* -type f | grep -v \/base`; do
    d=`dirname $i`
    echo &quot;$d&quot;
    kustomize build --enable-alpha-plugins &quot;$d&quot;
done

</code></pre>

<p>The solution is to create a dummy filter for processing ksops resources. For example, something like this:</p>
<pre><code>mkdir -p fakeplugins/viaduct.ai/v1/ksops
ln -s /bin/true fakeplugins/viaduct.ai/v1/ksops/ksops
export KUSTOMIZE_PLUGIN_HOME=$PWD/fakeplugins

kustomize build --enable-alpha-plugins
</code></pre>
<p>This will cause <code>kustomize</code> to call <code>/bin/true</code> when it encounters ksops-encrypted resources. You won't have secrets in your output, but it will generate all other resources.</p>
<p>(The above has been tested with kustomize 4.5.5)</p>
<hr />
<p>The reason your code is failing is because you're using a Busybox-based Docker image. Busybox is a multi-call binary; it figures out what applet to run based on the name with which it was called. So while on a normal system, we can run <code>ln -s /bin/true /path/to/ksops</code> and then run <code>/path/to/ksops</code>, this won't work in a Busybox environment: it sees that it's being called as <code>ksops</code> and doesn't know what to do.</p>
<p>Fortunately, that's an easy problem to solve:</p>
<pre><code>FROM alpine

RUN apk add bash curl git

RUN curl -s https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh | bash \
    &amp;&amp; mv kustomize /usr/bin/kustomize \
    &amp;&amp; kustomize version

RUN mkdir -p /root/fakeplugins/viaduct.ai/v1/ksops \
    &amp;&amp; printf &quot;#!/bin/sh\nexit 0\n&quot; &gt; /root/fakeplugins/viaduct.ai/v1/ksops/ksops \
    &amp;&amp; chmod 755 /root/fakeplugins/viaduct.ai/v1/ksops/ksops

ENV KUSTOMIZE_PLUGIN_HOME=/root/fakeplugins

COPY validate.sh /bin/validate-overlays

WORKDIR /code
</code></pre>
<p>And now, given a layout like this:</p>
<pre><code>.
├── Dockerfile
├── example
│   ├── base
│   │   ├── deployment.yaml
│   │   ├── kustomization.yaml
│   │   └── pvc.yaml
│   └── overlay
│       ├── deployment_patch.yaml
│       ├── kustomization.yaml
│       ├── pg-password.enc.yaml
│       └── secret-generator.yaml
└── validate.sh
</code></pre>
<p>I can run from the top directory:</p>
<pre><code>docker run --rm -v $PWD:/code my-kustomize-image validate-overlays
</code></pre>
<hr />
<p>NB: I've slightly modified <code>validate.sh</code> to do the filtering in <code>find</code> rather than piping the output to <code>grep -v</code>  :</p>
<pre><code>#!/bin/bash

set -e

find . -name base -prune -o -name kustomization.yaml -print |
    while read -r overlay; do
        overlay=&quot;${overlay%/*}&quot;
        echo &quot;$overlay&quot;
        kustomize build --enable-alpha-plugins &quot;$overlay&quot;
    done
</code></pre>
