Compare commits

..

No commits in common. "596b2df8e61917449c6d9bcdd43136a021670d1c" and "f167d7d17dd7a71e7becacd32415ea5ee151c846" have entirely different histories.

6 changed files with 51 additions and 82 deletions

6
.trivyignore.yaml Normal file
View File

@ -0,0 +1,6 @@
misconfigurations:
- id: KSV-0041
paths:
- deploy/clusterrole.yaml
expired_at: 2026-05-22
statement: Soteria copies restic credentials into target namespaces for backup Jobs; replace with a narrower per-namespace secret distribution model.

66
Jenkinsfile vendored
View File

@ -18,7 +18,6 @@ spec:
operator: NotIn
values:
- titan-06
- titan-08
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
preference:
@ -39,22 +38,22 @@ spec:
jenkins/jenkins-jenkins-agent: "true"
containers:
- name: builder
image: gcr.io/kaniko-project/executor@sha256:c3109d5926a997b100c4343944e06c6b30a6804b2f9abe0994d3de6ef92b028e
image: registry.bstein.dev/bstein/docker:27
command:
- /busybox/cat
- cat
tty: true
resources:
requests:
cpu: 100m
memory: 1Gi
limits:
cpu: 1500m
memory: 2Gi
env:
- name: DOCKER_HOST
value: tcp://localhost:2375
- name: DOCKER_TLS_CERTDIR
value: ""
volumeMounts:
- name: workspace-volume
mountPath: /home/jenkins/agent
- name: docker-config-writable
mountPath: /kaniko/.docker
mountPath: /root/.docker
- name: harbor-config
mountPath: /docker-config
- name: tester
image: registry.bstein.dev/bstein/golang:1.25-bookworm
command:
@ -74,6 +73,12 @@ spec:
volumes:
- name: docker-config-writable
emptyDir: {}
- name: harbor-config
secret:
secretName: harbor-robot-pipeline
items:
- key: .dockerconfigjson
path: config.json
- name: workspace-volume
emptyDir: {}
"""
@ -518,7 +523,7 @@ PY
expression { return params.PUBLISH_IMAGES }
}
steps {
container('tester') {
container('builder') {
script {
sh 'git config --global --add safe.directory /home/jenkins/agent/workspace/Soteria'
def semver = sh(returnStdout: true, script: 'git describe --tags --exact-match || true').trim()
@ -531,6 +536,24 @@ PY
}
}
}
stage('Buildx setup') {
when {
expression { return params.PUBLISH_IMAGES }
}
steps {
container('builder') {
sh '''
set -eu
seq 1 10 | while read _; do
docker info && break || sleep 2
done
BUILDER_NAME="soteria-${BUILD_NUMBER}"
docker buildx rm "${BUILDER_NAME}" >/dev/null 2>&1 || true
docker buildx create --name "${BUILDER_NAME}" --driver docker-container --driver-opt image=registry.bstein.dev/bstein/buildkit:buildx-stable-1 --bootstrap --use
'''
}
}
}
stage('Build & push image') {
when {
expression { return params.PUBLISH_IMAGES }
@ -540,20 +563,13 @@ PY
withCredentials([usernamePassword(credentialsId: 'harbor-robot', usernameVariable: 'HARBOR_USERNAME', passwordVariable: 'HARBOR_PASSWORD')]) {
sh '''
set -eu
set +x
VERSION_TAG=$(cut -d= -f2 build.env)
umask 077
auth=$(printf '%s:%s' "${HARBOR_USERNAME}" "${HARBOR_PASSWORD}" | base64 | tr -d '\\n')
printf '{"auths":{"registry.bstein.dev":{"auth":"%s"}}}\\n' "${auth}" > /kaniko/.docker/config.json
trap 'rm -f /kaniko/.docker/config.json' EXIT
/kaniko/executor \
--context "${WORKSPACE}" \
--dockerfile "${WORKSPACE}/Dockerfile" \
--build-arg BUILDPLATFORM=linux/arm64 \
--build-arg TARGETOS=linux \
--build-arg TARGETARCH=arm64 \
--destination "registry.bstein.dev/bstein/soteria:${VERSION_TAG}" \
--destination registry.bstein.dev/bstein/soteria:latest
printf '%s' "${HARBOR_PASSWORD}" | docker login registry.bstein.dev -u "${HARBOR_USERNAME}" --password-stdin
docker buildx build --platform linux/arm64 \
--provenance=false \
--tag registry.bstein.dev/bstein/soteria:${VERSION_TAG} \
--tag registry.bstein.dev/bstein/soteria:latest \
--push .
'''
}
}

View File

@ -1,16 +0,0 @@
# Default deployment permissions
This deployment uses the Longhorn backend. It reads inventory across namespaces
and updates only `soteria-policies` and `soteria-backup-usage` in its own namespace.
The empty Secret declarations create those records on first deployment; they
deliberately contain no data field, so application-written state is preserved.
The optional `soteria-restic` credential is readable by exact name only.
Changing the state or credential names also requires updating the Role. Do not
restore cluster-wide Secret access to accommodate another deployment.
The optional restic backend needs additional, explicitly approved Roles and
RoleBindings in each backup/restore target namespace: Job creation and the
credential-copy operations in `internal/k8s/jobs.go`. Those grants are not part
of this Longhorn deployment. Review credential distribution before enabling
restic; Kubernetes RBAC cannot restrict Secret creation by resource name.

View File

@ -8,6 +8,9 @@ rules:
- apiGroups: [""]
resources: ["persistentvolumeclaims", "persistentvolumes"]
verbs: ["get", "list"]
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "list", "create", "update", "delete"]
- apiGroups: ["batch"]
resources: ["jobs"]
verbs: ["get", "list"]
verbs: ["get", "list", "create"]

View File

@ -7,6 +7,5 @@ resources:
- serviceaccount.yaml
- clusterrole.yaml
- clusterrolebinding.yaml
- state-access.yaml
- deployment.yaml
- service.yaml

View File

@ -1,39 +0,0 @@
# The default Longhorn mode writes only its own policy and usage records.
apiVersion: v1
kind: Secret
metadata:
name: soteria-policies
type: Opaque
---
apiVersion: v1
kind: Secret
metadata:
name: soteria-backup-usage
type: Opaque
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: soteria-state
rules:
- apiGroups: [""]
resources: ["secrets"]
resourceNames: ["soteria-policies", "soteria-backup-usage"]
verbs: ["get", "update"]
- apiGroups: [""]
resources: ["secrets"]
resourceNames: ["soteria-restic"]
verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: soteria-state
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: soteria-state
subjects:
- kind: ServiceAccount
name: soteria
namespace: soteria