Description
I'm using python-client 4.0.0 and Kubernetes server 1.8.0 on minikube. I'm creating a custom resource definition using the kubernetes.client.ApiextensionsV1beta1Api.create_custom_resource_definition()
API.
This calls the following rest endpoint:
https://192.168.64.34:8443/apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions
with the following body:
{
'apiVersion': 'apiextensions.k8s.io/v1beta1',
'kind': 'CustomResourceDefinition',
'metadata': {
'name': 'alertmanagers.monitoring.coreos.com'
},
'spec': {
'group': 'monitoring.coreos.com',
'version': 'v1',
'scope': 'Namespaced',
'names': {
'plural': 'alertmanagers',
'singular': 'alertmanager',
'kind': 'AlertManager'
}
}
}
With Kubernetes 1.8.0, I get the following response:
{
"kind": "CustomResourceDefinition",
"apiVersion": "apiextensions.k8s.io/v1beta1",
"metadata": {
"name": "alertmanagers.monitoring.coreos.com",
"selfLink": "/apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions/alertmanagers.monitoring.coreos.com",
"uid": "898234e4-df84-11e7-b925-6275c77a1d00",
"resourceVersion": "6604",
"generation": 1,
"creationTimestamp": "2017-12-12T21:36:39Z"
},
"spec": {
"group": "monitoring.coreos.com",
"version": "v1",
"names": {
"plural": "alertmanagers",
"singular": "alertmanager",
"kind": "AlertManager",
"listKind": "AlertManagerList"},
"scope": "Namespaced"
},
"status": {
"conditions": null,
"acceptedNames": {"plural": "", "kind": ""}
}
}
which generates the following error in the python client:
File "/usr/local/lib/python3.6/site-packages/kubernetes/client/apis/apiextensions_v1beta1_api.py", line 57, in create_custom_resource_definition
(data) = self.create_custom_resource_definition_with_http_info(body, **kwargs)
File "/usr/local/lib/python3.6/site-packages/kubernetes/client/apis/apiextensions_v1beta1_api.py", line 136, in create_custom_resource_definition_with_http_info
collection_formats=collection_formats)
File "/usr/local/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 321, in call_api
_return_http_data_only, collection_formats, _preload_content, _request_timeout)
File "/usr/local/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 163, in __call_api
return_data = self.deserialize(response_data, response_type)
File "/usr/local/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 236, in deserialize
return self.__deserialize(data, response_type)
File "/usr/local/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 276, in __deserialize
return self.__deserialize_model(data, klass)
File "/usr/local/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 620, in __deserialize_model
kwargs[attr] = self.__deserialize(value, attr_type)
File "/usr/local/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 276, in __deserialize
return self.__deserialize_model(data, klass)
File "/usr/local/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 622, in __deserialize_model
instance = klass(**kwargs)
File "/usr/local/lib/python3.6/site-packages/kubernetes/client/models/v1beta1_custom_resource_definition_status.py", line 53, in __init__
self.conditions = conditions
File "/usr/local/lib/python3.6/site-packages/kubernetes/client/models/v1beta1_custom_resource_definition_status.py", line 101, in conditions
raise ValueError("Invalid value for `conditions`, must not be `None`")
ValueError: Invalid value for `conditions`, must not be `None`
Kubernetes 1.7.5 returns the following:
{
"kind": "CustomResourceDefinition",
"apiVersion": "apiextensions.k8s.io/v1beta1",
"metadata": {
"name": "alertmanagers.monitoring.coreos.com",
"selfLink": "/apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions/alertmanagers.monitoring.coreos.com",
"uid": "9c8a122b-df8b-11e7-b6e4-ca244fafa171",
"resourceVersion": "1730",
"creationTimestamp": "2017-12-12T22:27:17Z"
},
"spec": {
"group": "monitoring.coreos.com",
"version": "v1",
"names": {
"plural": "alertmanagers",
"singular": "alertmanager",
"kind": "AlertManager",
"listKind": "AlertManagerList"},
"scope": "Namespaced"
},
"status": {
"conditions": [],
"acceptedNames": {"plural": "", "kind": ""}
}
}
This works just fine. The difference is in the return value of the conditions
field
Now, there are a few things going on here:
- The server is returning a different value,
[]
for 1.7.5 andnull
for 1.8.0. - The swagger doc says both of these fields are required, but the server returns empty values.
- If the swagger doc was correct (which I doubt it is), the code generation may be wrong. I suppose it's open to interpretation. I don't think an empty array fulfills a "required value". The same applies to the empty strings for the
plural
andkind
members of theacceptedNames
dict. This really indicates no value, but the swagger says it's required.
This could possibly be split into separate issues. Let me know what's best in this case. Thanks!