Skip to content

Commit

Permalink
Merge pull request kubernetes#7 from wm775825/release-1.28
Browse files Browse the repository at this point in the history
load tls config immediately for authenticate webhook
  • Loading branch information
XiShanYongYe-Chang committed Dec 5, 2023
2 parents 83dc2c2 + bb5bf7c commit 7ec38c2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions staging/src/k8s.io/apiserver/pkg/util/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package webhook
import (
"context"
"fmt"
"os"
"time"

apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -153,6 +154,29 @@ func LoadKubeconfig(kubeConfigFile string, customDial utilnet.DialFunc) (*rest.C
return nil, err
}

// load tls configuration immediately
if clientConfig.CAFile != "" && len(clientConfig.CAData) == 0 {
caData, err := os.ReadFile(clientConfig.CAFile)
if err != nil {
return nil, err
}
clientConfig.CAData = caData
}
if clientConfig.CertFile != "" && len(clientConfig.CertData) == 0 {
certData, err := os.ReadFile(clientConfig.CertFile)
if err != nil {
return nil, err
}
clientConfig.CertData = certData
}
if clientConfig.KeyFile != "" && len(clientConfig.KeyData) == 0 {
keyData, err := os.ReadFile(clientConfig.KeyFile)
if err != nil {
return nil, err
}
clientConfig.KeyData = keyData
}

clientConfig.Dial = customDial

// Kubeconfigs can't set a timeout, this can only be set through a command line flag.
Expand Down

0 comments on commit 7ec38c2

Please sign in to comment.