mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-01 07:07:15 +00:00
client-go: use retry util in CRUD example
This updates the create-update-delete-deployment example with the following: Make use of client-go retry util in Update() steps instead of simple for loops. Using RetryOnConflict is generally better practice as it won't become stuck in a retry loop and uses exponential backoff to prevent exhausting the apiserver. Instead of changing annotations to demonstrate Updates/Rollbacks, change the container image as it is less confusing for readers and a better real-world example. Improve comments and README to reflect above changes. Signed-off-by: John Kelly <jekohk@gmail.com> Kubernetes-commit: 94f5bcf6f77d5b35074dfab47b5de37096d8ee00
This commit is contained in:
committed by
Kubernetes Publisher
parent
4e80b27156
commit
ddf6c35ca5
@@ -29,18 +29,19 @@ Now, run this application on your workstation with your local kubeconfig file:
|
||||
|
||||
Running this command will execute the following operations on your cluster:
|
||||
|
||||
1. **Create Deployment:** This will create a 2 replica Deployment with
|
||||
annotation `fizz=buzz`. Verify with `kubectl get pods`.
|
||||
1. **Create Deployment:** This will create a 2 replica Deployment. Verify with
|
||||
`kubectl get pods`.
|
||||
2. **Update Deployment:** This will update the Deployment resource created in
|
||||
previous step to set the replica count to 1 and update annotations. You are
|
||||
encouraged to inspect the retry loop that handles conflicts. Verify the new
|
||||
replica count and `foo=bar` annotation with `kubectl describe deployment
|
||||
demo`.
|
||||
previous step by setting the replica count to 1 and changing the container
|
||||
image to `nginx:1.13`. You are encouraged to inspect the retry loop that
|
||||
handles conflicts. Verify the new replica count and container image with
|
||||
`kubectl describe deployment demo`.
|
||||
3. **Rollback Deployment:** This will rollback the Deployment to the last
|
||||
revision, in this case the revision created in Step 1. Use `kubectl describe`
|
||||
to verify the original annotation `fizz=buzz`. Also note the 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.
|
||||
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.
|
||||
5. **Delete Deployment:** This will delete the Deployment object and its
|
||||
|
Reference in New Issue
Block a user