Skip to content

Commit 7db3b83

Browse files
committed
envtest expose 'SecureConfig' for user conveinience.
Please note that this just contains secure endpoint itself and its CA certs. User will have to set authentication information by themselves and configure some authn module in kube-apiserver.
1 parent b231ddb commit 7db3b83

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

pkg/envtest/server.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,18 @@ type Environment struct {
8787
// ControlPlane is the ControlPlane including the apiserver and etcd
8888
ControlPlane integration.ControlPlane
8989

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
9292
// loading.
9393
Config *rest.Config
9494

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
100+
SecureConfig *rest.Config
101+
95102
// CRDInstallOptions are the options for installing CRDs.
96103
CRDInstallOptions CRDInstallOptions
97104

@@ -249,6 +256,13 @@ func (te *Environment) Start() (*rest.Config, error) {
249256
QPS: 1000.0,
250257
Burst: 2000.0,
251258
}
259+
te.SecureConfig = &rest.Config{
260+
Host: fmt.Sprintf("%s:%d", te.ControlPlane.APIURL().Hostname(), te.ControlPlane.APIServer.SecurePort),
261+
TLSClientConfig: te.ControlPlane.APIServer.TlsClientConfig,
262+
// gotta go fast during tests -- we don't really care about overwhelming our test API server
263+
QPS: 1000.0,
264+
Burst: 2000.0,
265+
}
252266
}
253267

254268
log.V(1).Info("installing CRDs")

0 commit comments

Comments
 (0)