Created
June 4, 2020 07:12
-
-
Save anfernee/7d129e4b43659abdd4039a586efd992f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// creates the connection | |
config, err := clientcmd.BuildConfigFromFlags(master, kubeconfig) | |
if err != nil { | |
klog.Fatal(err) | |
} | |
var rt2 *http2.Transport | |
var once sync.Once | |
config.WrapTransport = func(rt http.RoundTripper) http.RoundTripper { | |
fmt.Println("wrapper") | |
once.Do(func() { | |
rt2 = &http2.Transport{ | |
TLSClientConfig: rt.(*http.Transport).TLSClientConfig, | |
} | |
go func() { | |
ipport := strings.ReplaceAll(config.Host, "https://", "") | |
conn, _ := tls.Dial("tcp", ipport, rt2.TLSClientConfig) | |
clientconn, _ := rt2.NewClientConn(conn) | |
for { | |
fmt.Println("ping", clientconn.Ping(context.TODO())) | |
time.Sleep(time.Second) | |
} | |
}() | |
}) | |
return rt2 | |
} | |
// creates the clientset | |
clientset, err := kubernetes.NewForConfig(config) | |
if err != nil { | |
klog.Fatal(err) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment