kubernetes-client / java

Official Java client library for kubernetes
http://kubernetes.io/
Apache License 2.0
3.46k stars 1.85k forks source link

Failed to generate spec from crd #1254

Open kinderyj opened 3 years ago

kinderyj commented 3 years ago

Steps to reproduce:

git clone https://github.com/kubernetes-client/java.git cd java/client-java-contrib docker build . docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$(pwd)":"$(pwd)" -it --network host 2f1a4715f0e7 /generate.sh -u https://github.com/kinderyj/presto-operator/releases/download/0.1/crd.yaml \ -n io.prestosql \ -p io.prestosql \ -o "$(pwd)"

When I generated the code from Crd, I only got the V1beta1PrestoClusterList.java, there is no Spec files such as V1beta1PrestoClusterSpec.java, How should I update my crd to generate the V1beta1PrestoClusterSpec.java ? Thanks.

My Crd is as below,

apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: name: prestoclusters.operator.prestosql.io spec: group: operator.prestosql.io version: v1alpha1 names: kind: PrestoCluster singular: prestocluster plural: prestoclusters scope: Namespaced validation: openAPIV3Schema: properties: spec: properties: workers: type: integer minimum: 1 maximum: 10 additionalPrinterColumns:

yue9944882 commented 3 years ago

can you follow our latest document https://github.com/kubernetes-client/java/blob/master/docs/generate-model-from-third-party-resources.md? there was a few updated content recently.

apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: name: prestoclusters.operator.prestosql.io spec: group: operator.prestosql.io version: v1alpha1 names: kind: PrestoCluster singular: prestocluster plural: prestoclusters scope: Namespaced validation: openAPIV3Schema: properties: spec: properties: workers: type: integer minimum: 1 maximum: 10 additionalPrinterColumns: - name: DESIRED type: integer description: The desired number of worker nodes JSONPath: .spec.workers - name: CURRENT type: integer description: The current number of worker nodes JSONPath: .status.availableWorkers

at a glance, i think you didn't enable the CRD pruning in this CRD's spec by setting .spec.preserveUnknownFields to false. can you retry?

dsyer commented 3 years ago

Adding .spec.preserveUnknownFields=false in the YAML seems to work. The canonical example from the docs doesn't have that flag though (https://gist.githubusercontent.com/yue9944882/266fee8e95c2f15a93778263633e72ed/raw/be12c13379eeed13d2532cb65da61fffb19ee3e7/crontab-crd.yaml). Maybe something needs to be added to the documentation?

fejta-bot commented 3 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale

dsyer commented 3 years ago

/remove-lifecycle stale

Please

fejta-bot commented 3 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale

fejta-bot commented 3 years ago

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten

dsyer commented 3 years ago

/remove-lifecycle rotten

brendandburns commented 3 years ago

/lifecycle frozen

dabaooline commented 2 years ago

operator.prestosql.io

change param -n io.prestosql.operator -p io.prestosql.operator maybe work.

I met the same error. Then I reverse the CRD group name, it worked.