Skip to content

Commit 6c06aa1

Browse files
committed
refactor: improve HTTP client configuration in webhook server
1 parent 179f0ec commit 6c06aa1

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

cmd/webhook/main.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package main
22

33
import (
4+
"net"
45
"net/http"
56
"os"
7+
"time"
68

79
"github.com/cert-manager/cert-manager/pkg/acme/webhook/cmd"
810
"github.com/stackitcloud/stackit-cert-manager-webhook/internal/repository"
@@ -28,10 +30,24 @@ func main() {
2830
// You can register multiple DNS provider implementations with a single
2931
// webhook, where the Name() method will be used to disambiguate between
3032
// the different implementations.
33+
34+
httpClient := &http.Client{
35+
Timeout: 30 * time.Second,
36+
Transport: &http.Transport{
37+
DialContext: (&net.Dialer{
38+
Timeout: 5 * time.Second,
39+
KeepAlive: 30 * time.Second,
40+
}).DialContext,
41+
TLSHandshakeTimeout: 5 * time.Second,
42+
ResponseHeaderTimeout: 10 * time.Second,
43+
IdleConnTimeout: 30 * time.Second,
44+
},
45+
}
46+
3147
cmd.RunWebhookServer(
3248
GroupName,
3349
resolver.NewResolver(
34-
&http.Client{},
50+
httpClient,
3551
logger,
3652
repository.NewZoneRepositoryFactory(),
3753
repository.NewRRSetRepositoryFactory(),

0 commit comments

Comments
 (0)