mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 13:45:06 +00:00
Can't replace a generic resource that is cluster scoped
It should be allowed to invoke kubectl replace with a JSON file that has no resource version set. Namespaced resources were working correctly, but cluster resources were silently failing to lookup the current state of the object to get the resource version because we weren't using NamespaceIfScoped(). Added a failing test.
This commit is contained in:
@@ -493,6 +493,31 @@ runTests() {
|
||||
kube::test::get_object_assert 'pod valid-pod' "{{(index .spec.containers 0).name}}" 'replaced-k8s-serve-hostname'
|
||||
#cleaning
|
||||
rm /tmp/tmp-valid-pod.json
|
||||
|
||||
## replace of a cluster scoped resource can succeed
|
||||
# Pre-condition: a node exists
|
||||
kubectl create -f - "${kube_flags[@]}" << __EOF__
|
||||
{
|
||||
"kind": "Node",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "node-${version}-test"
|
||||
}
|
||||
}
|
||||
__EOF__
|
||||
kubectl replace -f - "${kube_flags[@]}" << __EOF__
|
||||
{
|
||||
"kind": "Node",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "node-${version}-test",
|
||||
"annotations": {"a":"b"}
|
||||
}
|
||||
}
|
||||
__EOF__
|
||||
# Post-condition: the node command succeeds
|
||||
kube::test::get_object_assert "node node-${version}-test" "{{.metadata.annotations.a}}" 'b'
|
||||
kubectl delete node node-${version}-test
|
||||
|
||||
## kubectl edit can update the image field of a POD. tmp-editor.sh is a fake editor
|
||||
echo -e '#!/bin/bash\nsed -i "s/nginx/gcr.io\/google_containers\/serve_hostname/g" $1' > /tmp/tmp-editor.sh
|
||||
|
Reference in New Issue
Block a user