Make kubectl apply create resources if not found

This commit is contained in:
Janet Kuo
2015-11-04 18:29:56 -08:00
parent c095e35f1b
commit 37f35d9342
6 changed files with 81 additions and 5 deletions

View File

@@ -635,6 +635,18 @@ runTests() {
# Clean up
kubectl delete rc,hpa frontend
## kubectl apply should create the resource that doesn't exist yet
# Pre-Condition: no POD is running
kube::test::get_object_assert pods "{{range.items}}{{$id_field}}:{{end}}" ''
# Command: apply a pod "test-pod" (doesn't exist) should create this pod
kubectl apply -f hack/testdata/pod.yaml "${kube_flags[@]}"
# Post-Condition: pod "test-pod" is running
kube::test::get_object_assert 'pods test-pod' "{{${labels_field}.name}}" 'test-pod-label'
# Post-Condition: pod "test-pod" has configuration annotation
[[ "$(kubectl get pods test-pod -o yaml "${kube_flags[@]}" | grep kubectl.kubernetes.io/last-applied-configuration)" ]]
# Clean up
kubectl delete pods test-pod "${kube_flags[@]}"
##############
# Namespaces #
##############