openshift/openshift-restclient-python

create Deployment not support apiVersion apps/v1

zenyeh opened this issue · 0 comments

Hi,
I had follow the instruction to create Service, PVC all is works. But the Deployment not success.

        # Create Deployment
        v1_deployment = dyn_client.resources.get(api_version='apps/v1', kind='Deployment')

        deployment_body = {
          "apiVersion": "apps/v1",
          "kind": "Deployment",
          "metadata": {
              .......
           }
        }
       v1_deployment.create(body=deployment_body, namespace='default')

The API Return with follow message:

openshift.dynamic.exceptions.BadRequestError: 400
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Audit-Id': '2b73d032-cc1c-4ecb-b1dc-aa9d22987602', 'Cache-Control': 'no-cache, private', 'Content-Type': 'application/json', 'X-Kubernetes-Pf-Flowschema-Uid': 'e890e6da-1787-4569-a79a-a59eda1f61fe', 'X-Kubernetes-Pf-Prioritylevel-Uid': '085dcf1d-1936-4cf9-bb44-d5c2ab1cdd13', 'Date': 'Wed, 25 Aug 2021 09:17:31 GMT', 'Content-Length': '592'})
HTTP response body: b'{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Deployment in version \"v1\" cannot be handled as a Deployment: v1.Deployment.Spec: v1.DeploymentSpec.Template: v1.PodTemplateSpec.Spec: v1.PodSpec.Containers: []v1.Container: v1.Container.Env: []v1.EnvVar: v1.EnvVar.v1.EnvVar.Value: ReadString: expects \" or n, but found 4, error found in #10 byte of ...|\"value\": 4}, {\"name\"|..., bigger context ...|e\": \"1Gi\"}, {\"name\": \"xxxxx\", \"value\": 4}, {\"name\": \"xxxxx\", \"value\": \"64Gi\"}, {|...","reason":"BadRequest","code":400}\n'

I think it should be apiVersion fixed with "v1" value in
openshift-restclient-python/openshift/dynamic/resource.py

Thank you.