@@ -19,6 +19,7 @@ package main
19
19
20
20
import (
21
21
"context"
22
+ "crypto/tls"
22
23
"flag"
23
24
"fmt"
24
25
"os"
62
63
logOptions = logs .NewOptions ()
63
64
webhookPort int
64
65
webhookCertDir string
66
+ disableHTTP2 bool
65
67
66
68
scheme = runtime .NewScheme ()
67
69
setupLog = ctrl .Log .WithName ("setup" )
@@ -130,6 +132,9 @@ func initFlags(fs *pflag.FlagSet) {
130
132
fs .StringVar (& webhookCertDir , "webhook-cert-dir" , "/tmp/k8s-webhook-server/serving-certs/" ,
131
133
"The webhook certificate directory, where the server should find the TLS certificate and key." )
132
134
135
+ fs .BoolVar (& disableHTTP2 , "disable-http2" , true , "http/2 should be disabled due to its vulnerabilities. More specifically, disabling http/2 will" +
136
+ " prevent from being vulnerable to the HTTP/2 Stream Cancellation and Rapid Reset CVEs." )
137
+
133
138
logsv1 .AddFlags (logOptions , fs )
134
139
flags .AddManagerOptions (fs , & managerOptions )
135
140
}
@@ -199,6 +204,15 @@ func main() {
199
204
}
200
205
}
201
206
207
+ if disableHTTP2 {
208
+ metricsOptions .TLSOpts = append (metricsOptions .TLSOpts , func (c * tls.Config ) {
209
+ setupLog .Info ("disabling http/2" )
210
+ c .NextProtos = []string {"http/1.1" }
211
+ })
212
+ } else {
213
+ setupLog .Info ("WARNING: It is not recommended to enable http/2 due to https://github.com/kubernetes/kubernetes/issues/121197" )
214
+ }
215
+
202
216
mgr , err := ctrl .NewManager (ctrl .GetConfigOrDie (), ctrl.Options {
203
217
Scheme : scheme ,
204
218
LeaderElection : enableLeaderElection ,
0 commit comments