Files
pages/deploy/kubernetes/exhibition/storage-check.yaml.example
T
Anya Tokugawa 4a863fe63c chore(exhibition): preserve deployment and synthetic demo tooling
Separate one-time bootstrap, historical deployment examples and local validation. Document final hostname and historical status; exclude credentials and runtime data.
2026-11-30 23:14:24 +09:00

91 lines
3.7 KiB
Plaintext

# Run only in the assigned exhibit-anya namespace after release verification.
# kubectl -n exhibit-anya apply --dry-run=server -f storage-check.yaml.example
# No database or existing application data is opened by this job.
apiVersion: batch/v1
kind: Job
metadata:
name: pageswiki-storage-check
spec:
backoffLimit: 0
activeDeadlineSeconds: 120
ttlSecondsAfterFinished: 3600
template:
spec:
restartPolicy: Never
automountServiceAccountToken: false
securityContext:
runAsNonRoot: true
runAsUser: 10001
runAsGroup: 10001
seccompProfile:
type: RuntimeDefault
containers:
- name: check
image: python:3.13-alpine
imagePullPolicy: IfNotPresent
command: [python3, -c]
args:
- |
import hashlib, json, os, pathlib, tempfile
mount = None
for line in pathlib.Path('/proc/self/mountinfo').read_text().splitlines():
before, after = line.split(' - ', 1)
fields, detail = before.split(), after.split()
if fields[4] == '/check':
mount = (detail[0], set(fields[5].split(',')) | set(detail[2].split(',')))
if mount is None:
raise RuntimeError('PVC mount was not found')
fs, options = mount
if fs in ('nfs', 'nfs4') and ('hard' not in options or options & {'soft', 'softerr', 'softreval'}):
raise RuntimeError('NFS hard mount required; unsafe or unknown options')
root = pathlib.Path(tempfile.mkdtemp(prefix='.pageswiki-storage-check-', dir='/check'))
directory = os.open(root, os.O_RDONLY | os.O_DIRECTORY)
payload = b'PagesWiki isolated storage verification\n'
try:
with (root / 'source').open('xb') as f:
f.write(payload)
f.flush()
os.fsync(f.fileno())
os.link(root / 'source', root / 'published')
try:
os.link(root / 'source', root / 'published')
except FileExistsError:
pass
else:
raise RuntimeError('link publication replaced an existing entry')
os.fsync(directory)
os.rename(root / 'source', root / 'renamed')
os.fsync(directory)
expected = hashlib.sha256(payload).digest()
for name in ('published', 'renamed'):
if hashlib.sha256((root / name).read_bytes()).digest() != expected:
raise RuntimeError('content mismatch')
print(json.dumps({'result': 'passed', 'filesystem': fs,
'hard_mount': 'hard' in options,
'server_durability': 'not verified by this client-side test'}))
finally:
for name in ('source', 'published', 'renamed'):
(root / name).unlink(missing_ok=True)
os.fsync(directory)
os.close(directory)
root.rmdir()
resources:
requests:
cpu: 100m
memory: 64Mi
limits:
cpu: 250m
memory: 128Mi
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: [ALL]
volumeMounts:
- name: data
mountPath: /check
volumes:
- name: data
persistentVolumeClaim:
claimName: pageswiki-data