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

Observability Builder Props for Addons #833

Merged
merged 12 commits into from
Sep 18, 2023
Merged

Conversation

Howlla
Copy link
Contributor

@Howlla Howlla commented Aug 29, 2023

Issue #, if available:~

Description of changes: Modify some addons to export their Type for props.
Modify observability-builder.ts to accept props for each addon

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Collaborator

@elamaran11 elamaran11 left a comment

Choose a reason for hiding this comment

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

@Howlla Couple of questions for clarity

lib/addons/adot/index.ts Show resolved Hide resolved
lib/addons/coredns/index.ts Outdated Show resolved Hide resolved
lib/addons/kube-proxy/index.ts Show resolved Hide resolved
@Howlla
Copy link
Contributor Author

Howlla commented Aug 30, 2023

To support Fargate cluster deployment we need to be able to pass props for coredns and cert-manager.
Those are the 2 addons that need props in the argument. The rest props were exposed for future use cases that may require configuration values to be passed.

We can remove the export type from coredns and adot but then customers would have to define type again locally in their code

Copy link
Collaborator

@elamaran11 elamaran11 left a comment

Choose a reason for hiding this comment

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

LGTM. @shapirov103 Please check and run e2e

Copy link
Collaborator

@elamaran11 elamaran11 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@shapirov103 shapirov103 left a comment

Choose a reason for hiding this comment

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

@Howlla definitely a needed change!

The approach is a bit overloaded from the software engineering perspective and does not align well with the builder pattern which is supposed to abstract the complexity to build the object.

How about this style to enable prop overrides:

     ObservabilityBuilder.builder()
            .account(account)
            .region(region)
            .withAddOnProps(ObservabilityBuilder.ADDON.CoreDns, myCoreDnsProps)
            .withAddOnProps(ObservabilityBuilder.ADDON.CertManager, myCertManagerProps)
            .enableNativePatternAddOns()
            .addOns(...addOns)
            .build(scope, stackId);

Please let me know if you have any questions.

@Howlla
Copy link
Contributor Author

Howlla commented Sep 13, 2023

hi @shapirov103
Could you help me figure out how to properly type this function?

i tried the following way

 public withAddOnProps(addon:addons.HelmAddOn | addons.CoreAddOn, props: addons.CoreAddOnProps | addons.HelmAddOnProps ){
        return this.addOns(
            new addon(props)
        )
    }

but i get the following error

This expression is not constructable.
Not all constituents of type 'CoreAddOn | HelmAddOn' are constructable.
 Type 'CoreAddOn' has no construct signatures.
 ```

@shapirov103
Copy link
Collaborator

hi @shapirov103 Could you help me figure out how to properly type this function?

i tried the following way

 public withAddOnProps(addon:addons.HelmAddOn | addons.CoreAddOn, props: addons.CoreAddOnProps | addons.HelmAddOnProps ){
        return this.addOns(
            new addon(props)
        )
    }

but i get the following error

This expression is not constructable.
Not all constituents of type 'CoreAddOn | HelmAddOn' are constructable.
 Type 'CoreAddOn' has no construct signatures.

@Howlla I think the easiest approach is going to be something like:

class ObservabilityBuilder {
   
   private certManagerProps: CertManagerAddOnProps;
   private awsLoadbalancerProps: AwsLoadBalancerAddOnProps;
 ...

  public withCertManagerProps(props: CertManagerAddOnProps) {
     this.certManagerProps = props; // actually deep clone here to avoid side effects
  }

  private withAwsLoadBalancerProps(props: AwsLoadBalancerAddOnProps) {
    ...
  }
  
 
}


ObservabilityBuilder.builder()
    .withCertManagerProps( {someprops} )
    .withAwsLoadBalancerProps({some props})
    .enable...()

The downside is that for each addon there is an override method, but it makes it easy for the users to consume.

@Howlla
Copy link
Contributor Author

Howlla commented Sep 15, 2023

hi @shapirov103 Could you help me figure out how to properly type this function?
i tried the following way

 public withAddOnProps(addon:addons.HelmAddOn | addons.CoreAddOn, props: addons.CoreAddOnProps | addons.HelmAddOnProps ){
        return this.addOns(
            new addon(props)
        )
    }

but i get the following error

This expression is not constructable.
Not all constituents of type 'CoreAddOn | HelmAddOn' are constructable.
 Type 'CoreAddOn' has no construct signatures.

@Howlla I think the easiest approach is going to be something like:

class ObservabilityBuilder {
   
   private certManagerProps: CertManagerAddOnProps;
   private awsLoadbalancerProps: AwsLoadBalancerAddOnProps;
 ...

  public withCertManagerProps(props: CertManagerAddOnProps) {
     this.certManagerProps = props; // actually deep clone here to avoid side effects
  }

  private withAwsLoadBalancerProps(props: AwsLoadBalancerAddOnProps) {
    ...
  }
  
 
}


ObservabilityBuilder.builder()
    .withCertManagerProps( {someprops} )
    .withAwsLoadBalancerProps({some props})
    .enable...()

The downside is that for each addon there is an override method, but it makes it easy for the users to consume.

I have made the changes as per your recommendation Mikhail. Will require slight modification to the cdk-eks-observability-accelerator for these files.

Copy link
Collaborator

@shapirov103 shapirov103 left a comment

Choose a reason for hiding this comment

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

@Howlla Great work and thank you for address the kubeproxy and adot addon configurability.

@shapirov103
Copy link
Collaborator

@elamaran11 I put my approval on this, looks like it is pending requested changes from your side, please take a look.

Copy link
Collaborator

@elamaran11 elamaran11 left a comment

Choose a reason for hiding this comment

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

LGTM

@elamaran11 elamaran11 merged commit d0a26bd into aws-quickstart:main Sep 18, 2023
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.

3 participants