If you are using a released version of Kubernetes, you should refer to the docs that go with that version.
The latest release of this document can be found [here](http://releases.k8s.io/release-1.2/docs/devel/generating-clientset.md).Client-gen is an automatic tool that generates clientset based on API types. This doc introduces the use the client-gen, and the release cycle of the generated clientsets.
The workflow includes four steps:
pkg/apis/${GROUP}/${VERSION}/types.go
, mark the types (e.g., Pods) that you want to generate clients for with the // +genclient=true
tag. If the resource associated with the type is not namespace scoped (e.g., PersistentVolume), you need to append the nonNamespaced=true
tag as well.--input
to specify the groups and versions of the APIs you want to generate clients for, client-gen will then look into pkg/apis/${GROUP}/${VERSION}/types.go
and generate clients for the types you have marked with the genclient
tags. For example, run$ client-gen --input="api/v1,extensions/v1beta1" --clientset-name="my_release"
will generate a clientset named "my_release" which includes clients for api/v1 objects and extensions/v1beta1 objects. You can run $ client-gen --help
to see other command line arguments.
Create()
and Delete()
. You can manually add additional methods through the expansion interface. For example, this file adds additional methods to Pod's client. As a convention, we put the expansion interface and its methods in file ${TYPE}_expansion.go.--fake-clientset
is set. The fake clientset provides the default implementation, you only need to fake out the methods you care about when writing test cases.The output of client-gen inlcudes:
pkg/client/clientset_generated/
by default, and you can change the path via the --clientset-path
command line argument.pkg/client/clientset_generated/${clientset_name}/typed/generated/${GROUP}/${VERSION}/
At the 1.2 release, we have two released clientsets in the repo: internalclientset and release_1_2.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。