Compare commits
2 Commits
f167d7d17d
...
596b2df8e6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
596b2df8e6 | ||
|
|
3c0c868708 |
@ -1,6 +0,0 @@
|
||||
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
66
Jenkinsfile
vendored
@ -18,6 +18,7 @@ spec:
|
||||
operator: NotIn
|
||||
values:
|
||||
- titan-06
|
||||
- titan-08
|
||||
preferredDuringSchedulingIgnoredDuringExecution:
|
||||
- weight: 100
|
||||
preference:
|
||||
@ -38,22 +39,22 @@ spec:
|
||||
jenkins/jenkins-jenkins-agent: "true"
|
||||
containers:
|
||||
- name: builder
|
||||
image: registry.bstein.dev/bstein/docker:27
|
||||
image: gcr.io/kaniko-project/executor@sha256:c3109d5926a997b100c4343944e06c6b30a6804b2f9abe0994d3de6ef92b028e
|
||||
command:
|
||||
- cat
|
||||
- /busybox/cat
|
||||
tty: true
|
||||
env:
|
||||
- name: DOCKER_HOST
|
||||
value: tcp://localhost:2375
|
||||
- name: DOCKER_TLS_CERTDIR
|
||||
value: ""
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 1Gi
|
||||
limits:
|
||||
cpu: 1500m
|
||||
memory: 2Gi
|
||||
volumeMounts:
|
||||
- name: workspace-volume
|
||||
mountPath: /home/jenkins/agent
|
||||
- name: docker-config-writable
|
||||
mountPath: /root/.docker
|
||||
- name: harbor-config
|
||||
mountPath: /docker-config
|
||||
mountPath: /kaniko/.docker
|
||||
- name: tester
|
||||
image: registry.bstein.dev/bstein/golang:1.25-bookworm
|
||||
command:
|
||||
@ -73,12 +74,6 @@ 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: {}
|
||||
"""
|
||||
@ -523,7 +518,7 @@ PY
|
||||
expression { return params.PUBLISH_IMAGES }
|
||||
}
|
||||
steps {
|
||||
container('builder') {
|
||||
container('tester') {
|
||||
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()
|
||||
@ -536,24 +531,6 @@ 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 }
|
||||
@ -563,13 +540,20 @@ PY
|
||||
withCredentials([usernamePassword(credentialsId: 'harbor-robot', usernameVariable: 'HARBOR_USERNAME', passwordVariable: 'HARBOR_PASSWORD')]) {
|
||||
sh '''
|
||||
set -eu
|
||||
set +x
|
||||
VERSION_TAG=$(cut -d= -f2 build.env)
|
||||
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 .
|
||||
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
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
16
deploy/NOTES.md
Normal file
16
deploy/NOTES.md
Normal file
@ -0,0 +1,16 @@
|
||||
# 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.
|
||||
@ -8,9 +8,6 @@ rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["persistentvolumeclaims", "persistentvolumes"]
|
||||
verbs: ["get", "list"]
|
||||
- apiGroups: [""]
|
||||
resources: ["secrets"]
|
||||
verbs: ["get", "list", "create", "update", "delete"]
|
||||
- apiGroups: ["batch"]
|
||||
resources: ["jobs"]
|
||||
verbs: ["get", "list", "create"]
|
||||
verbs: ["get", "list"]
|
||||
|
||||
@ -7,5 +7,6 @@ resources:
|
||||
- serviceaccount.yaml
|
||||
- clusterrole.yaml
|
||||
- clusterrolebinding.yaml
|
||||
- state-access.yaml
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
|
||||
39
deploy/state-access.yaml
Normal file
39
deploy/state-access.yaml
Normal file
@ -0,0 +1,39 @@
|
||||
# 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
|
||||
Loading…
x
Reference in New Issue
Block a user