Commit Graph

100 Commits

Author SHA1 Message Date
Patrick Ohly
5d289bc44c client-go/tools/cache: add APIs with context parameter
The context is used for cancellation and to support contextual logging.

In most cases, alternative *WithContext APIs get added, except for
NewIntegerResourceVersionMutationCache where code searches indicate that the
API is not used downstream.

An API break around SharedInformer couldn't be avoided because the
alternative (keeping the interface unchanged and adding a second one with
the new method) would have been worse. controller-runtime needs to be updated
because it implements that interface in a test package. Downstream consumers of
controller-runtime will work unless they use those test package.

Converting Kubernetes to use the other new alternatives will follow. In the
meantime, usage of the new alternatives cannot be enforced via logcheck
yet (see https://github.com/kubernetes/kubernetes/issues/126379 for the
process).

Passing context through and checking it for cancellation is tricky for event
handlers. A better approach is to map the context cancellation to the normal
removal of an event handler via a helper goroutine. Thanks to the new
HandleErrorWithLogr and HandleCrashWithLogr, remembering the logger is
sufficient for handling problems at runtime.

Kubernetes-commit: 4638ba971661497b147906b8977ae206c9dd6e44
2024-07-26 15:26:00 +02:00
Patrick Ohly
70a4950f35 remove import doc comments
The "// import <path>" comment has been superseded by Go modules.
We don't have to remove them, but doing so has some advantages:

- They are used inconsistently, which is confusing.
- We can then also remove the (currently broken) hack/update-vanity-imports.sh.
- Last but not least, it would be a first step towards avoiding the k8s.io domain.

This commit was generated with
   sed -i -e 's;^package \(.*\) // import.*;package \1;' $(git grep -l '^package.*// import' | grep -v 'vendor/')

Everything was included, except for
   package labels // import k8s.io/kubernetes/pkg/util/labels
because that package is marked as "read-only".

Kubernetes-commit: 8a908e0c0bd96a3455edf7e3b5f5af90564e65b0
2024-12-02 14:43:58 +01:00
googs1025
1b8aded77b chore(leader-election): modify leader-election comment to OnStoppedLeading callback is always called when the LeaderElector exits, even if it did not start leading.
Kubernetes-commit: 7d2fbc7cfd49bca7d58160ed25dfd1f838629bb9
2024-09-30 09:38:10 +08:00
Stephen Kitt
105983d93c client-go: remove obsolete auth plugins from examples
The azure and gcp plugins no longer do anything other than point to
the corresponding external credential plugins. Client code should no
longer try to load them, so they should be removed from the examples.

Signed-off-by: Stephen Kitt <skitt@redhat.com>

Kubernetes-commit: 4531c6de760ec42941d9f509103f1b29c88bfae0
2024-10-03 11:08:52 +02:00
Alvaro Aleman
9aa3aae99d Use the generic/typed workqueue throughout
This change makes us use the generic workqueue throughout the project in
order to improve type safety and readability of the code.

Kubernetes-commit: 6d0ac8c561a7ac66c21e4ee7bd1976c2ecedbf32
2024-04-28 18:26:18 +02:00
José Carlos Chávez
76174b8af8 chore: adds consistent vanity import to files and provides tooling for verifying and updating them. (#120642)
* chore: drops update vanity imports from script.

* chore: changes copyright year to 2024.

* chore: makes lint happy.

Kubernetes-commit: 6d6398ef9266abce3518a4c9a3d4e4d8feeffdc1
2024-02-08 13:38:07 +00:00
Arpit Agrawal
f4a635a743 Update README.md
The Service Account Token link in the readme is broken and refers to a page that no longer exists.
In this PR I updated the correct link in the readme

Kubernetes-commit: 279a663f948337da156f544b74e41928ad66f9ef
2023-08-11 17:46:28 +05:30
Mark McLoughlin
3f66212017 client-go: remove reference to TPR in examples
5 years after third party resources were removed, we're probably just confusing readers with this reference.

Kubernetes-commit: d21fc6e762276747e3306cfaf27b0ce1201071c2
2022-09-16 15:14:13 +01:00
Davanum Srinivas
98e81a7784 Remove references to openstack and cinder
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 9bbf01bae93600d3314bce0acbff1f3a0a42e74b
2022-08-08 16:01:59 -04:00
0xff-dev
c94a539bfb use constant NamespaceDefault instead of variable namespace
Kubernetes-commit: 4bdca5689f65597f28a99f3610dd4e43fbc9cd7c
2022-08-04 14:18:47 +08:00
astraw99
a9a86ad864 unify worker num to workers
Kubernetes-commit: e6df935fd30c56a8ece0da6152c60fc725d942b7
2021-08-09 10:48:53 +08:00
Nikhita Raghunath
18b053fa9a Revert "Merge pull request #982 from sprutner/patch-1"
This reverts commit e7ebdbcfc7, reversing
changes made to 3fae6f05ac.
2021-06-22 13:41:22 +05:30
Seth Rutner
d5f964d7ae
Update README.md
This won't work if the ImagePullPolicy is not set to never as it tries to pull it.
2021-06-09 12:43:39 -07:00
0daryo
2de7d23dca Remove non-existent log option
Kubernetes-commit: 3fbd3cf1cd55f99970a984f106006a02cce2c97b
2021-03-06 16:23:06 +09:00
Haowei Cai
7dddf976b8 fix the fake client example: how to handle a race between the fake client and informer
Note that the fake client isn't designed to work with informer. It
doesn't support resource version. It's encouraged to use a real client
in an integration/E2E test if you need to test complex behavior with
informer/controllers.

Kubernetes-commit: 942bc9b32e39bb9c6ca045c02b48cc84dfa86633
2020-10-26 22:50:32 -07:00
Eddie Zaneski
a6ca2f510c Update client-go out of cluster example
Signed-off-by: Eddie Zaneski <eddiezane@gmail.com>

Kubernetes-commit: 522cba454b69c80d8a336026d6bc92a93955cbe1
2020-08-12 17:55:26 -06:00
yttan
3f4798d9ac fix golint failures for staging/src/k8s.io/client-go/examples/workqueue
Kubernetes-commit: d3db1ec12d1156fbdefacb15b5c5c6d31523a163
2020-09-08 15:01:45 +08:00
Davanum Srinivas
75fea27a27 switch over k/k to use klog v2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 442a69c3bdf6fe8e525b05887e57d89db1e2f3a5
2020-04-17 15:25:06 -04:00
ashish-billore
b284cb9910 Updated command to start in-cluster deployment
Updated the --image-pull-policy=Never option with default
'IfNotPresent'. 'Never' causes the pod to be in
state: ErrImageNeverPull

Kubernetes-commit: 7400cf937b9fcc31dc29caa8d90800940602b934
2019-09-17 19:58:02 +09:00
Jordan Liggitt
1faf9e8d03 client-go dynamic context
Kubernetes-commit: 6fa54d715fbc992afb483e71d450d5dbd66990eb
2020-03-06 01:27:11 -05:00
Jordan Liggitt
67a40b9a1a client-go dynamic client: update DeleteOptions callers
Kubernetes-commit: b19dc3a474e840340cb357f5ea9f4e575bad888d
2020-03-06 10:20:40 -05:00
Mike Danese
5c80d48932 automated refactor
Kubernetes-commit: c58e69ec791e4dd8a1298d5c2cc0649cf9176f67
2020-03-01 09:24:42 -08:00
Mike Danese
6659ae5216 generated: run refactor
Kubernetes-commit: 25651408aeadf38c3df7ea8c760e7519fd37d625
2020-02-08 12:30:21 -05:00
Mike Danese
60a0346672 generated: run refactor
Kubernetes-commit: 3aa59f7f3077642592dc8a864fcef8ba98699894
2020-02-07 18:16:47 -08:00
Mengjiang Bao
c51c673cf8 chore(*): update election example (#82821)
* feat(*): simplify leader election example

* chore(*): fix with comment

* chore(*): add os.exit

* chore(*): fix typo

Kubernetes-commit: 1185012da65edf802f22aff24141c0466a2a3ac8
2019-10-14 07:06:53 +00:00
yaron2
67a52dfbe2 fix auth import statement
Kubernetes-commit: 6b9ec1c59e1965f4253ecb1e8b600bc582780df9
2019-09-16 11:00:36 -07:00
ashish-billore
6078bde84c Corrected the pod reporting and messages
It is inconsistent and confusing to report pod count from all
namespaces but report message for only default namespace.
Added the namespace (default) reporting to clarify this.
Updated comments for usage clarity.

Kubernetes-commit: 31e427b54c500f2e532ebeb1990eb7580bf86729
2019-09-20 19:18:17 +09:00
Yassine TIJANI
7ee6383729 move WaitForCacheSync to the sharedInformer package
Signed-off-by: Yassine TIJANI <ytijani@vmware.com>

Kubernetes-commit: 7e4c3096fe71afc6a23c273b3309ed5db7289d8c
2019-08-16 21:15:53 +02:00
Sukeesh
94daee0164 Cleanup: Audit log and error capitalization
Kubernetes-commit: 346fdbccf0ac06ab3fa0e51ab3b92fdc041bb4cc
2019-06-30 11:56:27 +09:00
Vladimir Vivien
abf396d787 Create-update-delete-deployment example using dynamic package
Kubernetes-commit: 103c71a2b576cf2557418df3f235744b1d7f1e4e
2019-04-12 13:37:18 -04:00
Shovan Maity
778d000492 Update client-go example README.md (fix typo)
Signed-off-by: Shovan Maity <shovan.maity@mayadata.io>

Kubernetes-commit: 25dec55d61190ad1916de61bf7a06d26327bac76
2019-05-09 19:30:43 +05:30
aaa
90da71b8c3 Update some readme.md files in client-go
Kubernetes-commit: 1c424fddc2a564588fc5b32731cf4c0e52f86ef7
2019-04-09 06:56:52 -04:00
Kyle Bai
efa2d6bde2 client-go: update leader election example
Kubernetes-commit: 8a82b21f46c261ac920074274b213a888f47c256
2019-03-10 22:44:45 +08:00
Tomas Nozicka
1abd19a10b Fix client-go fake client example flake
Kubernetes-commit: 0b116d915f12181e36f02ed3a87767513074e270
2019-03-06 08:36:15 +01:00
Jordan Liggitt
e6881e4a02 Update client callers to use explicit versions
Kubernetes-commit: d1e865ee341ba37469efed8c935e22e2b483eec2
2019-02-22 10:27:46 -05:00
SneakyFish5
84710d1308 fix: use pod instead of node
Kubernetes-commit: 195547f872c288f5b81e436be6bd1f0feade5315
2018-08-09 11:48:18 -05:00
Ben Moss
6320f74bd6 Update deprecated links
Kubernetes-commit: 34ac4d9ee9fed65d770403fff4cb037253fc5d09
2019-02-04 13:28:31 -05:00
mattjmcnaughton
d5549376b9 Improve in-cluster-client-conf client-go docs
Make a small formatting change to make it clear that you must take the
RBAC actions regardless of whether you're using Minikube or not.

Kubernetes-commit: fb4148e5f81057cd6a2b1e2840e3562516834446
2019-02-10 15:17:45 -05:00
Carlos Mendible
26439bcc00 Added missing quote
Added missing quote cause uncommenting the line to to load all auth plugins resulted in a syntax error.

Kubernetes-commit: a968f52611a36925c3736652a6e9d786903ce090
2019-02-02 13:52:48 +01:00
Jordan Liggitt
3e0afcd74e Add docs around importing auth plugins
Kubernetes-commit: 34e7af7ec6154694cb760a0bb76be71695f03f7e
2019-01-16 22:29:29 -05:00
Johannes Würbach
164b2f8a05 Remove outdated rollback step from CRUD deployment example
The code was already removed, remove the rollback step also from the README

Kubernetes-commit: e6e3b78f7549d6bae33664af87bf34fd425528c3
2019-01-02 20:52:34 +01:00
Davanum Srinivas
74cd8bbeee Move from glog to klog
- Move from the old github.com/golang/glog to k8s.io/klog
- klog as explicit InitFlags() so we add them as necessary
- we update the other repositories that we vendor that made a similar
change from glog to klog
  * github.com/kubernetes/repo-infra
  * k8s.io/gengo/
  * k8s.io/kube-openapi/
  * github.com/google/cadvisor
- Entirely remove all references to glog
- Fix some tests by explicit InitFlags in their init() methods

Change-Id: I92db545ff36fcec83afe98f550c9e630098b3135

Kubernetes-commit: 954996e231074dc7429f7be1256a579bedd8344c
2018-11-09 13:49:10 -05:00
SataQiu
ed35c194bb Remove the redundant space
Kubernetes-commit: c9bc62542892a4f568a60cd423807e078c4e3ac9
2018-09-30 11:09:32 +08:00
Davanum Srinivas
61a24777f8 Add missing step to in-cluster-client-configuration example
If the permissions are not setup correctly the example fails.

Change-Id: I167ef68be66f8b56740236ae475c3b7fdcc0dfb5

Kubernetes-commit: d222c310aaa4ce8777094f4a37a920982aff794d
2018-09-28 14:46:01 -04:00
Nikhita Raghunath
933d577128 client-go/examples/fake-client: add doc.go to fix go build warnings
The fakeclient package does not have any non-test go files. This
causes `go build` to give a warning: `no non-test Go files in ...`.
This also causes the publishing bot to fail.

This PR adds a dummy doc.go file in the package to avoid this warning.

Kubernetes-commit: 764ae69671428987d77898b2d3c48c6c003e2fd4
2018-06-24 21:04:07 +05:30
Jonathan Basseri
c72a3893b1 Add client-go example using fake client in test.
This adds an example showing the steps needed to get a working
SharedInformerFactory with a fake client for testing.

Kubernetes-commit: aed487b42d1b49df9ac01f7234896f6d1b4da166
2018-06-20 18:35:57 -07:00
AnubhaKushwaha
c9a11b02aa Upgraded to apps/v1 and removed rollback example
Kubernetes-commit: 08c697283125dfa138746df4b286ce7574a9bed1
2018-02-25 14:32:58 +05:30
Kubernetes Publisher
fff8c3d73e sync: initially remove files BUILD */BUILD BUILD.bazel */BUILD.bazel 2018-03-15 09:19:38 +00:00
Jeff Grafton
fca8bb2928 Autogenerated: hack/update-bazel.sh
Kubernetes-commit: ef56a8d6bb3800ab7803713eafc4191e8202ad6e
2018-02-16 13:43:01 -08:00
halfcrazy
b6a34c5a00 fix typo in client-go
Kubernetes-commit: 86801dee64215e76080fe8df83ffd1fb7df9e093
2018-02-01 02:33:45 +08:00