kubernetes-client / python

Official Python client library for kubernetes
http://kubernetes.io/
Apache License 2.0
6.83k stars 3.28k forks source link

CRD status is not deployed #2268

Open leonp-c opened 3 months ago

leonp-c commented 3 months ago

**What happened: Registering a CRD with:

subresources:
      scale:
        labelSelectorPath: .status.selector
        specReplicasPath: .spec.replicas
        statusReplicasPath: .status.replicas
      status: {}

is not registered in k8s. after testing from command line using kubectl get crd some.custom.crd.ai -o yaml the result yaml is:

    subresources:
      scale:
        labelSelectorPath: .status.selector
        specReplicasPath: .spec.replicas
        statusReplicasPath: .status.replicas

status is missing

What you expected to happen: status should exist so that using kubernetes command (kubernnetes package): custom_objects_api.get_namespaced_custom_object(group=self.group, version=self.version, namespace=self.namespace, plural=self.plural, name=self.name) would work

How to reproduce it (as minimally and precisely as possible): Deploy a CustomResourceDefinition resource that has spec.versions.subresources.status as {} (dict) check the deployed CRD resource yaml get crd some.resource.name.ai -o yaml

Anything else we need to know?: Tried to downgrade to kubernetes 28.1.0, same result to comply to hikaru version (1.3.0)

Environment:

roycaihw commented 3 months ago

This seems to be a server-side issue. Have you verified if kubectl has the same problem?

leonp-c commented 3 months ago

using kubectl returned all values as expected

Bhargav-manepalli commented 2 months ago

Hi @leonp-c,

I tried to reproduce the issue you reported, and everything worked as expected on my end. Here’s what I did:

  1. Deployed a CRD with spec.versions.subresources.status defined as {} using the Kubernetes Python client.
  2. Queried the resource both using kubectl and the Python client, and I was able to see the status field correctly populated in both cases.

If everything looks correct and the issue persists, feel free to share more details about your setup,

leonp-c commented 2 months ago

Hi @Bhargav-manepalli , It seems that the issue was related to hikaru module which i used to parse the yaml and create the resource. hikaru is removing/ignoring the empty dictionary field from the v1 object. A bug was opened on their git hikaru-43 Thank you for your effort.