Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split s3 server certificate out of tasks secrets #618

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ansible/roles/local-secrets-archive/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
become: false
run_once: yes
shell: |
tar -C $XDG_RUNTIME_DIR/ci-secrets -hz --hard-dereference -c webhook s3-keys tasks > $XDG_RUNTIME_DIR/ci-secrets.tar.gz
tar -C $XDG_RUNTIME_DIR/ci-secrets -hz --hard-dereference -c webhook s3-keys s3-server tasks > $XDG_RUNTIME_DIR/ci-secrets.tar.gz
2 changes: 1 addition & 1 deletion local-s3/install-s3-service
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ systemctl stop cockpit-s3.service || true

if [ -z "${DISABLE_TLS:-}" ]; then

CERT_VOLS="-v $SECRETS/tasks/s3-server.key:/root/.minio/certs/private.key:ro -v $SECRETS/tasks/s3-server.pem:/root/.minio/certs/public.crt:ro"
CERT_VOLS="-v $SECRETS/s3-server/s3-server.key:/root/.minio/certs/private.key:ro -v $SECRETS/s3-server/s3-server.pem:/root/.minio/certs/public.crt:ro"
PORT=443
PROTOCOL=https
else
Expand Down
14 changes: 14 additions & 0 deletions tasks/build-secrets
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ for f in $(find -maxdepth 1 -type f -o -type l); do
printf ' %s: %s\n' "${f#./}" "$(base64 --wrap=0 $f)"
done

# local S3 image cache server secrets
cat <<EOF
---
apiVersion: v1
kind: Secret
metadata:
name: cockpit-s3-server-secrets
data:
EOF
cd "$BASE/s3-server"
for f in $(find -maxdepth 1 -type f -o -type l); do
printf ' %s: %s\n' "${f#./}" "$(base64 --wrap=0 $f)"
done

# webhook secrets
cat <<EOF

Expand Down
17 changes: 11 additions & 6 deletions test/test_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Config:
webhook: Path
tasks: Path
s3_keys: Path
s3_server: Path


@pytest.fixture(scope='session')
Expand Down Expand Up @@ -68,16 +69,20 @@ def config(tmp_path_factory) -> Config:
# default to dummy token, tests need to opt into real one with user_github_token
(config.webhook / '.config--github-token').write_text('0123abc')

# tasks secrets
config.tasks = config.secrets / 'tasks'
config.tasks.mkdir()
subprocess.run(ROOT_DIR / 'local-s3/generate-s3-cert.sh', cwd=config.tasks, check=True)
# minio S3 certificate
config.s3_server = config.secrets / 's3-server'
config.s3_server.mkdir()
subprocess.run(ROOT_DIR / 'local-s3/generate-s3-cert.sh', cwd=config.s3_server, check=True)

# minio S3 key
config.s3_keys = config.secrets / 's3-keys'
config.s3_keys.mkdir()
(config.s3_keys / 'localhost.localdomain').write_text('cockpituous foobarfoo')

# tasks secrets: none right now, but do create an empty directory to keep production structure
config.tasks = config.secrets / 'tasks'
config.tasks.mkdir()

# need to make secrets world-readable, as containers run as non-root
subprocess.run(['chmod', '-R', 'go+rX', configdir], check=True)

Expand Down Expand Up @@ -139,8 +144,8 @@ def pod(config: Config, pytestconfig) -> Iterator[PodData]:
# minio S3 store
data.s3 = f'cockpituous-s3-{test_instance}'
subprocess.run(['podman', 'run', '-d', '--name', data.s3, f'--pod={data.pod}', *launch_args,
'-v', f'{config.tasks}/s3-server.key:/root/.minio/certs/private.key:ro',
'-v', f'{config.tasks}/s3-server.pem:/root/.minio/certs/public.crt:ro',
'-v', f'{config.s3_server}/s3-server.key:/root/.minio/certs/private.key:ro',
'-v', f'{config.s3_server}/s3-server.pem:/root/.minio/certs/public.crt:ro',
'-e', 'MINIO_ROOT_USER=minioadmin',
'-e', 'MINIO_ROOT_PASSWORD=minioadmin',
'quay.io/minio/minio', 'server', '/data', '--console-address', ':9001'],
Expand Down