@@ -87,11 +87,34 @@ type Environment struct {
87
87
// ControlPlane is the ControlPlane including the apiserver and etcd
88
88
ControlPlane integration.ControlPlane
89
89
90
- // Config can be used to talk to the apiserver. It's automatically
91
- // populated if not set using the standard controller-runtime config
90
+ // Config can be used to talk to the apiserver (insecure endpoint).
91
+ // It's automatically populated if not set using the standard controller-runtime config
92
92
// loading.
93
93
Config * rest.Config
94
94
95
+ // SecureConfig can be used to talk to the apiserver (secure endpoint).
96
+ // It's automatically populated if not set using the standard controller-runtime config
97
+ // loading. This just contains secure endpoint and tlsconfig (no authn info).
98
+ // To use this config, you have to configure kube-apiserver with some authn module(static token, basic auth, etc.)
99
+ // and set your authentication info to this config. For example:
100
+ //
101
+ // // basic authn plugin case
102
+ // te := &envtest.Environment{
103
+ // KubeAPIServerFlags: append(
104
+ // envtest.DefaultKubeAPIServerFlags,
105
+ // "--basic-auth-file=my-file", "--authorization-mode=RBAC",
106
+ // ),
107
+ // }
108
+ // te.Start()
109
+ //
110
+ // cfg := rest.CopyConfig(te.SecureConfig)
111
+ // cfg.Username = "myname"
112
+ // cfg.Password = "mypassword"
113
+ //
114
+ // // This client can send a request as "myname" user.
115
+ // cli := client.New(cfg)
116
+ SecureConfig * rest.Config
117
+
95
118
// CRDInstallOptions are the options for installing CRDs.
96
119
CRDInstallOptions CRDInstallOptions
97
120
@@ -249,6 +272,13 @@ func (te *Environment) Start() (*rest.Config, error) {
249
272
QPS : 1000.0 ,
250
273
Burst : 2000.0 ,
251
274
}
275
+ te .SecureConfig = & rest.Config {
276
+ Host : fmt .Sprintf ("%s:%d" , te .ControlPlane .APIURL ().Hostname (), te .ControlPlane .APIServer .SecurePort ),
277
+ TLSClientConfig : te .ControlPlane .APIServer .TLSClientConfig ,
278
+ // gotta go fast during tests -- we don't really care about overwhelming our test API server
279
+ QPS : 1000.0 ,
280
+ Burst : 2000.0 ,
281
+ }
252
282
}
253
283
254
284
log .V (1 ).Info ("installing CRDs" )
0 commit comments