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

Thirdpartyresources examples #29

Merged
merged 3 commits into from
Nov 11, 2016

Conversation

wfarr
Copy link
Contributor

@wfarr wfarr commented Nov 4, 2016

Adds a basic example for registering a ThirdPartyResource and interacting with a custom Resource type.

A follow-up PR will include a controller built on the same foundations, but a simple CRUD example will be useful for folks as well.

Tested against kubernetes 1.4.5 on GKE.

attn @caesarxuchao
cc @mkobetic @ibawt @lxfontes


This change is Reviewable

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@wfarr
Copy link
Contributor Author

wfarr commented Nov 4, 2016

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@wfarr
Copy link
Contributor Author

wfarr commented Nov 4, 2016

ref: #8


## Use Cases

ThirdPartyResources can be used to implement custom Resource types for your Kubernetes cluster.
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 add a hyperlink for ThirdPartyResources?

@wfarr
Copy link
Contributor Author

wfarr commented Nov 6, 2016

Good suggestion. Will do tomorrow
On Sun, Nov 6, 2016 at 12:28 AM Chao Xu notifications@github.com wrote:

@caesarxuchao commented on this pull request.

In examples/third-party-resources/README.md
#29 (review)
:

+This particular example demonstrates how to perform basic operations such as:
+
+* How to register a new ThirdPartyResource (custom Resource type)
+* How to create/get/list instances of your new Resource type (update/delete/etc work as well but are not demonstrated)
+
+## Running
+
+ +# assumes you have a working kubeconfig, not required if operating in-cluster +go run *.go -kubeconfig=$HOME/.kube/config +
+
+## Use Cases
+
+ThirdPartyResources can be used to implement custom Resource types for your Kubernetes cluster.

Add a hyperlink for ThirdPartyResources
http://kubernetes.io/docs/user-guide/thirdpartyresources/?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#29 (review),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAAy4d3HxFWmZYygDQ4NDgj8aGh6_yFks5q7VdYgaJpZM4Kp57Z
.

## Use Cases

ThirdPartyResources can be used to implement custom Resource types for your Kubernetes cluster.
These act like most other Resources in Kubernetes, and may be `kubectl apply`'d, etc.
Copy link
Member

Choose a reason for hiding this comment

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

Do you mean you can kubectl apply ThirdpartyResource, or instances of ThirdpartyResource? If it's the former case, I feel it doesn't need to be emphasized.

config.GroupVersion = &groupversion
config.APIPath = "/apis"
config.ContentType = runtime.ContentTypeJSON
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: api.Codecs}
Copy link
Member

Choose a reason for hiding this comment

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

Do we have to use the api.Codecs and api.Scheme, or can we create our own instances of them (e.g., code)? I'm not sure if adding a groupversion to the exisiting scheme will have any side effects.


// The code below is used only to work around a known problem with third-party
// resources and ugorji. If/when these issues are resolved, the code below
// should no longer be required.
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 link to the issue: ugorji/go#178

Copy link
Member

Choose a reason for hiding this comment

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

And could you say if the issue is resolved, you can just define the UnmarshalText(data []byte) error for Example and ExampleList, and don't need to define ExampleListCopy and ExampleCopy.

Copy link
Member

@caesarxuchao caesarxuchao left a comment

Choose a reason for hiding this comment

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

Looks good, just a few comments. Thank you @wfarr for contributing the example!

@deads2k
Copy link
Contributor

deads2k commented Nov 7, 2016

It's probably worth linking to the known gotchas: kubernetes/enhancements#95. Some of these issues are pretty bad.

@caesarxuchao
Copy link
Member

caesarxuchao commented Nov 11, 2016

nit: the folder name shouldn't include dashes (see code convention), I think thirdpartyresources is clear enough.

[edit]: Oops, we used "in-cluster" "out-cluster" in other two examples. I'll fix those.

@caesarxuchao
Copy link
Member

@wfarr I'll merge this example as it is. Please let me know if you plan working on the comments, otherwise I'll find time perhaps next week to improve it a little bit. Thanks again.

@caesarxuchao caesarxuchao merged commit febd848 into kubernetes:master Nov 11, 2016
@wfarr
Copy link
Contributor Author

wfarr commented Nov 14, 2016

I've opened #37 based on the feedback here.

@wfarr wfarr deleted the thirdpartyresources-examples branch November 14, 2016 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants