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.
To do so, I'm trying to run kustomize build
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)
kustomize build --ignore-kind=ksops ./apps/myapp/production
If I don't skip the ksops stuff, I get this:
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
I noticed that someone else thought this was important too. They made a patched version of ksops that can handle my scenario. 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.
Update: For reference, I'm doing this in Docker.
Trying out larsks' solution, here's the code I tried:
Dockerfile
FROM alpine
RUN apk add bash curl git
RUN curl -s https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh | bash \
&& mv kustomize /usr/bin/kustomize \
&& 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 \
&& 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
validate.sh
#! /bin/bash
set -e
for i in `find . -name kustomization* -type f | grep -v \/base`; do
d=`dirname $i`
echo "$d"
kustomize build --enable-alpha-plugins "$d"
done