Skip to content

cannot create resources #4

@sebgoa

Description

@sebgoa

I tried to create a few things, here is an example to create a namespace:

import k8sclient
from k8sclient.rest import ApiException
import time

from pprint import pprint

k8sclient.configuration.host="http://127.0.0.1:8001"

api_instance=k8sclient.CoreV1Api()

body = k8sclient.V1Namespace() # V1Namespace | 
body.metadata = k8sclient.V1ObjectMeta()
body.metadata.name = "foobar"
body.spec = k8sclient.V1NamespaceSpec()
body.status = k8sclient.V1NamespaceStatus()

print body

try: 
    api_response = api_instance.create_core_v1_namespace(body)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling CoreV1Api->create_core_v1_namespace: %s\n" % e)

I just cannot get passed the content type error, even though reading the API docs I have all the right type and struct in place:

$ ./podcreate.py 
{'metadata': {'annotations': None,
              'cluster_name': None,
              'creation_timestamp': None,
              'deletion_grace_period_seconds': None,
              'deletion_timestamp': None,
              'finalizers': None,
              'generate_name': None,
              'generation': None,
              'labels': None,
              'name': 'foobar',
              'namespace': None,
              'owner_references': None,
              'resource_version': None,
              'self_link': None,
              'uid': None},
 'spec': {'finalizers': None},
 'status': {'phase': None}}
Exception when calling CoreV1Api->create_core_v1_namespace: (0)
Reason: Cannot prepare a request message for provided arguments.
                             Please check that your arguments match declared content type.

Same type of error when trying to create a pod. I get this on a v1.4.0 endpoint

any suggestions ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions