Files
argocd-apps/apps/base/puppet/deployment_puppetserver-compiler.yaml
T
unkin-agent 3fa12e4e5a
ci/woodpecker/pr/vector-test Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/kubeconform Pipeline was successful
Deliver the cert helpers to the puppet compiler pods
certmanager and sshsignhost are invoked server-side by generate() during catalog compilation but only exist on the legacy VM masters, so compiles on the k8s compilers fail with "No such file or directory".

- Stage a self-contained EL9 python runtime on the shared bins volume
- Render both helpers from their puppet-prod ERB templates on the code volume rather than copying the scripts here
- Mount a name-dispatching launcher at /usr/local/bin/{certmanager,sshsignhost}
- Mount kubernetes-auth configs at /opt/{certmanager,sshsignhost}/config.yaml

Needs terraform-vault #152 applied and the puppet-prod kubernetes-auth PR merged.
2026-09-13 23:26:34 +10:00

334 lines
11 KiB
YAML

apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
configmap.reloader.stakater.com/auto: "true"
secret.reloader.stakater.com/reload: "vault-ca-cert"
labels:
app.kubernetes.io/component: puppetserver-compilers
app.kubernetes.io/instance: puppetserver
app.kubernetes.io/name: puppetserver
app.kubernetes.io/version: 8.8.0
name: puppetserver-compiler
namespace: puppet
spec:
selector:
matchLabels:
app.kubernetes.io/component: puppetserver-compilers
app.kubernetes.io/name: puppetserver
template:
metadata:
labels:
app.kubernetes.io/component: puppetserver-compilers
app.kubernetes.io/instance: puppetserver
app.kubernetes.io/name: puppetserver
app.kubernetes.io/version: 8.8.0
spec:
hostname: puppetserver-compiler
imagePullSecrets: null
containers:
- name: puppetserver
image: ghcr.io/openvoxproject/openvoxserver:8.8.0-main
imagePullPolicy: IfNotPresent
resources:
limits:
cpu: 2
memory: 3072Mi
requests:
cpu: 200m
memory: 1024Mi
ports:
- containerPort: 8140
name: puppetserver
envFrom:
- configMapRef:
name: puppetserver-compiler-config
env:
- name: OPENVOXSERVER_HOSTNAME
valueFrom:
fieldRef:
fieldPath: metadata.name
livenessProbe:
failureThreshold: 3
periodSeconds: 30
successThreshold: 1
tcpSocket:
port: 8140
timeoutSeconds: 10
readinessProbe:
failureThreshold: 3
httpGet:
path: /status/v1/simple
port: 8140
scheme: HTTPS
periodSeconds: 60
successThreshold: 1
timeoutSeconds: 20
securityContext:
allowPrivilegeEscalation: false
# Root entrypoint chowns baked-in dirs (CHOWN) then drops the JVM to
# the puppet user via `runuser` (needs SETUID/SETGID). Cannot run
# non-root: the image entrypoint requires a root start.
capabilities:
add:
- CHOWN
- DAC_OVERRIDE
- FOWNER
- SETGID
- SETUID
drop:
- all
startupProbe:
failureThreshold: 30
periodSeconds: 15
tcpSocket:
port: 8140
volumeMounts:
- mountPath: /etc/puppetlabs/code/
name: puppet-code-volume
- mountPath: /etc/puppetlabs/puppet/
name: puppet-puppet-volume
- mountPath: /var/lib/puppet/keys/
name: eyaml-keys
readOnly: true
- mountPath: /opt/bin/
name: puppet-shared-bins
- mountPath: /opt/vault-ca-cert.crt
name: vault-ca-cert
subPath: ca.crt
- mountPath: /docker-custom-entrypoint.d/post-startup/additional-ruby-gems.sh
name: additional-ruby-gems
subPath: additional-ruby-gems.sh
- mountPath: /usr/local/bin/certmanager
name: cert-helpers
subPath: vault-helper
- mountPath: /usr/local/bin/sshsignhost
name: cert-helpers
subPath: vault-helper
- mountPath: /opt/certmanager/config.yaml
name: cert-helpers
subPath: certmanager-config.yaml
- mountPath: /opt/sshsignhost/config.yaml
name: cert-helpers
subPath: sshsignhost-config.yaml
- mountPath: /configmaps/auth.conf
name: compiler-auth-conf
subPath: auth.conf
- mountPath: /docker-custom-entrypoint.d/pre-default/10-auth-conf.sh
name: compiler-auth-conf-seed
subPath: 10-auth-conf.sh
initContainers:
- name: copy-configmaps
image: busybox:1.35
command:
- sh
- -c
args:
- |
echo "Copying configmap files to shared volume..."
mkdir -p /etc/puppetlabs/puppet
cp /configmaps/puppet.conf /etc/puppetlabs/puppet/puppet.conf
cp /configmaps/puppetdb.conf /etc/puppetlabs/puppet/puppetdb.conf
cp /configmaps/autosign.conf /etc/puppetlabs/puppet/autosign.conf
echo "Configmap files copied successfully"
volumeMounts:
- mountPath: /etc/puppetlabs/puppet/
name: puppet-puppet-volume
- mountPath: /configmaps/puppet.conf
name: compiler-puppet-conf
subPath: puppet.conf
- mountPath: /configmaps/puppetdb.conf
name: compiler-puppetdb-conf
subPath: puppetdb.conf
- mountPath: /configmaps/autosign.conf
name: compiler-autosign-conf
subPath: autosign.conf
- name: perms-and-dirs
image: ghcr.io/openvoxproject/openvoxserver:8.8.0-main
imagePullPolicy: IfNotPresent
command:
- sh
- -c
args:
- |
mkdir -p /etc/puppetlabs/puppet/eyaml/keys
mkdir -p /etc/puppetlabs/code/environments
mkdir -p /etc/puppetlabs/puppet/manifests
chown -R puppet:puppet /etc/puppetlabs
chown puppet:puppet /etc/puppetlabs/puppet/r10k.yaml
mkdir -p /opt/puppetlabs/server/data/puppetserver/dropsonde/bin/
touch /opt/puppetlabs/server/data/puppetserver/dropsonde/bin/dropsonde
chown puppet:puppet -R /opt/puppetlabs/server/data/puppetserver/
env:
- name: OPENVOXSERVER_JAVA_ARGS
value: -Xms1024m -Xmx3072m -Dcom.sun.management.jmxremote.port=31000 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
resources:
limits:
cpu: 300m
memory: 256Mi
requests:
cpu: 200m
memory: 128Mi
securityContext:
runAsUser: 0
runAsNonRoot: false
allowPrivilegeEscalation: false
# Runs as root to chown the mounted PVC dirs to puppet:puppet before
# the main container starts (CHOWN); does not drop privileges itself.
capabilities:
add:
- CHOWN
- DAC_OVERRIDE
- FOWNER
drop:
- all
volumeMounts:
- mountPath: /etc/puppetlabs/code/
name: puppet-code-volume
- mountPath: /etc/puppetlabs/puppet/
name: puppet-puppet-volume
- name: setup-shared-bins
image: git.unkin.net/unkin/almalinux9-base:20260606
command:
- sh
- -c
args:
- |
set -e
echo "Setting up shared binaries..."
mkdir -p /opt/bin
# Install the encapic ENC client (stdlib-only Go binary) to the shared
# bin volume. It replaces the uv/python ENC script, whose
# first-invocation dependency resolution failed on fresh compiler pods.
ENCAPIC_VERSION=v0.1.0
BASE=https://git.unkin.net/unkin/encapic/releases/download/$ENCAPIC_VERSION
cd /tmp
curl -fsSL -o encapic "$BASE/encapic_linux_amd64"
curl -fsSL -o encapic.sha256 "$BASE/encapic_linux_amd64.sha256"
# The published checksum names the release asset; verify against the
# file we downloaded regardless of the recorded filename.
EXPECTED=$(awk '{print $1}' encapic.sha256)
echo "$EXPECTED encapic" | sha256sum -c -
install -m 0755 encapic /opt/bin/encapic
echo "Shared binaries setup completed"
volumeMounts:
- mountPath: /opt/bin/
name: puppet-shared-bins
- name: setup-cert-helpers
image: git.unkin.net/unkin/almalinux9-base:20260606
command:
- sh
- -c
args:
- |
set -e
CH=/opt/bin/certhelpers
PYROOT=$CH/py-el9-1
TPL=/etc/puppetlabs/code/environments/develop/site/profiles/templates/helpers
mkdir -p "$CH"
# The helpers are python3 (requests, pyyaml) and openvoxserver ships
# no python, so stage a self-contained EL9 tree once per volume.
if [ ! -f "$PYROOT/.ready" ]; then
echo "Staging python runtime for the cert helpers..."
TMP=$CH/.py-el9-1.$$
rm -rf "$TMP"
dnf -y --installroot="$TMP" --releasever=9 --nodocs \
--setopt=install_weak_deps=0 --disablerepo=unkin install \
python3 python3-requests python3-pyyaml python3-six
rm -rf "$TMP/var/cache" "$TMP/var/lib/dnf" "$TMP/var/lib/rpm" \
"$TMP/usr/share/locale"
# Both hardcode EL absolute paths that only exist inside the tree.
SP=$TMP/usr/lib/python3.9/site-packages
ln -sfn ../../six.py "$SP/urllib3/packages/six.py"
sed -i "s|'/etc/pki/tls/certs/ca-bundle.crt'|'$PYROOT/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem'|" \
"$SP/requests/certs.py"
touch "$TMP/.ready"
mv -T "$TMP" "$PYROOT" || rm -rf "$TMP"
fi
# Render from the puppet-prod ERB templates on the code volume so this
# repo never carries a second copy of the scripts.
for n in certmanager sshsignhost; do
sed -e "s|<%= @venv_path %>|$PYROOT/usr|g" \
-e "s|<%= @config_path %>|/opt/$n/config.yaml|g" \
"$TPL/$n.erb" > "$CH/.$n.$$"
chmod 0755 "$CH/.$n.$$"
mv "$CH/.$n.$$" "$CH/$n"
done
echo "Cert helpers setup completed"
resources:
limits:
cpu: 1
memory: 1Gi
requests:
cpu: 200m
memory: 256Mi
volumeMounts:
- mountPath: /opt/bin/
name: puppet-shared-bins
- mountPath: /etc/puppetlabs/code/
name: puppet-code-volume
readOnly: true
securityContext:
fsGroup: 999
seccompProfile:
type: RuntimeDefault
volumes:
- name: puppet-code-volume
persistentVolumeClaim:
claimName: puppetserver-code-shared
- name: puppet-puppet-volume
persistentVolumeClaim:
claimName: puppetserver-compiler-config-shared
- name: eyaml-keys
secret:
secretName: eyaml-keys
defaultMode: 0600
- name: compiler-puppet-conf
configMap:
name: compiler-puppet.conf
- name: compiler-puppetdb-conf
configMap:
name: compiler-puppetdb.conf
- name: compiler-autosign-conf
configMap:
name: compiler-autosign.conf
- name: puppet-shared-bins
persistentVolumeClaim:
claimName: puppet-shared-bins
- name: vault-ca-cert
secret:
secretName: vault-ca-cert
- name: additional-ruby-gems
configMap:
name: additional-ruby-gems
defaultMode: 0755
- name: cert-helpers
configMap:
name: cert-helpers
items:
- key: vault-helper
path: vault-helper
mode: 0755
- key: certmanager-config.yaml
path: certmanager-config.yaml
mode: 0444
- key: sshsignhost-config.yaml
path: sshsignhost-config.yaml
mode: 0444
- name: compiler-auth-conf
configMap:
name: compiler-auth.conf
- name: compiler-auth-conf-seed
configMap:
name: compiler-auth-conf-seed
defaultMode: 0755
strategy:
type: RollingUpdate