newrelic-experimental / newrelic-eks-blueprints-addon

This repository contains the source code for the New Relic AddOn for AWS EKS Blueprints. EKS Blueprints is a CDK construct that makes it easy for customers to configure and deploy New Relic's Kubernetes integration as part of an EKS Blueprint cluster on Amazon EKS
Apache License 2.0
3 stars 1 forks source link

Apply reasonable default for `newrelicClusterName` configuration parameter #10

Closed shapirov103 closed 2 years ago

shapirov103 commented 2 years ago

Summary

At present NewRelicAddOn requires passing the cluster name as an add-on option. That makes it hard to reuse across multiple environments. Clustername could be defaulted to the EKS cluster name or to the stack name to facilitate reuse of the add-on across envs.

With newRelicClusterName being a required field customers will have to customize blueprint for each deployment.

Examples: 1) the current approach. Note that the need for the field is preventing customers from adding NewRelicAddOn into the master blueprint and requires to customize each deployment:

        const blueprint = blueprints.EksBlueprint.builder()
            .account(account) // the supplied default will fail, but build and synth will pass
            .region('us-west-1')
            .addOns(...)
          ;

        blueprints.CodePipelineStack.builder()
            .name("blueprints-eks-pipeline")
            .owner("aws-samples")
            .repository({
                repoUrl: 'cdk-eks-blueprints-patterns',
                credentialsSecretName: 'github-token',
                targetRevision: 'main'
            })
            .wave( {
                id: "dev",
                stages: [
                    { id: "dev-west-1", stackBuilder: blueprint.clone('us-west-1')
                        .addOns(new NewRelicAddOn({
                            version: "4.2.0-beta",
                            newRelicClusterName: "dev-west-1",
                            awsSecretName: "newrelic-pixie-combined",
                        }))
                    },
                    { id: "dev-east-2", stackBuilder: blueprint.clone('us-east-2')
                        .addOns(new NewRelicAddOn({
                            version: "4.2.0-beta",
                            newRelicClusterName: "dev-east-2",
                            awsSecretName: "newrelic-pixie-combined",
                        }))
                    },
                ]
            })
            // other waves
            .build(scope, "pipeline", props);

2) If the field gets a sane default. Note that the addon is now part of the master blueprint and no customizations are needed for each deployment (assuming the secret is replicated into the target regions):

 const blueprint = blueprints.EksBlueprint.builder()
            .account(account) // the supplied default will fail, but build and synth will pass
            .region('us-west-1')
            .addOns(
                new NewRelicAddOn({
                    version: "4.2.0-beta",
                    newRelicClusterName: id, // assuming this is not specified.
                    awsSecretName: "newrelic-pixie-combined"
                })
            );

    blueprints.CodePipelineStack.builder()
            .name("blueprints-eks-pipeline")
            .owner("aws-samples")
            .repository({
                repoUrl: 'cdk-eks-blueprints-patterns',
                credentialsSecretName: 'github-token',
                targetRevision: 'main'
            })
            .wave( {
                id: "dev",
                stages: [
                    { id: "dev-west-1", stackBuilder: blueprint.clone('us-west-1')},
                    { id: "dev-east-2", stackBuilder: blueprint.clone('us-east-2')},                  
                ]
            })
            // other waves
            .build(scope, "pipeline", props);

Desired Behavior

Ability to specify the add-on on the master blueprint level allows customers to control NewRelic lifecycle from a single location in the code.

Possible Solution

Make the newrelicClusterName optional with reasonable defaults that could be derived from the EKS cluster name or from the blueprint stack id. clusterInfo.cluster.clusterName

Additional context

bpschmitt commented 2 years ago

Thank you for submitting this @shapirov103! I ran into this issue recently as well and will be working on an update soon to improve it.

bpschmitt commented 2 years ago

@shapirov103 the New Relic Addon version 1.0.8 will now default to the EKS cluster name if no cluster name is provided.