Server和client部署整理
This commit is contained in:
4
deploy/frr/.env
Normal file
4
deploy/frr/.env
Normal file
@@ -0,0 +1,4 @@
|
||||
# RTR server endpoint used by deploy/frr/frr.conf.template.
|
||||
RPKI_FRR_RPKI_HOST=127.0.0.1
|
||||
RPKI_FRR_RPKI_PORT=323
|
||||
RPKI_FRR_RPKI_PREFERENCE=1
|
||||
@@ -15,7 +15,10 @@ Reference:
|
||||
## Files
|
||||
|
||||
- `daemons.example`: sample `/etc/frr/daemons`
|
||||
- `frr.conf.example`: sample `/etc/frr/frr.conf`
|
||||
- `frr.conf.example`: static sample `/etc/frr/frr.conf`
|
||||
- `frr.conf.template`: Docker template used to generate `/etc/frr/frr.conf`
|
||||
- `entrypoint.sh`: renders `frr.conf.template` from environment variables before starting FRR
|
||||
- `.env`: default Docker environment values
|
||||
|
||||
## How to apply on an FRR host
|
||||
|
||||
@@ -44,21 +47,32 @@ contains VRPs, the RTR client path is working.
|
||||
From repository root:
|
||||
|
||||
```bash
|
||||
docker compose -f deploy/frr/docker-compose.yml up -d
|
||||
docker compose --env-file deploy/frr/.env -f deploy/frr/docker-compose.yml up -d
|
||||
docker exec -it frr-rpki-client vtysh -c "show rpki cache-connection"
|
||||
docker exec -it frr-rpki-client vtysh -c "show rpki prefix-table"
|
||||
```
|
||||
|
||||
The Docker example defaults to `127.0.0.1:323`. Override the RTR server
|
||||
endpoint with environment variables:
|
||||
|
||||
```bash
|
||||
RPKI_FRR_RPKI_HOST=10.0.0.12 \
|
||||
RPKI_FRR_RPKI_PORT=323 \
|
||||
docker compose --env-file deploy/frr/.env -f deploy/frr/docker-compose.yml up -d
|
||||
```
|
||||
|
||||
Stop:
|
||||
|
||||
```bash
|
||||
docker compose -f deploy/frr/docker-compose.yml down
|
||||
docker compose --env-file deploy/frr/.env -f deploy/frr/docker-compose.yml down
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- This setup targets RTR over TCP (`rpki cache tcp`).
|
||||
- Docker mode renders `frr.conf.template` into `/etc/frr/frr.conf` at startup.
|
||||
- Keep protocol-level conformance checks in Rust tests and
|
||||
`src/bin/rtr_debug_client`.
|
||||
- `network_mode: host` expects your RTR server to be reachable at
|
||||
`127.0.0.1:323` from the Docker host.
|
||||
- `network_mode: host` is kept for the minimal FRR container example, but the
|
||||
RTR server address is controlled by `RPKI_FRR_RPKI_HOST` and
|
||||
`RPKI_FRR_RPKI_PORT`.
|
||||
|
||||
@@ -12,7 +12,10 @@
|
||||
## 文件说明
|
||||
|
||||
- `daemons.example`:示例 `/etc/frr/daemons`
|
||||
- `frr.conf.example`:示例 `/etc/frr/frr.conf`
|
||||
- `frr.conf.example`:静态示例 `/etc/frr/frr.conf`
|
||||
- `frr.conf.template`:Docker 启动时生成 `/etc/frr/frr.conf` 的模板
|
||||
- `entrypoint.sh`:启动 FRR 前根据环境变量渲染 `frr.conf.template`
|
||||
- `.env`:Docker 示例使用的默认环境变量
|
||||
|
||||
## 在 FRR 主机上应用
|
||||
|
||||
@@ -40,15 +43,23 @@ vtysh -c "show rpki prefix-table"
|
||||
在仓库根目录执行:
|
||||
|
||||
```bash
|
||||
docker compose -f deploy/frr/docker-compose.yml up -d
|
||||
docker compose --env-file deploy/frr/.env -f deploy/frr/docker-compose.yml up -d
|
||||
docker exec -it frr-rpki-client vtysh -c "show rpki cache-connection"
|
||||
docker exec -it frr-rpki-client vtysh -c "show rpki prefix-table"
|
||||
```
|
||||
|
||||
Docker 示例默认连接 `127.0.0.1:323`。如果 RTR Server 在其他地址,可以通过环境变量覆盖:
|
||||
|
||||
```bash
|
||||
RPKI_FRR_RPKI_HOST=10.0.0.12 \
|
||||
RPKI_FRR_RPKI_PORT=323 \
|
||||
docker compose --env-file deploy/frr/.env -f deploy/frr/docker-compose.yml up -d
|
||||
```
|
||||
|
||||
停止:
|
||||
|
||||
```bash
|
||||
docker compose -f deploy/frr/docker-compose.yml down
|
||||
docker compose --env-file deploy/frr/.env -f deploy/frr/docker-compose.yml down
|
||||
```
|
||||
|
||||
## 可测试范围
|
||||
@@ -68,4 +79,5 @@ docker compose -f deploy/frr/docker-compose.yml down
|
||||
## 说明
|
||||
|
||||
- 当前示例主要针对 RTR over TCP(`rpki cache tcp`)
|
||||
- `network_mode: host` 模式下,容器内访问 `127.0.0.1:323` 指向 Docker Host,请确保本机 RTR Server 可达
|
||||
- Docker 模式会在启动时把 `frr.conf.template` 渲染为 `/etc/frr/frr.conf`
|
||||
- `network_mode: host` 仍用于最小化 FRR 容器示例,但 RTR Server 地址由 `RPKI_FRR_RPKI_HOST` 和 `RPKI_FRR_RPKI_PORT` 控制
|
||||
|
||||
@@ -5,6 +5,12 @@ services:
|
||||
restart: unless-stopped
|
||||
network_mode: host
|
||||
privileged: true
|
||||
environment:
|
||||
RPKI_FRR_RPKI_HOST: "${RPKI_FRR_RPKI_HOST:-127.0.0.1}"
|
||||
RPKI_FRR_RPKI_PORT: "${RPKI_FRR_RPKI_PORT:-323}"
|
||||
RPKI_FRR_RPKI_PREFERENCE: "${RPKI_FRR_RPKI_PREFERENCE:-1}"
|
||||
entrypoint: ["/bin/sh", "/config/entrypoint.sh"]
|
||||
volumes:
|
||||
- ./frr/daemons.example:/etc/frr/daemons:ro
|
||||
- ./frr/frr.conf.example:/etc/frr/frr.conf:ro
|
||||
- ./daemons.example:/etc/frr/daemons:ro
|
||||
- ./frr.conf.template:/config/frr.conf.template:ro
|
||||
- ./entrypoint.sh:/config/entrypoint.sh:ro
|
||||
|
||||
24
deploy/frr/entrypoint.sh
Normal file
24
deploy/frr/entrypoint.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
: "${RPKI_FRR_RPKI_HOST:=127.0.0.1}"
|
||||
: "${RPKI_FRR_RPKI_PORT:=323}"
|
||||
: "${RPKI_FRR_RPKI_PREFERENCE:=1}"
|
||||
: "${RPKI_FRR_CONFIG_TEMPLATE_PATH:=/config/frr.conf.template}"
|
||||
: "${RPKI_FRR_CONFIG_PATH:=/etc/frr/frr.conf}"
|
||||
|
||||
escape_sed() {
|
||||
printf '%s' "$1" | sed 's/[&|\\]/\\&/g'
|
||||
}
|
||||
|
||||
host="$(escape_sed "${RPKI_FRR_RPKI_HOST}")"
|
||||
port="$(escape_sed "${RPKI_FRR_RPKI_PORT}")"
|
||||
preference="$(escape_sed "${RPKI_FRR_RPKI_PREFERENCE}")"
|
||||
|
||||
sed \
|
||||
-e "s|\${RPKI_FRR_RPKI_HOST}|${host}|g" \
|
||||
-e "s|\${RPKI_FRR_RPKI_PORT}|${port}|g" \
|
||||
-e "s|\${RPKI_FRR_RPKI_PREFERENCE}|${preference}|g" \
|
||||
"${RPKI_FRR_CONFIG_TEMPLATE_PATH}" > "${RPKI_FRR_CONFIG_PATH}"
|
||||
|
||||
exec /usr/lib/frr/docker-start
|
||||
22
deploy/frr/frr.conf.template
Normal file
22
deploy/frr/frr.conf.template
Normal file
@@ -0,0 +1,22 @@
|
||||
frr version 10.2
|
||||
frr defaults traditional
|
||||
hostname rpki-lab
|
||||
service integrated-vtysh-config
|
||||
!
|
||||
debug rpki
|
||||
!
|
||||
rpki
|
||||
rpki polling_period 10
|
||||
rpki timeout 10
|
||||
rpki retry_interval 10
|
||||
rpki expire_interval 7200
|
||||
rpki cache tcp ${RPKI_FRR_RPKI_HOST} ${RPKI_FRR_RPKI_PORT} preference ${RPKI_FRR_RPKI_PREFERENCE}
|
||||
exit
|
||||
!
|
||||
router bgp 65001
|
||||
bgp router-id 192.0.2.1
|
||||
!
|
||||
address-family ipv4 unicast
|
||||
exit-address-family
|
||||
!
|
||||
line vty
|
||||
Reference in New Issue
Block a user