sl1pm4t / k2tf

Kubernetes YAML to Terraform HCL converter
Mozilla Public License 2.0
1.17k stars 108 forks source link

Fail to convert CRD yamls #46

Closed bykvaadm closed 4 years ago

bykvaadm commented 4 years ago

4:13PM Fatal | %!s() error="2 errors occurred:\n\t could not decode yaml object with main scheme #1: no kind \"CustomResourceDefinition\" is registered for version \"apiextensions.k8s.io/v1beta1\" in scheme \"pkg/runtime/scheme.go:101\"\n\t could not decode yaml object with aggregator scheme #1: no kind \"CustomResourceDefinition\" is registered for version \"apiextensions.k8s.io/v1beta1\" in scheme \"pkg/runtime/scheme.go:101\"\n\n"

i.e.

kind: CustomResourceDefinition
metadata:
  name: clusterissuers.certmanager.k8s.io
  labels:
    app: cert-manager
spec:
  group: certmanager.k8s.io
  version: v1alpha1
  names:
    kind: ClusterIssuer
    plural: clusterissuers
  scope: Cluster
sl1pm4t commented 4 years ago

HI @bykvaadm - AFAIK the Terraform Kubernetes provider has no support for CRD's yet, so I've not added support in k2tf either.

thiagonache commented 4 years ago

Hi @sl1pm4t, First of all, thanks a lot for the tool. It's awesome. I agree that's not supported, but my understanding is that it should return warn like for other kind (ie MutatingWebhookConfiguration) instead of crashing. The problem is the YAML comes from a third-party and I want to avoid to create my own script to parser the YAML and remove the CRDs declaration. If I understood the code correctly kube-aggregator is the problem. Am I correct?

worwoods commented 4 years ago

Maybe a more desirable solution would be to output the support features as a tf and a trimmed version of the yaml for inclusion as standards kubectl command using the external feature?

sl1pm4t commented 4 years ago

Hi @thiagonache - Ah I didn't realise k2tf crashed when it came across a CRD yaml. I agree it should be possible to ignore unsupported resources and process all the rest.

thiagonache commented 4 years ago

Maybe a more desirable solution would be to output the support features as a tf and a trimmed version of the yaml for inclusion as standards kubectl command using the external feature?

yeah... that would be awesome

thiagonache commented 4 years ago

thank you @sl1pm4t !!!!!

brandonmaul commented 2 years ago

So the Kubernetes Terraform provider now has support for CRD's apparently: https://github.com/hashicorp/terraform-provider-kubernetes/issues/215

Could this be re-opened?