Description
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
Labels
Type
Projects
Status