feat/cert_manager_crds #211
Reference in New Issue
Block a user
No description provided.
Delete Branch "feat/cert_manager_crds"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
WIP: feat/cert_manager_crdsto feat/cert_manager_crdsSome refactoring to do, but not too far off!
Mostly use the CRDs properly and fix the return types.
But also the CertificateScore shoudl rely on the capability, not the other way around.
@@ -362,0 +432,4 @@cert_name: String,issuer_name: String,config: &CertificateManagementConfig,) -> Result<PreparationOutcome, PreparationError> {This should not return PreparationError and PreparationOutcome.
Most of the time it won't be used as part of a preparation phase.
@@ -362,0 +440,4 @@).await?;let cert = CertificateScore {I would have thought that CertificateScore depends on CertificateManagement capability, not the other way around.
The goal is to allow users to easily create certifiactes by calling CertificateScore on any Topology that implements CertificateManagement.
Or am I missing something?
I think this is a naming problem which makes the intent unclear.
I have CertificateCreationScore, CertificateIssuerScore, and CertificateManagementScore which depend on CertificateManagement capability, that way we can create certificates, issuers or ensure that CertificateManagement is ready on the Topology that implements the CertificateManagement trait.
The CertificateScore and IssuerScore are specific implentations for K8s that uses kubernetes CRDs which are applied as K8s resources, this is why further down the CertificateScore requires impl of K8sclient.
I modeled this off of postgresql which has a generic score.rs which calls topology.deploy() -> impl PostgreSQL for K8sAnywhereTopology -> K8sPostgreSQLScore.interpret()
@@ -362,0 +460,4 @@config: &CertificateManagementConfig,) -> Result<String, PreparationError> {let namespace = config.namespace.clone().unwrap();let certificate_gvk = GroupVersionKind {You should be using the CRD here, not crafting a GVK. See how it's done with NMstate and other CRDs.
@@ -362,0 +485,4 @@trace!("Secret Name {:#?}", secret_name);let secret_name: String = serde_json::from_value(secret_name.clone())If you were using the CRD properly here you would not have to mess with JSON, you would simply be walking the Rust struct directly.
@@ -381,0 +542,4 @@msg: "namespace is required".to_string(),})?;let gvk = GroupVersionKind {Same, use the CRD properly
@@ -0,0 +14,4 @@async fn ensure_certificate_management_ready(&self,config: &CertificateManagementConfig,) -> Result<PreparationOutcome, PreparationError>;It should be ensure_ready, no need for the long function name. Let's keep is standard-ish across Harmony. Eventually we will very likely extract the readiness state management in a separate trait.
@@ -0,0 +16,4 @@config: &CertificateManagementConfig,) -> Result<PreparationOutcome, PreparationError>;async fn create_issuer(Change the return types. This is something that will require cleanup across harmony eventually. But the semantic is incorrect here. This trait is not scoped in preparation.
@@ -0,0 +21,4 @@pub config: CertificateManagementConfig,}impl<T: Topology + K8sclient> Score<T> for CertificateScore {We want to be able to create certificates on anything implementing CertificateManagement, not just kubernetes.
This should be
@wjro Could you describe me how to test it (manually). I'll try to.
@jvtrudel I used the example/cert-manager to install, create an issuer and create a certificate. the trait also has a get_ca_cert function which you can call via topology.get_ca_cert()
@@ -0,0 +16,4 @@self_signed: true,};let cert_manager = CertificateManagementScore {Not the place
@@ -239,2 +234,3 @@resource.get(name).await// 1. Try namespaced first (if a namespace was provided)if let Some(ns) = namespace {else -> default namespace