ЛР 7: безопасность, mTLS и OpenBao на оценку 3
Skeleton contracts / contracts (pull_request) Blocked by required conditions
Skeleton contracts / contracts (pull_request) Blocked by required conditions
This commit is contained in:
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
case "${1:-}" in
|
||||
app1|app2)
|
||||
docker compose stop --timeout 3 "$1"
|
||||
exit
|
||||
;;
|
||||
"")
|
||||
;;
|
||||
*)
|
||||
printf '%s\n' 'Expected app1 or app2' >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
: "${TARGET_INSTANCE_ID:?Expected target API instance ID}"
|
||||
for replica in app1 app2; do
|
||||
headers=$(docker compose exec -T nginx curl -fsS --noproxy '*' --max-time 3 \
|
||||
--cacert /run/ca/ca.crt --cert /run/identity/lb.crt --key /run/identity/lb.key \
|
||||
--connect-to "api.internal:8443:$replica:8443" \
|
||||
-D - -o /dev/null https://api.internal:8443/health/live)
|
||||
instance=$(printf '%s\n' "$headers" | awk 'tolower($1)=="x-instance-id:" {print $2}' | tr -d '\r')
|
||||
if [ "$instance" = "$TARGET_INSTANCE_ID" ]; then
|
||||
docker compose stop --timeout 3 "$replica"
|
||||
exit
|
||||
fi
|
||||
done
|
||||
printf '%s\n' 'Target API instance was not found' >&2
|
||||
exit 1
|
||||
Reference in New Issue
Block a user