Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clientgo/examples: add ToC for examples #46883

Merged
merged 1 commit into from
Jun 16, 2017

Conversation

ahmetb
Copy link
Member

@ahmetb ahmetb commented Jun 2, 2017

Also add authenticate- prefix to auth samples. This patch could use some
improvement explaining workqueue and TPR examples as I'm not entirely sure.

/assign @caesarxuchao

Signed-off-by: Ahmet Alp Balkan ahmetb@google.com

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 2, 2017
@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. release-note-label-needed labels Jun 2, 2017
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note-label-needed labels Jun 2, 2017
@@ -79,7 +79,7 @@ if grep -rq '// import "k8s.io/kubernetes/' 'staging/'; then
exit 1
fi

for EXAMPLE in vendor/k8s.io/client-go/examples/{in-cluster,out-of-cluster,third-party-resources}; do
for EXAMPLE in vendor/k8s.io/client-go/examples/{authenticate-in-cluster,authenticate-out-of-cluster,third-party-resources}; do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The server url and port is also set up differently, so it's not just authenticate. Maybe call them in/out-cluster-client-configuration?

Copy link
Member Author

@ahmetb ahmetb Jun 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think authenticating is fine. The fact that you're pointing server URL/port is an implementation detail of authentication. The name change I made in this case was actually suggested by Jago (on the proposal doc) and I agree that it makes the point clear.

It also helps with discovery as the letter A is listed first on GitHub.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are ways to configure the client without supplying the authentication information, so authentication doesn't always equal to configuration. So i think "configuration" is slightly better.

It also helps with discovery as the letter A is listed first on GitHub.

We have your ToC now so we don't depend on the alphabetical order anymore :)

@@ -0,0 +1,36 @@
# client-go Usage Examples

This directory contains examples that cover examples of various use cases
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/examples of//

# client-go Usage Examples

This directory contains examples that cover examples of various use cases
and functionality for Go client library for Kubernetes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Go client library for Kubernetes/client-go/

This directory contains examples that cover examples of various use cases
and functionality for Go client library for Kubernetes.

### Authentication
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Configuration


- [**Third-party resources**](./third-party-resources): Register a custom
resource type with the API, create/update/query this custom type, and write a
controller to handle events for this custom resource type.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

events could be misleading, because Kubernetes have an API type called event. How about "write a controller drives the cluster state based on the changes to the custom resources."

- [**Third-party resources**](./third-party-resources): Register a custom
resource type with the API, create/update/query this custom type, and write a
controller to handle events for this custom resource type.
- [**Work queues**](./workqueue): Create a custom controller with a Watch for Pod events,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "Create a hotloop-free controller with the rate-limited workqueue and the informer framework", i don't think we need to mention "Watch for Pod".

And could you move this example before the tpr one? The latter is more complex.

Copy link
Member Author

@ahmetb ahmetb Jun 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the "Work queue" example just yet but the following 2 concepts are a bit too difficult to put here without any explanation:

  • hotloop-free controller
  • informer framework.

Is there a better way you think you can explain this example?

Create a hotloop-free controller with the rate-limited workqueue and the informer framework

I cannot infer any of this from workqueue/README.md which says:

This example demonstrates how to write a controller which follows the states
of watched resources.

It demonstrates how to:
 * combine the workqueue with a cache to a full controller
 * synchronize the controller on startup

:) Let me know if you have a better explanation and I will change/consolidate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tl;dr
Consider introduce informer in the description of the tpr example:
"The example demonstrates how to write a controller using the informer."

And update the description of workqueue example to:
"Combine the workqueue with the informer to write a controller. Workqueue makes sure the controller doesn't hot-loop on failed operations."


hotloop-free controller

I'm referring to this line, this makes sure the controller to exponential backoff before process the item again. Preventing hot-loop is a main feature of the workqueue.

IMO another important functionality of the workqueue is that it allow multiple workers to work in parallel, unfortunately the example doesn't show that.

informer framework

I mean the "k8s.io/client-go/tools/cache" package, which is also used in the thirdparty resource example, so we don't need to emphasis "informer framework" in the workqueue example.

combine the workqueue with a cache to a full controller

Here the "cache" means "k8s.io/client-go/tools/cache".

synchronize the controller on startup

It refers to this line. It's less important. Probably we should copy this line to the tpr example.

- [**Work queues**](./workqueue): Create a custom controller with a Watch for Pod events,
a rate limited Work Queue and an Informer with cache.

## How to run these examples
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The in-cluster won't work with these steps. And the user needs a kubeconfig ready. I suggest that we direct the readers to follow each example's README to learn how to run them.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 8, 2017
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 9, 2017
@ahmetb
Copy link
Member Author

ahmetb commented Jun 13, 2017

@caesarxuchao PTAL again. I have this comment still: #46883 (comment) I think we need to do a better job summarizing what workqueue example does (please suggest one), other than that I addressed your feedback.

@caesarxuchao
Copy link
Member

Also please note the recent changes to the examples. The tpr example is marked as deprecated, the successor is CRD.

@ahmetb
Copy link
Member Author

ahmetb commented Jun 13, 2017

@caesarxuchao yeah I incorporated the relevant changes. feel free to take a look again.

### Advanced Concepts

- [**Work queues**](./workqueue): Create a hotloop-free controller with the
rate-limited workqueue and the informer framework.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make "informer framework" a hyperlink to https://godoc.org/k8s.io/client-go/tools/cache#NewInformer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. But still my comment above stands. This sentence is very confusing to a beginner. We need to simplify.

@caesarxuchao
Copy link
Member

One nit and lgtm.

@caesarxuchao
Copy link
Member

There is a standalone example on informer: #44446. I think we can explain informer better after that's merged,

Also add authenticate- prefix to auth samples.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
@ahmetb
Copy link
Member Author

ahmetb commented Jun 13, 2017

Done.

@caesarxuchao
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 13, 2017
@caesarxuchao
Copy link
Member

/assign @deads2k for approval

It's mostly doc improvement for client-go, can we add the 1.7 milestone?

@deads2k
Copy link
Contributor

deads2k commented Jun 14, 2017

@caesarxuchao cutting it a little fine, but I think this is the last day of slush

/approve no-issue

@deads2k deads2k added this to the v1.7 milestone Jun 14, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahmetb, caesarxuchao, deads2k

Associated issue requirement bypassed by: deads2k

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 14, 2017
@ahmetb
Copy link
Member Author

ahmetb commented Jun 14, 2017

@k8s-bot pull-kubernetes-unit test this
looks like a flake.

@marun marun added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Jun 14, 2017
@ahmetb
Copy link
Member Author

ahmetb commented Jun 15, 2017

@k8s-bot pull-kubernetes-e2e-gce-etcd3 test this

@ahmetb
Copy link
Member Author

ahmetb commented Jun 15, 2017

@k8s-bot pull-kubernetes-federation-e2e-gce test this

@ahmetb
Copy link
Member Author

ahmetb commented Jun 15, 2017

It seems like this is stuck at the pull-kubernetes-federation-e2e-gce flake.

@ahmetb
Copy link
Member Author

ahmetb commented Jun 16, 2017

@caesarxuchao it looks like it's getting blocked on the flakes for the past 2 days. how do we get this merged? Should I rebase?

@caesarxuchao
Copy link
Member

/retest

@caesarxuchao
Copy link
Member

No rebase needed. We just retry the test. Sigh.

@ahmetb
Copy link
Member Author

ahmetb commented Jun 16, 2017

No luck :(

@caesarxuchao
Copy link
Member

Opened an issue: #47672

@caesarxuchao
Copy link
Member

/retest

@k8s-github-robot
Copy link

Automatic merge from submit-queue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants