Skip to content

Commit d8a45e6

Browse files
committed
chore: merge main
Signed-off-by: santong <[email protected]>
2 parents 230131c + 5ae1888 commit d8a45e6

File tree

7 files changed

+260
-95
lines changed

7 files changed

+260
-95
lines changed

client/daemon/peer/peertask_base.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ func (pt *peerTask) waitFailedPiece() (int32, bool) {
626626
return -1, false
627627
case failed := <-pt.failedPieceCh:
628628
pt.Warnf("download piece/%d failed, retry", failed)
629-
return -1, true
629+
return failed, true
630630
}
631631
}
632632

client/daemon/proxy/proxy_sni.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ import (
2626
"time"
2727

2828
"github.com/golang/groupcache/lru"
29+
"github.com/pkg/errors"
2930

3031
logger "d7y.io/dragonfly/v2/internal/dflog"
3132
)
3233

3334
func (proxy *Proxy) ServeSNI(l net.Listener) error {
3435
if proxy.cert == nil {
35-
return fmt.Errorf("empty cert")
36+
return errors.New("empty cert")
3637
}
3738
if proxy.cert.Leaf != nil && proxy.cert.Leaf.IsCA {
3839
logger.Infof("hijack sni https request with CA <%s>", proxy.cert.Leaf.Subject.CommonName)

docs/en/ecosystem/Kubernetes-with-Dragonfly.md

Lines changed: 136 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,137 @@ Table of contents:
1111

1212
## Helm Support
1313

14+
### Runtime Configuration Guide for Dragonfly Helm Chart
15+
16+
When enable runtime configuration in dragonfly, you can skip [Configure Runtime](#configure-runtime-manually) manually.
17+
18+
#### 1. Docker
19+
20+
Dragonfly helm supports config docker automatically.
21+
22+
Config cases:
23+
24+
**Case 1: Implicit registries support**
25+
26+
Chart customize values.yaml:
27+
```yaml
28+
containerRuntime:
29+
docker:
30+
enable: true
31+
# -- Inject domains into /etc/hosts to force redirect traffic to dfdaemon.
32+
# Caution: This feature need dfdaemon to implement SNI Proxy, confirm image tag is greater than v0.4.0.
33+
# When use certs and inject hosts in docker, no necessary to restart docker daemon.
34+
injectHosts: true
35+
registryDomains:
36+
- "harbor.example.com"
37+
- "harbor.example.net"
38+
```
39+
40+
This config enables docker pulling images from registries `harbor.example.com` and `harbor.example.net` via Dragonfly.
41+
When deploying Dragonfly with above config, it's unnecessary to restart docker daemon.
42+
43+
Limitations:
44+
* Only support implicit registries
45+
46+
**Case 2: Arbitrary registries support**
47+
48+
Chart customize values.yaml:
49+
```yaml
50+
containerRuntime:
51+
docker:
52+
enable: true
53+
# -- Restart docker daemon to redirect traffic to dfdaemon
54+
# When containerRuntime.docker.restart=true, containerRuntime.docker.injectHosts and containerRuntime.registry.domains is ignored.
55+
# If did not want restart docker daemon, keep containerRuntime.docker.restart=false and containerRuntime.docker.injectHosts=true.
56+
restart: true
57+
```
58+
59+
This config enables docker pulling images from arbitrary registries via Dragonfly.
60+
When deploying Dragonfly with above config, dfdaemon will restart docker daemon.
61+
62+
Limitations:
63+
* Must enable live-restore feature in docker
64+
* Need restart docker daemon
65+
66+
#### 2. Containerd
67+
68+
The config of containerd has two version with complicated fields. These are many cases to consider:
69+
70+
**Case 1: Version 2 config with config_path**
71+
72+
There is `config_path` in `/etc/containerd/config.toml`:
73+
```toml
74+
[plugins."io.containerd.grpc.v1.cri".registry]
75+
config_path = "/etc/containerd/certs.d"
76+
```
77+
78+
This case is very simple to enable multiple registry mirrors support.
79+
80+
Chart customize values.yaml:
81+
```yaml
82+
containerRuntime:
83+
containerd:
84+
enable: true
85+
```
86+
87+
**Case 2: Version 2 config without config_path**
88+
89+
* Option 1 - Allow charts to inject config_path and restart containerd.
90+
91+
This option also enable multiple registry mirrors support.
92+
93+
> Caution: if there are already many other mirror config in config.toml, should not use this option, or migrate your config with `config_path`.
94+
95+
Chart customize values.yaml:
96+
```yaml
97+
containerRuntime:
98+
containerd:
99+
enable: true
100+
injectConfigPath: true
101+
```
102+
103+
* Option 2 - Just mirror only one registry which `dfdaemon.config.proxy.registryMirror.url` is
104+
105+
Chart customize values.yaml:
106+
107+
```yaml
108+
containerRuntime:
109+
containerd:
110+
enable: true
111+
```
112+
113+
**Case 3: Version 1**
114+
115+
With version 1 config.toml, only support the registry which `dfdaemon.config.proxy.registryMirror.url` is.
116+
117+
Chart customize values.yaml:
118+
119+
```yaml
120+
containerRuntime:
121+
containerd:
122+
enable: true
123+
```
124+
125+
#### 3. [WIP] CRI-O
126+
127+
> DON'T USE, Work in progress
128+
129+
Dragonfly helm supports config CRI-O automatically with drop-in registries.
130+
131+
Chart customize values.yaml:
132+
```yaml
133+
containerRuntime:
134+
crio:
135+
# -- Enable CRI-O support
136+
# Inject drop-in mirror config into /etc/containers/registries.conf.d.
137+
enable: true
138+
# Registries full urls
139+
registries:
140+
- "https://ghcr.io"
141+
- "https://quay.io"
142+
- "https://harbor.example.com:8443"
143+
```
144+
14145
### Prepare Kubernetes Cluster
15146

16147
If there is no available Kubernetes cluster for testing, [minikube](https://minikube.sigs.k8s.io/docs/start/) is
@@ -101,7 +232,7 @@ Wait all pods running
101232
kubectl -n dragonfly-system wait --for=condition=ready --all --timeout=10m pod
102233
```
103234

104-
### Configure Runtime
235+
### Configure Runtime Manually
105236

106237
Use Containerd with CRI as example, more runtimes can be found [here](../user-guide/quick-start.md)
107238

@@ -146,10 +277,10 @@ crictl pull docker.io/library/alpine:latest
146277
After pulled images, find logs in dfdaemon pod:
147278
```shell
148279
# find pods
149-
kubectl -n dragonfly get pod -l component=dfdaemon
280+
kubectl -n dragonfly-system get pod -l component=dfdaemon
150281
# find logs
151282
pod_name=dfdaemon-xxxxx
152-
kubectl -n dragonfly exec -it ${pod_name} -- grep "peer task done" /var/log/dragonfly/daemon/core.log
283+
kubectl -n dragonfly-system exec -it ${pod_name} -- grep "peer task done" /var/log/dragonfly/daemon/core.log
153284
```
154285

155286
Example output:
@@ -176,12 +307,12 @@ kustomize build Dragonfly2/deploy/kustomize/single-cluster-native/overlays/sampl
176307
Wait all pods running
177308

178309
```shell
179-
kubectl -n dragonfly wait --for=condition=ready --all --timeout=10m pod
310+
kubectl -n dragonfly-system wait --for=condition=ready --all --timeout=10m pod
180311
```
181312

182313
### Next Steps
183314

184-
Following [Configure Runtime](#configure-runtime) to configure runtime.
315+
Following [Configure Runtime](#configure-runtime-manually) to configure runtime.
185316

186317
Following [Using Dragonfly](#using-dragonfly) to use Dragonfly.
187318

0 commit comments

Comments
 (0)