Skip to content

API Conventions: PUT does not create new resource #876

Open
@etiennedi

Description

@etiennedi

According to HTTP Verbs section of the API conventions documentation, using the HTTP Verb PUT, we can update or create a resource if it does not exist.

However, this doesn't seem to reflect reality. It might be true only for specific resources and endpoints, but we cannot seem to create a resource of type Deployment using the Kubernetes API on a Minikube test setup: (tested with Kubernetes Version 1.5.3 and 1.7.0)

Consider the following request:

PUT /apis/extensions/v1beta1/namespaces/default/deployments/test-deployment HTTP/1.1
Host: 127.0.0.1:8001
Content-Type: application/json

{
    "metadata": {
        "name": "test-deployment"
    },
    "spec": {
        "template": {
            "metadata": {
                "labels": {
                    "app": "test-app"
                }
            },
            "spec": {
                "containers": [
                    {
                        "name": "test-app",
                        "image": "nginx"
                    }
                ]
            }
        }
    }
}

This request fails if the resource does not exist. It succeeds if the resource has previously been created. Using PUT does therefore not seem to 'Create or Update a Resource', but rather only 'Update a Resource'.

Is the documentation incorrect or does it for some reason not apply to the resource type Deployments? (We have also tested with Services and seen the same behavior).

Thanks for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/contributor-guideIssues or PRs related to the contributor guidelifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.sig/architectureCategorizes an issue or PR as relevant to SIG Architecture.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions