Files
argocd-apps/apps/base/artifactapi/api-deployment.yaml
T
unkin-agent 87dad4c89b Encrypt artifactapi GitHub App keys with Vault transit (#616)
artifactapi stores GitHub App private keys in Postgres in plaintext. It can now encrypt them with a Vault transit key, logging in via Kubernetes auth.

- enable transit encryption of GitHub App keys on the api Deployment
- point it at Vault (`k8s/au/syd1` role `artifactapi`, transit key `artifactapi-github-app-keys`) using the combined CA bundle
- mount a projected SA token with audience `vault` for the login

Requires IUCLabs/terraform-vault#15 applied and an artifactapi release containing IUCLabs/artifactapi#22.

Reviewed-on: #616
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-11-29 17:45:07 +11:00

121 lines
3.4 KiB
YAML

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: api
namespace: artifactapi
annotations:
configmap.reloader.stakater.com/auto: "true"
secret.reloader.stakater.com/reload: "vault-ca-cert"
spec:
selector:
matchLabels:
app: api
strategy:
rollingUpdate:
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
labels:
app: api
spec:
automountServiceAccountToken: true
initContainers:
- name: combine-certs
image: alpine:3
command:
- sh
- -c
- cat /etc/ssl/certs/ca-certificates.crt /custom-ca/ca.crt > /combined-certs/ca-certificates.crt
volumeMounts:
- name: vault-ca-cert
mountPath: /custom-ca
readOnly: true
- name: combined-certs
mountPath: /combined-certs
containers:
- name: api
image: ghcr.io/iuclabs/artifactapi:v3.26.3
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8000
name: http
protocol: TCP
env:
- name: GITHUB_APP_KEY_ENCRYPTION
value: transit
- name: VAULT_ADDR
value: https://vault.service.consul:8200
- name: VAULT_CACERT
value: /etc/ssl/combined/ca-certificates.crt
- name: VAULT_K8S_MOUNT
value: k8s/au/syd1
- name: VAULT_K8S_ROLE
value: artifactapi
- name: VAULT_K8S_TOKEN_PATH
value: /var/run/secrets/vault/token
- name: VAULT_TRANSIT_MOUNT
value: transit
- name: VAULT_TRANSIT_KEY
value: artifactapi-github-app-keys
envFrom:
- configMapRef:
name: api-env
optional: false
- secretRef:
name: environment
optional: false
volumeMounts:
- name: combined-certs
mountPath: /etc/ssl/combined
readOnly: true
- name: vault-token
mountPath: /var/run/secrets/vault
readOnly: true
livenessProbe:
failureThreshold: 3
httpGet:
path: /health
port: http
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 5
readinessProbe:
failureThreshold: 3
httpGet:
path: /health
port: http
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 5
successThreshold: 1
timeoutSeconds: 5
resources:
limits:
cpu: "1"
memory: 4Gi
requests:
cpu: 100m
memory: 256Mi
volumes:
- name: vault-ca-cert
secret:
secretName: vault-ca-cert
items:
- key: ca.crt
path: ca.crt
- name: combined-certs
emptyDir: {}
# The default kubernetes.io token has the wrong audience for Vault login.
- name: vault-token
projected:
sources:
- serviceAccountToken:
path: token
audience: vault
expirationSeconds: 600
restartPolicy: Always