Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support registering APIService in envtest #1448

Closed
timebertt opened this issue Mar 24, 2021 · 7 comments
Closed

Support registering APIService in envtest #1448

timebertt opened this issue Mar 24, 2021 · 7 comments
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@timebertt
Copy link
Contributor

Currently, envtest primarily supports controllers working on resources registered by CRDs.
We would like to leverage envtest for writing integration tests for resources provided by an extension API server and registered via APIServices as well.

@timebertt
Copy link
Contributor Author

timebertt commented Mar 24, 2021

With #1449 it's now possible to configure the test environment's API server's aggregation layer in order to register APIServices like in a usual cluster.

Example:

testEnv.ControlPlane.APIServer.Args = append(envtest.DefaultKubeAPIServerFlags,
	"--client-ca-file={{ .CertDir }}/apiserver-ca.crt",
	"--proxy-client-key-file={{ .CertDir }}/apiserver.key",
	"--proxy-client-cert-file={{ .CertDir }}/apiserver.crt",
	"--requestheader-client-ca-file={{ .CertDir }}/apiserver-ca.crt",
	"--requestheader-extra-headers-prefix=X-Remote-Extra-",
	"--requestheader-group-headers=X-Remote-Group",
	"--requestheader-username-headers=X-Remote-User",
)

// start testEnv...
// start extension API server (configure delegating authn/authz as usual)
// create client with `apiregistration` in its scheme...

err := c.Create(ctx, &apiregistrationv1.APIService{ /* ... */ })

// talk to extension API server as usual
err = c.List(ctx, &yourextendedapi.SomeResourceList{})

See example usage for a more details.

@timebertt
Copy link
Contributor Author

Let me know, if there is interest in simplifying this scenario even further.
We could offer registering APIServices similar to CRDs (i.e. CRDInstallOptions) and optionally configure the aggregation layer for it accordingly.

Though, I assume that most folks using controller-runtime are rather working with CRDs, which are already well-supported by envtest.

@timebertt
Copy link
Contributor Author

here is an updated example for how to configure the aggregation layer in envtest with controller-runtime@v0.9.0 and #1541.
It generates dedicated front-proxy CA/cert/key and configures the respective API server flags.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 15, 2021
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Oct 15, 2021
@timebertt
Copy link
Contributor Author

Sine envtest mainly target's controllers working on CRDs and given that it's still fairly simple to register an APIService nowadays (described in #1448 (comment)), I think we can close this issue.
/close

@k8s-ci-robot
Copy link
Contributor

@timebertt: Closing this issue.

In response to this:

Sine envtest mainly target's controllers working on CRDs and given that it's still fairly simple to register an APIService nowadays (described in #1448 (comment)), I think we can close this issue.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

3 participants