mirror of
https://github.com/kubernetes/client-go.git
synced 2025-08-07 10:23:33 +00:00
Merge pull request #53474 from jekohk/clientgo-examples/crud-rollback
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. client-go/examples: Update CRUD Deployment sample **What this PR does / why we need it**: PR motivated by [#128](https://github.com/kubernetes/client-go/issues/128), namely updating the CRUD example with the following: - Add new step which demonstrates rolling back deployments - Cleanup retry loop for `Update()` steps - Make `-kubeconfig` flag optional when running example (same as out-of-cluster example) - Update `README.md` to reflect changes **Special notes for your reviewer**: My first Kubernetes contribution- feedback very welcome! **Release note**: ```release-note NONE ``` /cc @ahmetb @caesarxuchao Kubernetes-commit: 1ba331ef59220c3f50246a4bfe23350de2c2f5ed
This commit is contained in:
commit
19f27357d1
160
Godeps/Godeps.json
generated
160
Godeps/Godeps.json
generated
@ -372,323 +372,323 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/admissionregistration/v1alpha1",
|
"ImportPath": "k8s.io/api/admissionregistration/v1alpha1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/apps/v1",
|
"ImportPath": "k8s.io/api/apps/v1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/apps/v1beta1",
|
"ImportPath": "k8s.io/api/apps/v1beta1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/apps/v1beta2",
|
"ImportPath": "k8s.io/api/apps/v1beta2",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/authentication/v1",
|
"ImportPath": "k8s.io/api/authentication/v1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/authentication/v1beta1",
|
"ImportPath": "k8s.io/api/authentication/v1beta1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/authorization/v1",
|
"ImportPath": "k8s.io/api/authorization/v1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/authorization/v1beta1",
|
"ImportPath": "k8s.io/api/authorization/v1beta1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/autoscaling/v1",
|
"ImportPath": "k8s.io/api/autoscaling/v1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/autoscaling/v2beta1",
|
"ImportPath": "k8s.io/api/autoscaling/v2beta1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/batch/v1",
|
"ImportPath": "k8s.io/api/batch/v1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/batch/v1beta1",
|
"ImportPath": "k8s.io/api/batch/v1beta1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/batch/v2alpha1",
|
"ImportPath": "k8s.io/api/batch/v2alpha1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/certificates/v1beta1",
|
"ImportPath": "k8s.io/api/certificates/v1beta1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/core/v1",
|
"ImportPath": "k8s.io/api/core/v1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/extensions/v1beta1",
|
"ImportPath": "k8s.io/api/extensions/v1beta1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/imagepolicy/v1alpha1",
|
"ImportPath": "k8s.io/api/imagepolicy/v1alpha1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/networking/v1",
|
"ImportPath": "k8s.io/api/networking/v1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/policy/v1beta1",
|
"ImportPath": "k8s.io/api/policy/v1beta1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/rbac/v1",
|
"ImportPath": "k8s.io/api/rbac/v1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/rbac/v1alpha1",
|
"ImportPath": "k8s.io/api/rbac/v1alpha1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/rbac/v1beta1",
|
"ImportPath": "k8s.io/api/rbac/v1beta1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/scheduling/v1alpha1",
|
"ImportPath": "k8s.io/api/scheduling/v1alpha1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/settings/v1alpha1",
|
"ImportPath": "k8s.io/api/settings/v1alpha1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/storage/v1",
|
"ImportPath": "k8s.io/api/storage/v1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/storage/v1beta1",
|
"ImportPath": "k8s.io/api/storage/v1beta1",
|
||||||
"Rev": "858c4b937c6f0bd144f800f3fc659ee4e52790db"
|
"Rev": "9e94033b59b468be6b19ecf16d643134f7512166"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/errors",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/errors",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/meta",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/meta",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/resource",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/resource",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/testing",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/testing",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/testing/fuzzer",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/testing/fuzzer",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/testing/roundtrip",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/testing/roundtrip",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery",
|
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/announced",
|
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/announced",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/registered",
|
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/registered",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer",
|
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
|
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
|
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
|
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1alpha1",
|
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1alpha1",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/conversion",
|
"ImportPath": "k8s.io/apimachinery/pkg/conversion",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
|
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/conversion/unstructured",
|
"ImportPath": "k8s.io/apimachinery/pkg/conversion/unstructured",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/fields",
|
"ImportPath": "k8s.io/apimachinery/pkg/fields",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/labels",
|
"ImportPath": "k8s.io/apimachinery/pkg/labels",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/selection",
|
"ImportPath": "k8s.io/apimachinery/pkg/selection",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/types",
|
"ImportPath": "k8s.io/apimachinery/pkg/types",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/cache",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/cache",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/clock",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/clock",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/diff",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/diff",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/errors",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/errors",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/framer",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/framer",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/json",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/json",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/net",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/net",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/sets",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/sets",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/validation",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/validation",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/wait",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/wait",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/version",
|
"ImportPath": "k8s.io/apimachinery/pkg/version",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/watch",
|
"ImportPath": "k8s.io/apimachinery/pkg/watch",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
|
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
|
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
|
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
|
||||||
"Rev": "2daf8da27592e02bcfc0eae6e9b5045be9c1b9da"
|
"Rev": "0622870c23fc807836ffbf35f1827e479b15365b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kube-openapi/pkg/common",
|
"ImportPath": "k8s.io/kube-openapi/pkg/common",
|
||||||
|
@ -19,10 +19,11 @@ go_library(
|
|||||||
deps = [
|
deps = [
|
||||||
"//vendor/k8s.io/api/apps/v1beta1:go_default_library",
|
"//vendor/k8s.io/api/apps/v1beta1:go_default_library",
|
||||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
|
||||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||||
"//vendor/k8s.io/client-go/tools/clientcmd:go_default_library",
|
"//vendor/k8s.io/client-go/tools/clientcmd:go_default_library",
|
||||||
|
"//vendor/k8s.io/client-go/util/homedir:go_default_library",
|
||||||
|
"//vendor/k8s.io/client-go/util/retry:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@ go build -o ./app
|
|||||||
Now, run this application on your workstation with your local kubeconfig file:
|
Now, run this application on your workstation with your local kubeconfig file:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
./app
|
||||||
|
# or specify a kubeconfig file with flag
|
||||||
./app -kubeconfig=$HOME/.kube/config
|
./app -kubeconfig=$HOME/.kube/config
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -30,13 +32,19 @@ Running this command will execute the following operations on your cluster:
|
|||||||
1. **Create Deployment:** This will create a 2 replica Deployment. Verify with
|
1. **Create Deployment:** This will create a 2 replica Deployment. Verify with
|
||||||
`kubectl get pods`.
|
`kubectl get pods`.
|
||||||
2. **Update Deployment:** This will update the Deployment resource created in
|
2. **Update Deployment:** This will update the Deployment resource created in
|
||||||
previous step to set the replica count to 1 and add annotations. You are
|
previous step by setting the replica count to 1 and changing the container
|
||||||
encouraged to inspect the retry loop that handles conflicts. Verify the new
|
image to `nginx:1.13`. You are encouraged to inspect the retry loop that
|
||||||
replica count and `foo=bar` annotation with `kubectl describe deployment
|
handles conflicts. Verify the new replica count and container image with
|
||||||
demo`.
|
`kubectl describe deployment demo`.
|
||||||
3. **List Deployments:** This will retrieve Deployments in the `default`
|
3. **Rollback Deployment:** This will rollback the Deployment to the last
|
||||||
|
revision. In this case, it's the revision that was created in Step 1.
|
||||||
|
Use `kubectl describe` to verify the container image is now `nginx:1.12`.
|
||||||
|
Also note that the Deployment's replica count is still 1; this is because a
|
||||||
|
Deployment revision is created if and only if the Deployment's pod template
|
||||||
|
(`.spec.template`) is changed.
|
||||||
|
4. **List Deployments:** This will retrieve Deployments in the `default`
|
||||||
namespace and print their names and replica counts.
|
namespace and print their names and replica counts.
|
||||||
4. **Delete Deployment:** This will delete the Deployment object and its
|
5. **Delete Deployment:** This will delete the Deployment object and its
|
||||||
dependent ReplicaSet resource. Verify with `kubectl get deployments`.
|
dependent ReplicaSet resource. Verify with `kubectl get deployments`.
|
||||||
|
|
||||||
Each step is separated by an interactive prompt. You must hit the
|
Each step is separated by an interactive prompt. You must hit the
|
||||||
@ -55,6 +63,10 @@ Updating deployment...
|
|||||||
Updated deployment...
|
Updated deployment...
|
||||||
-> Press Return key to continue.
|
-> Press Return key to continue.
|
||||||
|
|
||||||
|
Rolling back deployment...
|
||||||
|
Rolled back deployment...
|
||||||
|
-> Press Return key to continue.
|
||||||
|
|
||||||
Listing deployments in namespace "default":
|
Listing deployments in namespace "default":
|
||||||
* demo-deployment (1 replicas)
|
* demo-deployment (1 replicas)
|
||||||
-> Press Return key to continue.
|
-> Press Return key to continue.
|
||||||
|
@ -22,23 +22,28 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
appsv1beta1 "k8s.io/api/apps/v1beta1"
|
appsv1beta1 "k8s.io/api/apps/v1beta1"
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
|
"k8s.io/client-go/util/homedir"
|
||||||
|
"k8s.io/client-go/util/retry"
|
||||||
// Uncomment the following line to load the gcp plugin (only required to authenticate against GKE clusters).
|
// Uncomment the following line to load the gcp plugin (only required to authenticate against GKE clusters).
|
||||||
// _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
|
// _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
kubeconfig := flag.String("kubeconfig", "", "absolute path to the kubeconfig file")
|
var kubeconfig *string
|
||||||
flag.Parse()
|
if home := homedir.HomeDir(); home != "" {
|
||||||
if *kubeconfig == "" {
|
kubeconfig = flag.String("kubeconfig", filepath.Join(home, ".kube", "config"), "(optional) absolute path to the kubeconfig file")
|
||||||
panic("-kubeconfig not specified")
|
} else {
|
||||||
|
kubeconfig = flag.String("kubeconfig", "", "absolute path to the kubeconfig file")
|
||||||
}
|
}
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig)
|
config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -66,7 +71,7 @@ func main() {
|
|||||||
Containers: []apiv1.Container{
|
Containers: []apiv1.Container{
|
||||||
{
|
{
|
||||||
Name: "web",
|
Name: "web",
|
||||||
Image: "nginx:1.13",
|
Image: "nginx:1.12",
|
||||||
Ports: []apiv1.ContainerPort{
|
Ports: []apiv1.ContainerPort{
|
||||||
{
|
{
|
||||||
Name: "http",
|
Name: "http",
|
||||||
@ -97,36 +102,53 @@ func main() {
|
|||||||
// 1. Modify the "deployment" variable and call: Update(deployment).
|
// 1. Modify the "deployment" variable and call: Update(deployment).
|
||||||
// This works like the "kubectl replace" command and it overwrites/loses changes
|
// This works like the "kubectl replace" command and it overwrites/loses changes
|
||||||
// made by other clients between you Create() and Update() the object.
|
// made by other clients between you Create() and Update() the object.
|
||||||
// 2. Modify the "result" returned by Create()/Get() and retry Update(result) until
|
// 2. Modify the "result" returned by Get() and retry Update(result) until
|
||||||
// you no longer get a conflict error. This way, you can preserve changes made
|
// you no longer get a conflict error. This way, you can preserve changes made
|
||||||
// by other clients between Create() and Update(). This is implemented below:
|
// by other clients between Create() and Update(). This is implemented below
|
||||||
|
// using the retry utility package included with client-go. (RECOMMENDED)
|
||||||
|
//
|
||||||
|
// More Info:
|
||||||
|
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#concurrency-control-and-consistency
|
||||||
|
|
||||||
|
retryErr := retry.RetryOnConflict(retry.DefaultRetry, func() error {
|
||||||
|
// Retrieve the latest version of Deployment before attempting update
|
||||||
|
// RetryOnConflict uses exponential backoff to avoid exhausting the apiserver
|
||||||
|
result, getErr := deploymentsClient.Get("demo-deployment", metav1.GetOptions{})
|
||||||
|
if getErr != nil {
|
||||||
|
panic(fmt.Errorf("Failed to get latest version of Deployment: %v", getErr))
|
||||||
|
}
|
||||||
|
|
||||||
for {
|
|
||||||
result.Spec.Replicas = int32Ptr(1) // reduce replica count
|
result.Spec.Replicas = int32Ptr(1) // reduce replica count
|
||||||
result.Spec.Template.Annotations = map[string]string{ // add annotations
|
result.Spec.Template.Spec.Containers[0].Image = "nginx:1.13" // change nginx version
|
||||||
"foo": "bar",
|
_, updateErr := deploymentsClient.Update(result)
|
||||||
}
|
return updateErr
|
||||||
|
})
|
||||||
if _, err := deploymentsClient.Update(result); errors.IsConflict(err) {
|
if retryErr != nil {
|
||||||
// Deployment is modified in the meanwhile, query the latest version
|
panic(fmt.Errorf("Update failed: %v", retryErr))
|
||||||
// and modify the retrieved object.
|
|
||||||
fmt.Println("encountered conflict, retrying")
|
|
||||||
result, err = deploymentsClient.Get("demo-deployment", metav1.GetOptions{})
|
|
||||||
if err != nil {
|
|
||||||
panic(fmt.Errorf("Get failed: %+v", err))
|
|
||||||
}
|
|
||||||
} else if err != nil {
|
|
||||||
panic(err)
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: You should sleep here with an exponential backoff to avoid
|
|
||||||
// exhausting the apiserver, and add a limit/timeout on the retries to
|
|
||||||
// avoid getting stuck in this loop indefintiely.
|
|
||||||
}
|
}
|
||||||
fmt.Println("Updated deployment...")
|
fmt.Println("Updated deployment...")
|
||||||
|
|
||||||
|
// Rollback Deployment
|
||||||
|
prompt()
|
||||||
|
fmt.Println("Rolling back deployment...")
|
||||||
|
// Once again use RetryOnConflict to avoid update conflicts
|
||||||
|
retryErr = retry.RetryOnConflict(retry.DefaultRetry, func() error {
|
||||||
|
result, getErr := deploymentsClient.Get("demo-deployment", metav1.GetOptions{})
|
||||||
|
if getErr != nil {
|
||||||
|
panic(fmt.Errorf("Failed to get latest version of Deployment: %v", getErr))
|
||||||
|
}
|
||||||
|
|
||||||
|
result.Spec.RollbackTo = &appsv1beta1.RollbackConfig{
|
||||||
|
Revision: 0, // can be specific revision number, or 0 for last revision
|
||||||
|
}
|
||||||
|
_, updateErr := deploymentsClient.Update(result)
|
||||||
|
return updateErr
|
||||||
|
})
|
||||||
|
if retryErr != nil {
|
||||||
|
panic(fmt.Errorf("Rollback failed: %v", retryErr))
|
||||||
|
}
|
||||||
|
fmt.Println("Rolled back deployment...")
|
||||||
|
|
||||||
// List Deployments
|
// List Deployments
|
||||||
prompt()
|
prompt()
|
||||||
fmt.Printf("Listing deployments in namespace %q:\n", apiv1.NamespaceDefault)
|
fmt.Printf("Listing deployments in namespace %q:\n", apiv1.NamespaceDefault)
|
||||||
|
Loading…
Reference in New Issue
Block a user