Migrate Deprecated TLSMinVersion to TLSOption for webhook.

Co-authored-by: RainbowMango <qdurenhongcai@gmail.com>
Signed-off-by: Lan Liang <gcslyp@gmail.com>
This commit is contained in:
Lan Liang 2023-12-29 07:05:33 +00:00
parent 04779a27cc
commit f75377ce3b
1 changed files with 23 additions and 6 deletions

View File

@ -18,6 +18,7 @@ package app
import ( import (
"context" "context"
"crypto/tls"
"flag" "flag"
"fmt" "fmt"
"net/http" "net/http"
@ -117,12 +118,28 @@ func Run(ctx context.Context, opts *options.Options) error {
Logger: klog.Background(), Logger: klog.Background(),
Scheme: gclient.NewSchema(), Scheme: gclient.NewSchema(),
WebhookServer: webhook.NewServer(webhook.Options{ WebhookServer: webhook.NewServer(webhook.Options{
Host: opts.BindAddress, Host: opts.BindAddress,
Port: opts.SecurePort, Port: opts.SecurePort,
CertDir: opts.CertDir, CertDir: opts.CertDir,
CertName: opts.CertName, CertName: opts.CertName,
KeyName: opts.KeyName, KeyName: opts.KeyName,
TLSMinVersion: opts.TLSMinVersion, TLSOpts: []func(*tls.Config){
func(config *tls.Config) {
// Just transform the valid options as opts.TLSMinVersion
// can only accept "1.0", "1.1", "1.2", "1.3" and has default
// value,
switch opts.TLSMinVersion {
case "1.0":
config.MinVersion = tls.VersionTLS10
case "1.1":
config.MinVersion = tls.VersionTLS11
case "1.2":
config.MinVersion = tls.VersionTLS12
case "1.3":
config.MinVersion = tls.VersionTLS13
}
},
},
}), }),
LeaderElection: false, LeaderElection: false,
MetricsBindAddress: opts.MetricsBindAddress, MetricsBindAddress: opts.MetricsBindAddress,