This fixes some scope isses that were introduced by shadowing vars inside anonymous functions as well as using a naked return.
Fixed by using unique err names and explicitly returning errors.
Additional improvement is using the HomeDir() util function provided by client-go instead of including a helper function at the bottom of this example.
Signed-off-by: John Kelly <jekohk@gmail.com>
Kubernetes-commit: e71c9f1b4beb06bcd3694163e6bf1764fb49edd6
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 updates the create-update-delete-deployment example with the following:
Add rollback step to demonstrate rolling back deployments with client-go.
Modify the for-loops used in both Update steps to Get() the latest version
of the Deployment from the server before attempting Update().
This is necessary because the object returned by Create() does
not have the new resourceVersion, causing the initial Update() to always fail
due to conflicting resource versions. Putting the Get() at the top of the
loop seems to fix this bug.
Make -kubeconfig flag optional if config is in default location, using the
same method found in the out-of-cluster example.
Patch is motivated by effort to improve client-go examples.
Signed-off-by: John Kelly <jekohk@gmail.com>
Kubernetes-commit: ce73088a718c30d8a3577f5d0521584b9c201e69
Remove custom-resources directory from client-go
Add TPR example back
Mention CRD is successor to TPR
Kubernetes-commit: bfa9ce4308ca897711eb1b822bd5f0e31bbef31d
Also add authenticate- prefix to auth samples.
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
Kubernetes-commit: 62d1251874cb259d38d727300ac4b2646c4122c8
Adding instructions for out-of-cluster example and making it work without
specifying the -kubeconfig argument if the home directory can be inferred.
This is part of the body of work improving the client library samples.
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
Kubernetes-commit: e59f05fe0ee6980c4bdaae76f5a77ef884bd2da1
This sample adds sample code for create/list/replace/delete operations for
Deployment resource for client-go library. This patch also contains
documentation explaining what the example application does and how it can be
executed.
This patch is part of the body of work improving the client library samples.
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
Kubernetes-commit: d75710f9f4d2e74979f6da07de31b02fae0392b0
Since NewSchemeBuilder registers the supplied Scheme transformation
functions synchronously, there's no need for a subsequent call
to (*SchemeBuilder).Register against the same instance.
Kubernetes-commit: 3a8e44bda80f74d674bf2df0b87cb4562a3587a0
This patch adds instructions for how to run the in-cluster client-go example.
To make this example executable, providing a Dockerfile and build steps so
that it can directly be run on minikube.
This is part of the body of work improving the client library samples.
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
Kubernetes-commit: 8604ed6d9906ebfb33206b55467db41c87e9f148
Demonstrates how to compose a controller out of cache.Controller,
cache.Indexer and a workqueue.
Kubernetes-commit: b39b3ba01675828c13bc0dea67d5114b4c225644