Derive Macro kube_derive::CustomResource [−][src]
#[derive(CustomResource)] { // Attributes available to this derive: #[kube] }
Expand description
A custom derive for kubernetes custom resource definitions.
This will generate a root object that implements the k8s_openapi::Metadata
and
k8s_openapi::Resource
traits for this type so it can be used with kube::Api
Additionally, it will implement a Foo::crd
function which will generate the,
CustomResourceDefinition at the specified api version (or v1 if unspecified).
Example
ⓘ
#[derive(CustomResource, Clone, Debug, PartialEq, Deserialize, Serialize)] #[kube(group = "clux.dev", version = "v1", namespaced)] struct FooSpec { prop1: String, prop2: Vec<bool>, #[serde(skip_serializing_if = "Option::is_none")] prop3: Option<i32>, }
This example creates a struct Foo
containing metadata, the spec,
and optionally status.
The struct should be named MyKindSpec for it to infer the Kind is MyKind normally.
But you can also use an arbitrary name if you supply #[kube(kind = "MyFoo")]
Setting printercolumns + subresources are also supported.
Try cargo-expand
to see your own macro expansion.