-
Notifications
You must be signed in to change notification settings - Fork 608
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
YQ kqprun added scripts for starting prometheus and connector #14816
base: main
Are you sure you want to change the base?
YQ kqprun added scripts for starting prometheus and connector #14816
Conversation
🟢 |
⚪ Test history | Ya make output | Test bloat
🟢 |
⚪ Test history | Ya make output | Test bloat
🟢 |
⚪ Test history | Ya make output | Test bloat
🟢 |
⚪ Test history | Ya make output | Test bloat
🟢 |
|
||
ydb: | ||
<<: *data_source_default_var | ||
use_underlay_network_for_dedicated_databases: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mode: MODE_QUERY_SERVICE_NATIVE
see ydb/library/yql/providers/generic/connector/tests/fq-connector-go/fq-connector-go.yaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ну вот о чём и речь - начинаются проблемы консистентности конфигов, их обновления, тогда как об этом вообще не надо думать. Рабочий конфиг идёт прямо в образе, и не надо его трогать без надобности
|
||
SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) | ||
|
||
cp ${2:-"$SCRIPT_DIR/configuration/connector_config.yaml"} ./connector_config.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"${2:-...}"
SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) | ||
|
||
cp ${2:-"$SCRIPT_DIR/configuration/connector_config.yaml"} ./connector_config.yaml | ||
sed -i "s/\${TARGET_PORT}/$1/g" ./connector_config.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... or drop cp
line above and
sed "s/.../" "${2:-...}" > ./connector_config.yaml
in single step
cp ${2:-"$SCRIPT_DIR/configuration/connector_config.yaml"} ./connector_config.yaml | ||
sed -i "s/\${TARGET_PORT}/$1/g" ./connector_config.yaml | ||
|
||
docker run --rm --name=fq-connector-go-$1 --network host -v ./connector_config.yaml:/opt/ydb/cfg/fq-connector-go.yaml ghcr.io/ydb-platform/fq-connector-go:latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Не совсем понятно, зачем коннектору
--network=host
? Ведь вряд ли кто-то будет ходить в коннектор извне, кроме kqprun, который будет работать на той же машине, что и контейнер с коннектором. Да даже если надо ходить - всё равно стандартный паттерн этоdocker run -d -p <host_ip>:<host_port>:<container_port> <image_name>
. Можешь попробовать развернуть какой-нибудь Nginx и сходить на него с другой машины. Если не заработает - это значит, что какие-то яндексовские велосипеды в области файрволла блокируют сетевую доступность, и надо просить Вадима их поправить. Поэтому ты можешь использовать просто стандартные настройки сети (т. е. вообще не указывать параметр--network
), но вместо этого указать маппинг порта коннектора в тот, что тебе нужен, типаdocker run -p внешний_порт:внутренний_порт ...
. Когда всё правильно настроено на хосте,--network=host
никогда не нужен. - Исходя из п. 1, тебе не нужен кастомный конфиг коннектора: не нужно его рендерить из шаблона и не нужно монтировать в контейнер. Внутри образа с коннектором уже есть дефолтный конфиг, и, как мне кажется, его здесь будет вполне достаточно.
cp ${3:-"$SCRIPT_DIR/configuration/prometheus_config.yaml"} ./prometheus_config.yaml | ||
sed -i "s/\${TARGET_PORT}/$1/g" ./prometheus_config.yaml | ||
|
||
docker run --rm --name=prometeus-$1 --network host -v ./prometheus_config.yaml:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml --web.listen-address=:$2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Всё вышесказанное относится и к контейнеру с Prometheus в том числе.
cp ${3:-"$SCRIPT_DIR/configuration/prometheus_config.yaml"} ./prometheus_config.yaml | ||
sed -i "s/\${TARGET_PORT}/$1/g" ./prometheus_config.yaml | ||
|
||
docker run --rm --name=prometeus-$1 --network host -v ./prometheus_config.yaml:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml --web.listen-address=:$2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docker run --rm --name=prometeus-$1 --network host -v ./prometheus_config.yaml:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml --web.listen-address=:$2 | |
docker run --rm --name=prometheus-$1 --network host -v ./prometheus_config.yaml:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml --web.listen-address=:$2 |
if netstat -tuln | grep ":$1"; then | ||
echo "Can not start connector on port $1, port already in use" | ||
exit -1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я бы сказал, что это лишняя работа. Если хостовый порт занят, docker и так выдаст человекочитаемую ошибку.
@@ -0,0 +1,38 @@ | |||
#!/usr/bin/env bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Кмк, не хватает скриптов, которые будут гасить все эти контейнеры. Ведь у контейнеров, как я вижу, ещё и имена с переменными суффиксами.
Возможно, тебе более удобным покажется такой подход. Делаешь docker-compose.yml
с нужными тебе переменными параметрами:
version: '3.8'
services:
web:
image: my_service:my_tag
ports:
- "${HOST_PORT}:80"
Далее в баш скриптах просто вызов с указанием переменных окружения:
# запуск
HOST_PORT=12345 docker compose up -d web
# остановка
docker compose down -v web
Так можно параметризировать самые разнообразные настройки, в том числе имя контейнера. Баш скрипты становятся лаконичными, а, всё, что связано с Docker, уходит в docker-compose.yaml
, что является стандартным и переносимым способом настройки окружений.
Changelog entry
Added scripts for starting prometheus and connector in kqprun
Changelog category
Description for reviewers