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

feature: ability to manage CRDs in KCP using terraform #3333

Open
1 task
andrewlee1089 opened this issue Mar 14, 2025 · 2 comments
Open
1 task

feature: ability to manage CRDs in KCP using terraform #3333

andrewlee1089 opened this issue Mar 14, 2025 · 2 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@andrewlee1089
Copy link

Feature Description

I can't quite decide whether to raise this with the KCP community or the terraform-provider-kubernetes community. I think you can argue it either way!

The problem is that using if you use custom resources in a KCP, then you cannot use terraform to manage them:

 terraform apply
╷
│ Error: Plugin error
│
│   with kubernetes_manifest.mycustomkind,
│   on main.tf line 15, in resource "kubernetes_manifest" "mycustomkind":
│   15: resource "kubernetes_manifest" "mycustomkind" {
│
│ The plugin returned an unexpected error from plugin.(*GRPCProvider).PlanResourceChange: rpc error: code = Unknown desc = failed to determine resource type ID: cannot get resource type from OpenAPI
│ (mycustomapi.com/v1alpha1, Kind=mycustomkind): mycustomapi.com/v1alpha1, Kind=mycustomkind resource not found in OpenAPI index

This is because the terraform code in TFTypeFromOpenAPI (https://github.com/hashicorp/terraform-provider-kubernetes/blob/main/manifest/provider/resource.go#L85C30-L85C47) assumes that custom resource types:

  • will have a CRD
  • will have an OpenAPISchema on that CRD

KCP obviously breaks these assumptions. The OpenAPISchema is still there - on the APIResourceSchema object.

At this point I'm just raising this without any expectation it will be fixed - but I am interested in finding out if other KCP users would also like this feature.

Proposed Solution

I think it's incumbent on the KCP community to push a fix to the terraform-provider-kubernetes to cope with custom resources where is no CRD.

Alternative Solutions

No response

Want to contribute?

  • I would like to work on this issue.

Additional Context

No response

@andrewlee1089 andrewlee1089 added the kind/feature Categorizes issue or PR as related to a new feature. label Mar 14, 2025
@kcp-ci-bot kcp-ci-bot added this to kcp Mar 14, 2025
@github-project-automation github-project-automation bot moved this to New in kcp Mar 14, 2025
@embik
Copy link
Member

embik commented Mar 18, 2025

Hey @andrewlee1089 - thanks for using kcp and reporting this issue! As you mentioned, this seems to be an issue with the Terraform provider, we can't do much about it. I'm happy to keep this open, should we maybe convert it into a discussion?

The code in the provider isn't fully clear to me, but it seems to me that ideally, the provider would look for a CRD and if it cannot find one, fall back to OpenAPI discovery directly. I wonder if this is something that could be raised upstream?

@xrstf
Copy link
Contributor

xrstf commented Mar 19, 2025

Just to be sure, is your Kind really all lowercase?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
Status: New
Development

No branches or pull requests

3 participants