-
Is the correct workflow to maintain a CRD spec both as a YAML file and as a Rust struct with the CustomResource derive? Or can the YAML be generated from the Rust struct (or the Rust struct from the YAML)? Or can the CRD be applied to the cluster by a Rust program that skips the YAML formatting altogether? Thanks. I'm just getting started. I hope the question is clear. I'm trying to understand the developer workflow for keeping apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: mycrd in sync with #[derive(CustomResource, Serialize, Deserialize, Debug, PartialEq, Clone, JsonSchema)]
#[kube(
group = "example.com",
version = "v1",
kind = "MyCrd",
plural = "mycrds",
derive = "PartialEq",
namespaced
)]
#[kube(status = "MyCrdStatus")]
pub struct MyCrdSpec {
// ...
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
You can generate the yaml from the rust struct (not the other way around), and you should commit that generated file, because the definition is usually applied out of band (crd write perms are usually cluster admin type permissions, and you generally don't want your controller to have it). I recommend a small bin entry point to generate this file like crdgen in controller-rs.
You can do this, but for the permission issue, this is generally not good practice. |
Beta Was this translation helpful? Give feedback.
-
crdgen.rs of controller-rs generates YAML for the DocumentSpec. |
Beta Was this translation helpful? Give feedback.
You can generate the yaml from the rust struct (not the other way around), and you should commit that generated file, because the definition is usually applied out of band (crd write perms are usually cluster admin type permissions, and you generally don't want your controller to have it).
I recommend a small bin entry point to generate this file like crdgen in controller-rs.
You ca…