Skip to content

Commit 8f6b89f

Browse files
authored
Merge pull request kubernetes#81860 from deads2k/allow-http1-only
allow an apiserver to only serve http1
2 parents ec344a1 + 6eb6250 commit 8f6b89f

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

staging/src/k8s.io/apiserver/pkg/server/config.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"sync/atomic"
3030
"time"
3131

32-
"github.com/evanphx/json-patch"
32+
jsonpatch "github.com/evanphx/json-patch"
3333
"github.com/go-openapi/spec"
3434
"github.com/pborman/uuid"
3535

@@ -247,6 +247,9 @@ type SecureServingInfo struct {
247247
// HTTP2MaxStreamsPerConnection is the limit that the api server imposes on each client.
248248
// A value of zero means to use the default provided by golang's HTTP/2 support.
249249
HTTP2MaxStreamsPerConnection int
250+
251+
// DisableHTTP2 indicates that http2 should not be enabled.
252+
DisableHTTP2 bool
250253
}
251254

252255
type AuthenticationInfo struct {

staging/src/k8s.io/apiserver/pkg/server/secure_serving.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ func (s *SecureServingInfo) Serve(handler http.Handler, shutdownTimeout time.Dur
6060
},
6161
}
6262

63+
if s.DisableHTTP2 {
64+
klog.Info("Forcing use of http/1.1 only")
65+
secureServer.TLSConfig.NextProtos = []string{"http/1.1"}
66+
}
67+
6368
if s.MinTLSVersion > 0 {
6469
secureServer.TLSConfig.MinVersion = s.MinTLSVersion
6570
}
@@ -108,9 +113,11 @@ func (s *SecureServingInfo) Serve(handler http.Handler, shutdownTimeout time.Dur
108113
// increase the connection buffer size from the 1MB default to handle the specified number of concurrent streams
109114
http2Options.MaxUploadBufferPerConnection = http2Options.MaxUploadBufferPerStream * int32(http2Options.MaxConcurrentStreams)
110115

111-
// apply settings to the server
112-
if err := http2.ConfigureServer(secureServer, http2Options); err != nil {
113-
return nil, fmt.Errorf("error configuring http2: %v", err)
116+
if !s.DisableHTTP2 {
117+
// apply settings to the server
118+
if err := http2.ConfigureServer(secureServer, http2Options); err != nil {
119+
return nil, fmt.Errorf("error configuring http2: %v", err)
120+
}
114121
}
115122

116123
klog.Infof("Serving securely on %s", secureServer.Addr)

0 commit comments

Comments
 (0)