forked from mtusi2026/mtusi2026lab5
chore(migrate) moved codebase from lab4
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
# Инфраструктура студента
|
||||
|
||||
Здесь разместите конфигурации выбранных сервисов; основную топологию — в корневом compose.yaml/stack.yaml. `compose.example.yaml` — только worksheet ролей и намеренно не запускается. `contracts/infrastructure.json` задаёт минимальные роли, не готовые образы/пароли.
|
||||
|
||||
В REPORT.md сопоставьте роль → service name → версия/digest → health/readiness → volume → сеть/порт → способ передачи credentials. Приведите bootstrap (schema, bucket, broker topology, а с lab6 provisioning) и безопасное повторение этих команд.
|
||||
|
||||
Приложение строится из исходников. Не используйте заранее существующий образ преподавательского сервера вместо своей реализации. Restart hook перезапускает все соответствующие stores с volumes; failover hook останавливает только заданную API-реплику.
|
||||
@@ -0,0 +1,41 @@
|
||||
global
|
||||
log stdout format raw local0
|
||||
maxconn 4096
|
||||
|
||||
defaults
|
||||
log global
|
||||
mode http
|
||||
option httplog
|
||||
option dontlognull
|
||||
timeout connect 2s
|
||||
timeout client 30s
|
||||
timeout server 30s
|
||||
timeout http-request 10s
|
||||
timeout http-keep-alive 30s
|
||||
retries 2
|
||||
option redispatch
|
||||
|
||||
resolvers docker
|
||||
nameserver dns 127.0.0.11:53
|
||||
resolve_retries 3
|
||||
timeout resolve 1s
|
||||
timeout retry 1s
|
||||
|
||||
frontend api_frontend
|
||||
bind *:8080
|
||||
default_backend api
|
||||
|
||||
backend api
|
||||
balance roundrobin
|
||||
option httpchk GET /health/ready
|
||||
http-check expect status 200
|
||||
default-server check inter 1s fastinter 500ms downinter 1s fall 2 rise 2
|
||||
# 16 slots is thus the upper bound for API_REPLICAS
|
||||
server-template api 16 api:8080 resolvers docker init-addr last,libc,none
|
||||
|
||||
frontend stats
|
||||
bind *:8404
|
||||
http-request use-service prometheus-exporter if { path /metrics }
|
||||
stats enable
|
||||
stats uri /stats
|
||||
stats refresh 5s
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:GetBucketLocation",
|
||||
"s3:ListBucket"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::__BUCKET__"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:GetObject",
|
||||
"s3:PutObject",
|
||||
"s3:DeleteObject"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::__BUCKET__/attachments/*"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
# Idempotent RustFS bootstrap: create the private bucket, a scoped IAM user and
|
||||
# a policy that only allows object operations under the attachments/ prefix.
|
||||
set -eu
|
||||
|
||||
: "${S3_ENDPOINT:?S3_ENDPOINT is required}"
|
||||
: "${S3_BUCKET:?S3_BUCKET is required}"
|
||||
: "${S3_ROOT_ACCESS_KEY:?S3_ROOT_ACCESS_KEY is required}"
|
||||
: "${S3_ROOT_SECRET_KEY:?S3_ROOT_SECRET_KEY is required}"
|
||||
: "${S3_ACCESS_KEY_ID:?S3_ACCESS_KEY_ID is required}"
|
||||
: "${S3_SECRET_ACCESS_KEY:?S3_SECRET_ACCESS_KEY is required}"
|
||||
: "${S3_APP_USER:?S3_APP_USER is required}"
|
||||
: "${S3_APP_POLICY:?S3_APP_POLICY is required}"
|
||||
: "${S3_POLICY_TEMPLATE:?S3_POLICY_TEMPLATE is required}"
|
||||
|
||||
# AGENT: rc stores its alias file in $HOME. The image runs as an unprivileged
|
||||
# user, so point HOME at a writable temporary directory.
|
||||
export HOME="${HOME:-/tmp}"
|
||||
ALIAS=local
|
||||
|
||||
rc alias set "$ALIAS" "$S3_ENDPOINT" "$S3_ROOT_ACCESS_KEY" "$S3_ROOT_SECRET_KEY" >/dev/null
|
||||
|
||||
# Compose waits for the RustFS healthcheck, but the S3 API can become ready a
|
||||
# moment later. A bounded wait keeps this service deterministic without hiding
|
||||
# a genuinely broken deployment.
|
||||
attempt=0
|
||||
until rc ready "$ALIAS" >/dev/null 2>&1; do
|
||||
attempt=$((attempt + 1))
|
||||
if [ "$attempt" -ge 60 ]; then
|
||||
echo "RustFS did not become ready within 60 seconds" >&2
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
rc bucket create -p "$ALIAS/$S3_BUCKET" >/dev/null
|
||||
# Explicitly converge anonymous access to private. This is both a policy
|
||||
# assertion and a guard against a bucket created public by a previous run.
|
||||
rc bucket anonymous set private "$ALIAS/$S3_BUCKET" >/dev/null
|
||||
|
||||
# The policy is rendered from a template because the bucket name is part of
|
||||
# every resource ARN and is configurable in .env.
|
||||
sed "s|__BUCKET__|$S3_BUCKET|g" "$S3_POLICY_TEMPLATE" > /tmp/api-policy.json
|
||||
|
||||
# All three admin calls are replaces/updates, not creates that fail on a second
|
||||
# run: policy create replaces the named document, user add updates the secret,
|
||||
# and policy attach is idempotent.
|
||||
rc admin policy create "$ALIAS" "$S3_APP_POLICY" /tmp/api-policy.json >/dev/null
|
||||
rc admin user add "$ALIAS" "$S3_APP_USER" "$S3_SECRET_ACCESS_KEY" >/dev/null
|
||||
rc admin policy attach "$ALIAS" "$S3_APP_POLICY" --user "$S3_APP_USER" >/dev/null
|
||||
|
||||
echo "S3 bootstrap complete: bucket=$S3_BUCKET user=$S3_APP_USER policy=$S3_APP_POLICY"
|
||||
Reference in New Issue
Block a user