Skip to content

Commit ea850f7

Browse files
authored
feat: support preheat with self-signed certs (#3541)
Signed-off-by: Gaius <[email protected]>
1 parent 1afe79e commit ea850f7

File tree

14 files changed

+529
-819
lines changed

14 files changed

+529
-819
lines changed

deploy/docker-compose/docker-compose.yaml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ services:
2222
- MARIADB_DATABASE=manager
2323
- MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=yes
2424
healthcheck:
25-
test: ["CMD-SHELL", "mysqladmin status"]
25+
test: ["CMD-SHELL", "mysqladmin ping -h localhost"]
2626
interval: 1s
2727
timeout: 2s
2828
retries: 30
@@ -31,13 +31,13 @@ services:
3131

3232
manager:
3333
image: dragonflyoss/manager:latest
34-
container_name: dragonfly-manager
34+
container_name: manager
3535
depends_on:
3636
- redis
3737
- mysql
3838
restart: always
3939
volumes:
40-
- ./log/manager:/var/log/dragonfly/manager
40+
- ./log/manager:/var/log/dragonfly
4141
- ./config/manager.yaml:/etc/dragonfly/manager.yaml:ro
4242
healthcheck:
4343
test: ["CMD-SHELL", "/bin/grpc_health_probe -addr=:65003 || exit 1"]
@@ -48,60 +48,60 @@ services:
4848
- 65003:65003
4949
- 8080:8080
5050

51-
dfdaemon:
52-
image: dragonflyoss/dfdaemon:latest
51+
client:
52+
image: dragonflyoss/client:latest
5353
depends_on:
5454
- manager
5555
- scheduler
56-
- seed-peer
57-
container_name: dragonfly-seed-peer
56+
- seed-client
57+
container_name: client
5858
restart: always
5959
healthcheck:
60-
test: ["CMD-SHELL", "/bin/grpc_health_probe -addr=:65000 || exit 1"]
60+
test: ["CMD-SHELL", "/bin/grpc_health_probe -addr=unix:///var/run/dragonfly/dfdaemon.sock || exit 1"]
6161
interval: 1s
6262
timeout: 2s
6363
retries: 30
6464
volumes:
65-
- ./log/peer:/var/log/dragonfly/daemon
66-
- ./config/dfget.yaml:/etc/dragonfly/dfget.yaml:ro
65+
- ./log/client:/var/log/dragonfly
66+
- ./config/client.yaml:/etc/dragonfly/dfdaemon.yaml:ro
6767
ports:
68-
- 65000:65000
69-
- 65001:65001
70-
- 65002:65002
68+
- 4000:4000
69+
- 4001:4001
70+
- 4002:4002
7171

7272
scheduler:
7373
image: dragonflyoss/scheduler:latest
7474
depends_on:
7575
- manager
76-
container_name: dragonfly-scheduler
76+
container_name: scheduler
7777
restart: always
7878
healthcheck:
7979
test: ["CMD-SHELL", "/bin/grpc_health_probe -addr=:8002 || exit 1"]
8080
interval: 1s
8181
timeout: 2s
8282
retries: 30
8383
volumes:
84-
- ./log/scheduler:/var/log/dragonfly/scheduler
84+
- ./log/scheduler:/var/log/dragonfly
8585
- ./config/scheduler.yaml:/etc/dragonfly/scheduler.yaml:ro
8686
ports:
8787
- 8002:8002
8888

89-
seed-peer:
90-
image: dragonflyoss/dfdaemon:latest
89+
seed-client:
90+
image: dragonflyoss/client:latest
9191
depends_on:
9292
- manager
9393
- scheduler
94-
container_name: dragonfly-dfdaemon
94+
container_name: seed-client
9595
restart: always
9696
healthcheck:
97-
test: ["CMD-SHELL", "/bin/grpc_health_probe -addr=:65006 || exit 1"]
97+
test: ["CMD-SHELL", "/bin/grpc_health_probe -addr=unix:///var/run/dragonfly/dfdaemon.sock || exit 1"]
9898
interval: 1s
9999
timeout: 2s
100100
retries: 30
101101
volumes:
102-
- ./log/seed-peer:/var/log/dragonfly/daemon
103-
- ./config/seed-peer.yaml:/etc/dragonfly/dfget.yaml:ro
102+
- ./log/seed-client:/var/log/dragonfly
103+
- ./config/seed-client.yaml:/etc/dragonfly/dfdaemon.yaml:ro
104104
ports:
105-
- 65006:65006
106-
- 65007:65007
107-
- 65008:65008
105+
- 4010:4010
106+
- 4011:4011
107+
- 4012:4012

deploy/docker-compose/run.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -e
44

55
REPO=${REPO:-dragonflyoss}
66
TAG=${TAG:-latest}
7+
CLIENT_TAG=${CLIENT_TAG:-latest}
78

89
DIR=$(cd "$(dirname "$0")" && pwd)
910
cd $DIR
@@ -13,8 +14,8 @@ prepare(){
1314

1415
ip=${IP:-$(hostname -i)}
1516

16-
sed "s,__IP__,$ip," template/dfget.template.yaml > config/dfget.yaml
17-
sed "s,__IP__,$ip," template/seed-peer.template.yaml > config/seed-peer.yaml
17+
sed "s,__IP__,$ip," template/client.template.yaml > config/client.yaml
18+
sed "s,__IP__,$ip," template/seed-client.template.yaml > config/seed-client.yaml
1819
sed "s,__IP__,$ip," template/scheduler.template.yaml > config/scheduler.yaml
1920
sed "s,__IP__,$ip," template/manager.template.yaml > config/manager.yaml
2021
}
@@ -25,7 +26,7 @@ delete_container(){
2526

2627
echo try to clean old containers
2728
${RUNTIME} rm -f dragonfly-redis dragonfly-mysql dragonfly-manager dragonfly-scheduler \
28-
dragonfly-dfdaemon dragonfly-seed-peer
29+
dragonfly-client dragonfly-seed-client
2930
}
3031

3132
run_container(){
@@ -34,7 +35,7 @@ run_container(){
3435

3536
echo try to clean old containers
3637
${RUNTIME} rm -f dragonfly-redis dragonfly-mysql dragonfly-manager dragonfly-scheduler \
37-
dragonfly-dfdaemon dragonfly-seed-peer
38+
dragonfly-client dragonfly-seed-client
3839

3940
printf "create dragonfly-redis "
4041
${RUNTIME} run -d --name dragonfly-redis --restart=always -p 6379:6379 \
@@ -55,23 +56,23 @@ run_container(){
5556
-v ${DIR}/config/manager.yaml:/etc/dragonfly/manager.yaml \
5657
${REPO}/manager:${TAG}
5758

58-
printf "create dragonfly-seed-peer "
59-
${RUNTIME} run -d --name dragonfly-seed-peer --restart=always --net=host \
59+
printf "create dragonfly-seed-client "
60+
${RUNTIME} run -d --name dragonfly-seed-client --restart=always --net=host \
6061
-v /tmp/log/dragonfly:/var/log/dragonfly \
6162
-v ${DIR}/config/seed-peer.yaml:/etc/dragonfly/dfget.yaml \
62-
${REPO}/dfdaemon:${TAG}
63+
${REPO}/client:${CLIENT_TAG}
6364

6465
printf "create dragonfly-scheduler "
6566
${RUNTIME} run -d --name dragonfly-scheduler --restart=always --net=host \
6667
-v /tmp/log/dragonfly:/var/log/dragonfly \
6768
-v ${DIR}/config/scheduler.yaml:/etc/dragonfly/scheduler.yaml \
6869
${REPO}/scheduler:${TAG}
6970

70-
printf "create dragonfly-dfdaemon "
71-
${RUNTIME} run -d --name dragonfly-dfdaemon --restart=always --net=host \
71+
printf "create dragonfly-client "
72+
${RUNTIME} run -d --name dragonfly-client --restart=always --net=host \
7273
-v /tmp/log/dragonfly:/var/log/dragonfly \
7374
-v ${DIR}/config/dfget.yaml:/etc/dragonfly/dfget.yaml \
74-
${REPO}/dfdaemon:${TAG}
75+
${REPO}/client:${CLIENT_TAG}
7576
}
7677

7778
prepare
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# verbose prints log to stdout.
2+
verbose: true
3+
4+
log:
5+
# Specify the logging level [trace, debug, info, warn, error]
6+
level: info
7+
8+
# host is the host configuration for dfdaemon.
9+
host:
10+
## idc is the idc of the host.
11+
idc: ''
12+
## location is the location of the host.
13+
location: ''
14+
## hostname is the hostname of the host.
15+
# hostname: ""
16+
## ip is the advertise ip of the host.
17+
ip: __IP__
18+
19+
server:
20+
# pluginDir is the directory to store plugins.
21+
pluginDir: /var/lib/dragonfly/plugins/dfdaemon/
22+
# cacheDir is the directory to store cache files.
23+
cacheDir: /var/cache/dragonfly/dfdaemon/
24+
25+
download:
26+
server:
27+
# socketPath is the unix socket path for dfdaemon GRPC service.
28+
socketPath: /var/run/dragonfly/dfdaemon.sock
29+
# rateLimit is the default rate limit of the download speed in KiB/MiB/GiB per second, default is 10GiB/s.
30+
rateLimit: 10GiB
31+
# pieceTimeout is the timeout for downloading a piece from source.
32+
pieceTimeout: 30s
33+
# concurrentPieceCount is the number of concurrent pieces to download.
34+
concurrentPieceCount: 10
35+
36+
upload:
37+
server:
38+
# port is the port to the grpc server.
39+
port: 4000
40+
## ip is the listen ip of the grpc server.
41+
# ip: ""
42+
# disableShared indicates whether disable to share data for other peers.
43+
disableShared: false
44+
# rateLimit is the default rate limit of the upload speed in KiB/MiB/GiB per second, default is 10GiB/s.
45+
rateLimit: 10GiB
46+
47+
manager:
48+
# addrs is manager addresses.
49+
addrs:
50+
- http://__IP__:65003
51+
52+
scheduler:
53+
# announceInterval is the interval to announce peer to the scheduler.
54+
# Announcer will provide the scheduler with peer information for scheduling,
55+
# peer information includes cpu, memory, etc.
56+
announceInterval: 10s
57+
# scheduleTimeout is the timeout for scheduling. If the scheduling timesout, dfdaemon will back-to-source
58+
# download if enableBackToSource is true, otherwise dfdaemon will return download failed.
59+
scheduleTimeout: 30s
60+
# maxScheduleCount is the max count of schedule.
61+
maxScheduleCount: 5
62+
# enableBackToSource indicates whether enable back-to-source download, when the scheduling failed.
63+
enableBackToSource: true
64+
65+
dynconfig:
66+
# refreshInterval is the interval to refresh dynamic configuration from manager.
67+
refreshInterval: 1m
68+
69+
storage:
70+
# dir is the directory to store task's metadata and content.
71+
dir: /var/lib/dragonfly/
72+
# keep indicates whether keep the task's metadata and content when the dfdaemon restarts.
73+
keep: true
74+
# writeBufferSize is the buffer size for writing piece to disk, default is 128KB.
75+
writeBufferSize: 131072
76+
# readBufferSize is the buffer size for reading piece from disk, default is 128KB.
77+
readBufferSize: 131072
78+
79+
gc:
80+
# interval is the interval to do gc.
81+
interval: 900s
82+
policy:
83+
# taskTTL is the ttl of the task.
84+
taskTTL: 21600s
85+
# distHighThresholdPercent is the high threshold percent of the disk usage.
86+
# If the disk usage is greater than the threshold, dfdaemon will do gc.
87+
distHighThresholdPercent: 80
88+
# distLowThresholdPercent is the low threshold percent of the disk usage.
89+
# If the disk usage is less than the threshold, dfdaemon will stop gc.
90+
distLowThresholdPercent: 60
91+
92+
proxy:
93+
server:
94+
# port is the port to the proxy server.
95+
port: 4001
96+
## ip is the listen ip of the proxy server.
97+
# ip: ""
98+
## caCert is the root CA cert path with PEM format for the proxy server to generate the server cert.
99+
## If ca_cert is empty, proxy will generate a smaple CA cert by rcgen::generate_simple_self_signed.
100+
## When client requests via the proxy, the client should not verify the server cert and set
101+
## insecure to true. If ca_cert is not empty, proxy will sign the server cert with the CA cert. If openssl is installed,
102+
## you can use openssl to generate the root CA cert and make the system trust the root CA cert.
103+
## Then set the ca_cert and ca_key to the root CA cert and key path. Dfdaemon generates the server cert
104+
## and key, and signs the server cert with the root CA cert. When client requests via the proxy,
105+
## the proxy can intercept the request by the server cert.
106+
# caCert: ""
107+
## caKey is the root CA key path with PEM format for the proxy server to generate the server cert.
108+
## If ca_key is empty, proxy will generate a smaple CA key by rcgen::generate_simple_self_signed.
109+
## When client requests via the proxy, the client should not verify the server cert and set
110+
## insecure to true. If ca_key is not empty, proxy will sign the server cert with the CA cert. If openssl is installed,
111+
## you can use openssl to generate the root CA cert and make the system trust the root CA cert.
112+
## Then set the ca_cert and ca_key to the root CA cert and key path. Dfdaemon generates the server cert
113+
## and key, and signs the server cert with the root CA cert. When client requests via the proxy,
114+
## the proxy can intercept the request by the server cert.
115+
# caKey: ""
116+
# rules is the list of rules for the proxy server.
117+
# regex is the regex of the request url.
118+
# useTLS indicates whether use tls for the proxy backend.
119+
# redirect is the redirect url.
120+
# filteredQueryParams is the filtered query params to generate the task id.
121+
# When filter is ["Signature", "Expires", "ns"], for example:
122+
# http://example.com/xyz?Expires=e1&Signature=s1&ns=docker.io and http://example.com/xyz?Expires=e2&Signature=s2&ns=docker.io
123+
# will generate the same task id.
124+
# Default value includes the filtered query params of s3, gcs, oss, obs, cos.
125+
# `X-Dragonfly-Use-P2P` header can instead of the regular expression of the rule. If the value is "true",
126+
# the request will use P2P technology to distribute the content. If the value is "false",
127+
# but url matches the regular expression in rules. The request will also use P2P technology to distribute the content.
128+
rules:
129+
- regex: 'blobs/sha256.*'
130+
# useTLS: false
131+
# redirect: ""
132+
# filteredQueryParams: []
133+
registryMirror:
134+
# addr is the default address of the registry mirror. Proxy will start a registry mirror service for the
135+
# client to pull the image. The client can use the default address of the registry mirror in
136+
# configuration to pull the image. The `X-Dragonfly-Registry` header can instead of the default address
137+
# of registry mirror.
138+
addr: https://index.docker.io
139+
## certs is the client certs path with PEM format for the registry.
140+
## If registry use self-signed cert, the client should set the
141+
## cert for the registry mirror.
142+
# certs: ""
143+
# disableBackToSource indicates whether disable to download back-to-source when download failed.
144+
disableBackToSource: false
145+
# prefetch pre-downloads full of the task when download with range request.
146+
prefetch: false
147+
# readBufferSize is the buffer size for reading piece from disk, default is 32KB.
148+
readBufferSize: 32768
149+
150+
security:
151+
# enable indicates whether enable security.
152+
enable: false
153+
154+
metrics:
155+
server:
156+
# port is the port to the metrics server.
157+
port: 4002
158+
## ip is the listen ip of the metrics server.
159+
# ip: ""
160+
161+
## tracing is the tracing configuration for dfdaemon.
162+
# tracing:
163+
## addr is the address to report tracing log.
164+
# addr: ""

0 commit comments

Comments
 (0)