<p><strong>What happened</strong></p>
<p>I am trying to create custom resource definition in kubernetes using kubernetes python client, but i am unable to do so, it would be helpful if someone can explain what i am doing wrong here</p>
<pre class="lang-sh prettyprint-override"><code>Traceback (most recent call last):
  File &quot;/home/talha/python/examples/custom_object.py&quot;, line 239, in &lt;module&gt;
    main()
  File &quot;/home/talha/python/examples/custom_object.py&quot;, line 191, in main
    api.create_custom_resource_definition(body=crd)
  File &quot;/home/talha/python/kubernetes/client/api/apiextensions_v1beta1_api.py&quot;, line 65, in create_custom_resource_definition
    return self.create_custom_resource_definition_with_http_info(body, **kwargs)  # noqa: E501
  File &quot;/home/talha/python/kubernetes/client/api/apiextensions_v1beta1_api.py&quot;, line 166, in create_custom_resource_definition_with_http_info
    collection_formats=collection_formats)
  File &quot;/home/talha/python/kubernetes/client/api_client.py&quot;, line 353, in call_api
    _preload_content, _request_timeout, _host)
  File &quot;/home/talha/python/kubernetes/client/api_client.py&quot;, line 184, in __call_api
    _request_timeout=_request_timeout)
  File &quot;/home/talha/python/kubernetes/client/api_client.py&quot;, line 397, in request
    body=body)
  File &quot;/home/talha/python/kubernetes/client/rest.py&quot;, line 280, in POST
    body=body)
  File &quot;/home/talha/python/kubernetes/client/rest.py&quot;, line 233, in request
    raise ApiException(http_resp=r)
kubernetes.client.exceptions.ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Cache-Control': 'no-cache, private', 'Content-Type': 'application/json', 'Date': 'Mon, 31 Aug 2020 09:51:19 GMT', 'Content-Length': '610'})
HTTP response body: {&quot;kind&quot;:&quot;Status&quot;,&quot;apiVersion&quot;:&quot;v1&quot;,&quot;metadata&quot;:{},&quot;status&quot;:&quot;Failure&quot;,&quot;message&quot;:&quot;CustomResourceDefinition in version \&quot;v1beta1\&quot; cannot be handled as a CustomResourceDefinition: v1beta1.CustomResourceDefinition.ObjectMeta: v1.ObjectMeta.Labels: CreationTimestamp: unmarshalerDecoder: parsing time \&quot;null\&quot; as \&quot;2006-01-02T15:04:05Z07:00\&quot;: cannot parse \&quot;null\&quot; as \&quot;2006\&quot;, error found in #10 byte of ...|p\&quot;: \&quot;null\&quot;, \&quot;labels\&quot;|..., bigger context ...|o/version\&quot;: \&quot;v0.2.4\&quot;}, \&quot;creationTimestamp\&quot;: \&quot;null\&quot;, \&quot;labels\&quot;: {\&quot;component\&quot;: \&quot;velero\&quot;}, \&quot;name\&quot;: \&quot;back|...&quot;,&quot;reason&quot;:&quot;BadRequest&quot;,&quot;code&quot;:400}

</code></pre>
<p><strong>What you expected to happen</strong>:
create CRD</p>
<p><strong>How to reproduce it (as minimally and precisely as possible)</strong>:</p>
<pre class="lang-py prettyprint-override"><code>    config.load_kube_config()
    api = client.ApiextensionsV1beta1Api()
    crd = {
         &quot;apiVersion&quot;:&quot;apiextensions.k8s.io/v1beta1&quot;,
         &quot;kind&quot;:&quot;CustomResourceDefinition&quot;,
         &quot;metadata&quot;:{
            &quot;annotations&quot;:{
               &quot;controller-gen.kubebuilder.io/version&quot;:&quot;v0.2.4&quot;
            },
            &quot;creationTimestamp&quot;:&quot;null&quot;,
            &quot;labels&quot;:{
               &quot;component&quot;:&quot;velero&quot;
            },
            &quot;name&quot;:&quot;backupstoragelocations.velero.io&quot;
         },
         &quot;spec&quot;:{
            &quot;group&quot;:&quot;velero.io&quot;,
            &quot;names&quot;:{
               &quot;kind&quot;:&quot;BackupStorageLocation&quot;,
               &quot;listKind&quot;:&quot;BackupStorageLocationList&quot;,
               &quot;plural&quot;:&quot;backupstoragelocations&quot;,
               &quot;singular&quot;:&quot;backupstoragelocation&quot;
            },
            &quot;preserveUnknownFields&quot;:&quot;false&quot;,
            &quot;scope&quot;:&quot;Namespaced&quot;,
            &quot;validation&quot;:{
               &quot;openAPIV3Schema&quot;:{
                  &quot;description&quot;:&quot;BackupStorageLocation is a location where Velero stores backup objects.&quot;,
                  &quot;properties&quot;:{
                     &quot;apiVersion&quot;:{
                        &quot;description&quot;:&quot;APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources&quot;,
                        &quot;type&quot;:&quot;string&quot;
                     },
                     &quot;kind&quot;:{
                        &quot;description&quot;:&quot;Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds&quot;,
                        &quot;type&quot;:&quot;string&quot;
                     },
                     &quot;metadata&quot;:{
                        &quot;type&quot;:&quot;object&quot;
                     },
                     &quot;spec&quot;:{
                        &quot;description&quot;:&quot;BackupStorageLocationSpec defines the specification for a Velero BackupStorageLocation.&quot;,
                        &quot;properties&quot;:{
                           &quot;accessMode&quot;:{
                              &quot;description&quot;:&quot;AccessMode defines the permissions for the backup storage location.&quot;,
                              &quot;enum&quot;:[
                                 &quot;ReadOnly&quot;,
                                 &quot;ReadWrite&quot;
                              ],
                              &quot;type&quot;:&quot;string&quot;
                           },
                           &quot;backupSyncPeriod&quot;:{
                              &quot;description&quot;:&quot;BackupSyncPeriod defines how frequently to sync backup API objects from object storage. A value of 0 disables sync.&quot;,
                              &quot;nullable&quot;:&quot;true&quot;,
                              &quot;type&quot;:&quot;string&quot;
                           },
                           &quot;config&quot;:{
                              &quot;additionalProperties&quot;:{
                                 &quot;type&quot;:&quot;string&quot;
                              },
                              &quot;description&quot;:&quot;Config is for provider-specific configuration fields.&quot;,
                              &quot;type&quot;:&quot;object&quot;
                           },
                           &quot;objectStorage&quot;:{
                              &quot;description&quot;:&quot;ObjectStorageLocation specifies the settings necessary to connect to a provider's object storage.&quot;,
                              &quot;properties&quot;:{
                                 &quot;bucket&quot;:{
                                    &quot;description&quot;:&quot;Bucket is the bucket to use for object storage.&quot;,
                                    &quot;type&quot;:&quot;string&quot;
                                 },
                                 &quot;caCert&quot;:{
                                    &quot;description&quot;:&quot;CACert defines a CA bundle to use when verifying TLS connections to the provider.&quot;,
                                    &quot;format&quot;:&quot;byte&quot;,
                                    &quot;type&quot;:&quot;string&quot;
                                 },
                                 &quot;prefix&quot;:{
                                    &quot;description&quot;:&quot;Prefix is the path inside a bucket to use for Velero storage. Optional.&quot;,
                                    &quot;type&quot;:&quot;string&quot;
                                 }
                              },
                              &quot;required&quot;:[
                                 &quot;bucket&quot;
                              ],
                              &quot;type&quot;:&quot;object&quot;
                           },
                           &quot;provider&quot;:{
                              &quot;description&quot;:&quot;Provider is the provider of the backup storage.&quot;,
                              &quot;type&quot;:&quot;string&quot;
                           }
                        },
                        &quot;required&quot;:[
                           &quot;objectStorage&quot;,
                           &quot;provider&quot;
                        ],
                        &quot;type&quot;:&quot;object&quot;
                     },
                     &quot;status&quot;:{
                        &quot;description&quot;:&quot;BackupStorageLocationStatus describes the current status of a Velero BackupStorageLocation.&quot;,
                        &quot;properties&quot;:{
                           &quot;accessMode&quot;:{
                              &quot;description&quot;:&quot;AccessMode is an unused field. \n Deprecated: there is now an AccessMode field on the Spec and this field will be removed entirely as of v2.0.&quot;,
                              &quot;enum&quot;:[
                                 &quot;ReadOnly&quot;,
                                 &quot;ReadWrite&quot;
                              ],
                              &quot;type&quot;:&quot;string&quot;
                           },
                           &quot;lastSyncedRevision&quot;:{
                              &quot;description&quot;:&quot;LastSyncedRevision is the value of the `metadata/revision` file in the backup storage location the last time the BSL's contents were synced into the cluster. \n Deprecated: this field is no longer updated or used for detecting changes to the location's contents and will be removed entirely in v2.0.&quot;,
                              &quot;type&quot;:&quot;string&quot;
                           },
                           &quot;lastSyncedTime&quot;:{
                              &quot;description&quot;:&quot;LastSyncedTime is the last time the contents of the location were synced into the cluster.&quot;,
                              &quot;format&quot;:&quot;date-time&quot;,
                              &quot;nullable&quot;:&quot;true&quot;,
                              &quot;type&quot;:&quot;string&quot;
                           },
                           &quot;phase&quot;:{
                              &quot;description&quot;:&quot;Phase is the current state of the BackupStorageLocation.&quot;,
                              &quot;enum&quot;:[
                                 &quot;Available&quot;,
                                 &quot;Unavailable&quot;
                              ],
                              &quot;type&quot;:&quot;string&quot;
                           }
                        },
                        &quot;type&quot;:&quot;object&quot;
                     }
                  },
                  &quot;type&quot;:&quot;object&quot;
               }
            },
            &quot;version&quot;:&quot;v1&quot;,
            &quot;versions&quot;:[
               {
                  &quot;name&quot;:&quot;v1&quot;,
                  &quot;served&quot;:&quot;true&quot;,
                  &quot;storage&quot;:&quot;true&quot;
               }
            ]
         }
      }
    api.create_custom_resource_definition(body=crd)
</code></pre>
<p><strong>Anything else we need to know?</strong>:</p>
<p><strong>Environment</strong>:</p>
<ul>
<li>Kubernetes version (<code>v1.18.6</code>):</li>
<li>OS (ubuntu 20.04):</li>
<li>Python version (<code>3.8.2</code>)</li>
<li>Python client version (<code>11.0.0</code>)</li>
</ul>

Talha Latif
<p>Let's take a look at the error message:</p>
<blockquote>
<p>CustomResourceDefinition in version &quot;v1beta1&quot; cannot be handled as a CustomResourceDefinition: v1beta1.CustomResourceDefinition.ObjectMeta: v1.ObjectMeta.Labels: CreationTimestamp: unmarshalerDecoder: parsing time &quot;null&quot; as &quot;2006-01-02T15:04:05Z07:00&quot;: cannot parse &quot;null&quot; as &quot;2006&quot;</p>
</blockquote>
<p>So, as the error message suggests, there is a problem with <code>CreationTimeStamp</code>. Now the question is, what's wrong with your <code>CreationTimestamp</code>?</p>
<p>Your CreationTimestamp should be:</p>
<pre><code>{
&quot;creationTimestamp&quot;:null, // creationTimestamp is actually defined, but the value is null
}
</code></pre>
<p>instead of:</p>
<pre><code>{
&quot;creationTimestamp&quot;:&quot;null&quot;, // setting creationTimestamp equal to a string value &quot;null&quot;
}
</code></pre>
