Closed cxisama closed 3 months ago
type customCipherRoundTripper struct {
originalTransport http.RoundTripper
}
func (t *customCipherRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
// Force conversion customRt to http.Transport
tlsTran, ok := t.originalTransport.(*http.Transport)
if ok {
tlsTran.TLSClientConfig.CipherSuites = []uint16{tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}
}
return t.originalTransport.RoundTrip(req)
}
func createClientSets(opt *options.TrainingJobOperatorOption) (kubeclientset.Interface, kubeclientset.Interface, trainingjobclientset.Interface, apiextensionsclient.Interface, *vcclient.Clientset, error) {
var kubeConfig *restclientset.Config
var err error
if opt.RunInCluster {
kubeConfig, err = restclientset.InClusterConfig()
} else {
if opt.Kubeconfig != "" {
if _, err = os.Stat(opt.Kubeconfig); err != nil {
opt.Kubeconfig = ""
}
klog.V(4).Infof("Using kubeconfig file: %s", opt.Kubeconfig)
}
kubeConfig, err = clientcmd.BuildConfigFromFlags(opt.MasterUrl, opt.Kubeconfig)
}
kubeConfig.WrapTransport = func(rt http.RoundTripper) http.RoundTripper {
return &customCipherRoundTripper{rt}
}
}
you can try these codes
First of all, I Customize a rest.Config and configure WrapTransport for it. After obtaining rest.config, use the config.wrap method to configure CipherSuites for transport.The code is as follows:
The clientSet does not use the specified CipherSuites when accessing Kubernetes as a client. Instead, the native CipherSuite of Kubernetes is used. How do I specify the default CipherSuites for clientSet?