Skip to content

Commit

Permalink
envtest expose 'SecureConfig' for user conveinience.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
everpeace committed Jun 6, 2020
1 parent b231ddb commit 7db3b83
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions pkg/envtest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,18 @@ type Environment struct {
// ControlPlane is the ControlPlane including the apiserver and etcd
ControlPlane integration.ControlPlane

// Config can be used to talk to the apiserver. It's automatically
// populated if not set using the standard controller-runtime config
// Config can be used to talk to the apiserver (insecure endpoint).
// It's automatically populated if not set using the standard controller-runtime config
// loading.
Config *rest.Config

// SecureConfig can be used to talk to the apiserver (secure endpoint).
// It's automatically populated if not set using the standard controller-runtime config
// loading. This just contains secure endpoint and tlsconfig (no authn info).
// To use this config, you have to configure kube-apiserver with some authn module(static token, basic auth, etc.)
// and set your authentication info to this config
SecureConfig *rest.Config

// CRDInstallOptions are the options for installing CRDs.
CRDInstallOptions CRDInstallOptions

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

log.V(1).Info("installing CRDs")
Expand Down

0 comments on commit 7db3b83

Please sign in to comment.