mirror of https://github.com/k3s-io/k3s
Disable HTTP on main etcd client port
Fixes performance issue under load, ref: https://github.com/etcd-io/etcd/issues/15402 and https://github.com/kubernetes/kubernetes/pull/118460 Signed-off-by: Brad Davidson <brad.davidson@rancher.com>pull/8292/head^2
parent
cae8b2b626
commit
8c73fd670b
|
@ -37,6 +37,7 @@ type ETCDConfig struct {
|
|||
InitialOptions `json:",inline"`
|
||||
Name string `json:"name,omitempty"`
|
||||
ListenClientURLs string `json:"listen-client-urls,omitempty"`
|
||||
ListenClientHTTPURLs string `json:"listen-client-http-urls,omitempty"`
|
||||
ListenMetricsURLs string `json:"listen-metrics-urls,omitempty"`
|
||||
ListenPeerURLs string `json:"listen-peer-urls,omitempty"`
|
||||
AdvertiseClientURLs string `json:"advertise-client-urls,omitempty"`
|
||||
|
|
|
@ -834,6 +834,14 @@ func (e *ETCD) listenMetricsURLs(reset bool) string {
|
|||
return metricsURLs
|
||||
}
|
||||
|
||||
// listenClientHTTPURLs returns a list of URLs to bind to for http client connections.
|
||||
// This should no longer be used, but we must set it in order to free the listen URLs
|
||||
// for dedicated use by GRPC.
|
||||
// Ref: https://github.com/etcd-io/etcd/issues/15402
|
||||
func (e *ETCD) listenClientHTTPURLs() string {
|
||||
return fmt.Sprintf("https://%s:2382", e.config.Loopback(true))
|
||||
}
|
||||
|
||||
// cluster calls the executor to start etcd running with the provided configuration.
|
||||
func (e *ETCD) cluster(ctx context.Context, reset bool, options executor.InitialOptions) error {
|
||||
ctx, e.cancel = context.WithCancel(ctx)
|
||||
|
@ -864,6 +872,7 @@ func (e *ETCD) cluster(ctx context.Context, reset bool, options executor.Initial
|
|||
Logger: "zap",
|
||||
LogOutputs: []string{"stderr"},
|
||||
ExperimentalInitialCorruptCheck: true,
|
||||
ListenClientHTTPURLs: e.listenClientHTTPURLs(),
|
||||
}, e.config.ExtraEtcdArgs)
|
||||
}
|
||||
|
||||
|
@ -885,10 +894,16 @@ func (e *ETCD) StartEmbeddedTemporary(ctx context.Context) error {
|
|||
|
||||
endpoints := getEndpoints(e.config)
|
||||
clientURL := endpoints[0]
|
||||
// peer URL is usually 1 more than client
|
||||
peerURL, err := addPort(endpoints[0], 1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// client http URL is usually 3 more than client, after peer and metrics
|
||||
clientHTTPURL, err := addPort(endpoints[0], 3)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
embedded := executor.Embedded{}
|
||||
ctx, e.cancel = context.WithCancel(ctx)
|
||||
|
@ -898,6 +913,7 @@ func (e *ETCD) StartEmbeddedTemporary(ctx context.Context) error {
|
|||
ForceNewCluster: true,
|
||||
AdvertiseClientURLs: clientURL,
|
||||
ListenClientURLs: clientURL,
|
||||
ListenClientHTTPURLs: clientHTTPURL,
|
||||
ListenPeerURLs: peerURL,
|
||||
Logger: "zap",
|
||||
HeartbeatInterval: 500,
|
||||
|
|
Loading…
Reference in New Issue