From 25a5798556ec9f019fb6baf430258939ae78a1ea Mon Sep 17 00:00:00 2001 From: Eli Date: Mon, 18 Jul 2022 17:06:55 -0500 Subject: [PATCH 01/16] addon start --- .../flagger/custom-canary-resource.yaml | 61 +++++++++++++++++ lib/addons/flagger/my_new_addon.ts | 65 +++++++++++++++++++ lib/teams/application-team/index.ts | 11 ++++ 3 files changed, 137 insertions(+) create mode 100644 lib/addons/flagger/custom-canary-resource.yaml create mode 100644 lib/addons/flagger/my_new_addon.ts create mode 100644 lib/teams/application-team/index.ts diff --git a/lib/addons/flagger/custom-canary-resource.yaml b/lib/addons/flagger/custom-canary-resource.yaml new file mode 100644 index 000000000..6dc394c1a --- /dev/null +++ b/lib/addons/flagger/custom-canary-resource.yaml @@ -0,0 +1,61 @@ +apiVersion: flagger.app/v1beta1 +kind: Canary +metadata: + name: podinfo ##INSERT YOURS ELI + namespace: test +spec: + # service mesh provider can be: kubernetes, istio, appmesh, nginx, gloo + provider: kubernetes + # deployment reference + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: podinfo ##INSERT YOURS ELI + # the maximum time in seconds for the canary deployment + # to make progress before rollback (default 600s) + progressDeadlineSeconds: 60 + # HPA reference (optional) + autoscalerRef: + apiVersion: autoscaling/v2beta2 + kind: HorizontalPodAutoscaler + name: podinfo ##INSERT YOURS ELI + service: + port: 9898 + portDiscovery: true + analysis: + # schedule interval (default 60s) + interval: 30s + # max number of failed checks before rollback + threshold: 2 + # number of checks to run before rollback + iterations: 10 + # Prometheus checks based on + # http_request_duration_seconds histogram + metrics: + - name: request-success-rate + # minimum req success rate (non 5xx responses) + # percentage (0-100) + thresholdRange: + min: 99 + interval: 1m + - name: request-duration + # maximum req duration P99 + # milliseconds + thresholdRange: + max: 500 + interval: 30s + # acceptance/load testing hooks + webhooks: + - name: smoke-test + type: pre-rollout + url: http://flagger-loadtester.test/ + timeout: 15s + metadata: + type: bash + cmd: "curl -sd 'anon' http://podinfo-canary.test:9898/token | grep token" ##INSERT YOURS ELI + - name: load-test + url: http://flagger-loadtester.test/ + timeout: 5s + metadata: + type: cmd + cmd: "hey -z 1m -q 10 -c 2 http://podinfo-canary.test:9898/" ##INSERT YOURS ELI \ No newline at end of file diff --git a/lib/addons/flagger/my_new_addon.ts b/lib/addons/flagger/my_new_addon.ts new file mode 100644 index 000000000..473ff3209 --- /dev/null +++ b/lib/addons/flagger/my_new_addon.ts @@ -0,0 +1,65 @@ +// filename=lib/kubevious_addon.ts +import 'source-map-support/register'; +import * as blueprints from '../../../lib'; +import { Construct } from 'constructs'; +import { setPath } from '../../utils'; + +/** + * User provided options for the Helm Chart + */ +export interface FlaggerAddOnProps extends blueprints.HelmAddOnUserProps { + version?: string, + ingressEnabled?: boolean, + flaggerServiceType?: string, +} + +/** + * Default props to be used when creating the Helm chart + */ +export const defaultProps: blueprints.HelmAddOnProps & FlaggerAddOnProps = { + name: "flagger-progressive-delivery", // Internal identifyer for our add-on + namespace: "flagger", // Namespace used to deploy the chart + chart: "flagger", // Name of the Chart to be deployed + version: "1.0", // version of the chart + release: "flagger", // Name for our chart in Kubernetes + repository: "https://flagger.io", // HTTPS address of the chart repository + values: {}, // Additional chart values + + ingressEnabled: false, + flaggerServiceType: "ClusterIP", +} + +/** + * Main class to instantiate the Helm chart + */ +export class FlaggerAddOn extends blueprints.HelmAddOn { + + readonly options: FlaggerAddOnProps + + constructor(props: FlaggerAddOnProps) { + super({ ...defaultProps, ...props }); + this.options = this.props as FlaggerAddOnProps; + } + + deploy(clusterInfo: blueprints.ClusterInfo): Promise { + let values: blueprints.Values = populateValues(this.options); + + const chart = this.addHelmChart(clusterInfo, values); + + return Promise.resolve(chart); + } +} + +/** + * populateValues populates the appropriate values used to customize the Helm chart + * @param helmOptions User provided values to customize the chart + */ +function populateValues(helmOptions: FlaggerAddOnProps): blueprints.Values { + const values = helmOptions.values ?? {}; + + setPath(values, "ingress.enabled", helmOptions.ingressEnabled); + setPath(values, "flagger.service.type", helmOptions.flaggerServiceType); + setPath(values, "mysql.generate_passwords", true); + + return values; +} diff --git a/lib/teams/application-team/index.ts b/lib/teams/application-team/index.ts new file mode 100644 index 000000000..81a1b68a2 --- /dev/null +++ b/lib/teams/application-team/index.ts @@ -0,0 +1,11 @@ +import { ArnPrincipal } from 'aws-cdk-lib/aws-iam'; +import { ApplicationTeam } from '../../../lib/teams'; + +export class TeamApplication extends ApplicationTeam { + constructor(name: string, accountID: string) { + super({ + name: name, + users: [new ArnPrincipal(`arn:aws:iam::${accountID}:user/application`)] + }); + } +} From 85c3fd9e4e92aef5bfcabe165e3f5d32eb432be9 Mon Sep 17 00:00:00 2001 From: Eli Date: Tue, 19 Jul 2022 09:15:09 -0500 Subject: [PATCH 02/16] Lets see if this updates --- lib/addons/flagger/custom-canary-resource.yaml | 2 +- lib/addons/flagger/my_new_addon.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/addons/flagger/custom-canary-resource.yaml b/lib/addons/flagger/custom-canary-resource.yaml index 6dc394c1a..0bddfc69b 100644 --- a/lib/addons/flagger/custom-canary-resource.yaml +++ b/lib/addons/flagger/custom-canary-resource.yaml @@ -29,7 +29,7 @@ spec: threshold: 2 # number of checks to run before rollback iterations: 10 - # Prometheus checks based on + # Prometheus checks based on # http_request_duration_seconds histogram metrics: - name: request-success-rate diff --git a/lib/addons/flagger/my_new_addon.ts b/lib/addons/flagger/my_new_addon.ts index 473ff3209..4c4451c85 100644 --- a/lib/addons/flagger/my_new_addon.ts +++ b/lib/addons/flagger/my_new_addon.ts @@ -19,7 +19,7 @@ export interface FlaggerAddOnProps extends blueprints.HelmAddOnUserProps { export const defaultProps: blueprints.HelmAddOnProps & FlaggerAddOnProps = { name: "flagger-progressive-delivery", // Internal identifyer for our add-on namespace: "flagger", // Namespace used to deploy the chart - chart: "flagger", // Name of the Chart to be deployed + chart: "flagger", // Name of the Chart to be deployed version: "1.0", // version of the chart release: "flagger", // Name for our chart in Kubernetes repository: "https://flagger.io", // HTTPS address of the chart repository From 159cb5a9998055995c4fed40bbe750954e191359 Mon Sep 17 00:00:00 2001 From: Eli Date: Tue, 19 Jul 2022 09:29:11 -0500 Subject: [PATCH 03/16] minor work on flagger --- lib/addons/flagger/custom-canary-resource.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/addons/flagger/custom-canary-resource.yaml b/lib/addons/flagger/custom-canary-resource.yaml index 0bddfc69b..ab1f8a7a0 100644 --- a/lib/addons/flagger/custom-canary-resource.yaml +++ b/lib/addons/flagger/custom-canary-resource.yaml @@ -10,7 +10,7 @@ spec: targetRef: apiVersion: apps/v1 kind: Deployment - name: podinfo ##INSERT YOURS ELI + name: podinfo ##INSERT YOURS ELI! # the maximum time in seconds for the canary deployment # to make progress before rollback (default 600s) progressDeadlineSeconds: 60 From 050652a293bfaa21ece5149928432e1a810ea84a Mon Sep 17 00:00:00 2001 From: Eli Date: Tue, 19 Jul 2022 10:04:43 -0500 Subject: [PATCH 04/16] testing commit while on different branch --- lib/addons/flagger/my_new_addon.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/addons/flagger/my_new_addon.ts b/lib/addons/flagger/my_new_addon.ts index 4c4451c85..01dbac5dc 100644 --- a/lib/addons/flagger/my_new_addon.ts +++ b/lib/addons/flagger/my_new_addon.ts @@ -20,7 +20,7 @@ export const defaultProps: blueprints.HelmAddOnProps & FlaggerAddOnProps = { name: "flagger-progressive-delivery", // Internal identifyer for our add-on namespace: "flagger", // Namespace used to deploy the chart chart: "flagger", // Name of the Chart to be deployed - version: "1.0", // version of the chart + version: "1.0", // version of the chart release: "flagger", // Name for our chart in Kubernetes repository: "https://flagger.io", // HTTPS address of the chart repository values: {}, // Additional chart values From 81916a47b0d3cc47ab41c8b8be42a3f911045663 Mon Sep 17 00:00:00 2001 From: Eli Date: Tue, 19 Jul 2022 10:07:48 -0500 Subject: [PATCH 05/16] remove canary for real now --- .../flagger/custom-canary-resource.yaml | 61 ------------------- 1 file changed, 61 deletions(-) delete mode 100644 lib/addons/flagger/custom-canary-resource.yaml diff --git a/lib/addons/flagger/custom-canary-resource.yaml b/lib/addons/flagger/custom-canary-resource.yaml deleted file mode 100644 index ab1f8a7a0..000000000 --- a/lib/addons/flagger/custom-canary-resource.yaml +++ /dev/null @@ -1,61 +0,0 @@ -apiVersion: flagger.app/v1beta1 -kind: Canary -metadata: - name: podinfo ##INSERT YOURS ELI - namespace: test -spec: - # service mesh provider can be: kubernetes, istio, appmesh, nginx, gloo - provider: kubernetes - # deployment reference - targetRef: - apiVersion: apps/v1 - kind: Deployment - name: podinfo ##INSERT YOURS ELI! - # the maximum time in seconds for the canary deployment - # to make progress before rollback (default 600s) - progressDeadlineSeconds: 60 - # HPA reference (optional) - autoscalerRef: - apiVersion: autoscaling/v2beta2 - kind: HorizontalPodAutoscaler - name: podinfo ##INSERT YOURS ELI - service: - port: 9898 - portDiscovery: true - analysis: - # schedule interval (default 60s) - interval: 30s - # max number of failed checks before rollback - threshold: 2 - # number of checks to run before rollback - iterations: 10 - # Prometheus checks based on - # http_request_duration_seconds histogram - metrics: - - name: request-success-rate - # minimum req success rate (non 5xx responses) - # percentage (0-100) - thresholdRange: - min: 99 - interval: 1m - - name: request-duration - # maximum req duration P99 - # milliseconds - thresholdRange: - max: 500 - interval: 30s - # acceptance/load testing hooks - webhooks: - - name: smoke-test - type: pre-rollout - url: http://flagger-loadtester.test/ - timeout: 15s - metadata: - type: bash - cmd: "curl -sd 'anon' http://podinfo-canary.test:9898/token | grep token" ##INSERT YOURS ELI - - name: load-test - url: http://flagger-loadtester.test/ - timeout: 5s - metadata: - type: cmd - cmd: "hey -z 1m -q 10 -c 2 http://podinfo-canary.test:9898/" ##INSERT YOURS ELI \ No newline at end of file From 9e1705c8569ca238e909ee74a8b68d271d8489c0 Mon Sep 17 00:00:00 2001 From: Eli Date: Tue, 19 Jul 2022 18:27:02 -0500 Subject: [PATCH 06/16] minor code progress --- examples/blueprint-construct/index.ts | 7 +-- lib/addons/flagger/index.ts | 43 ++++++++++++++++++ lib/addons/flagger/my_new_addon.ts | 65 --------------------------- lib/addons/index.ts | 2 +- package.json | 5 ++- 5 files changed, 51 insertions(+), 71 deletions(-) create mode 100644 lib/addons/flagger/index.ts delete mode 100644 lib/addons/flagger/my_new_addon.ts diff --git a/examples/blueprint-construct/index.ts b/examples/blueprint-construct/index.ts index a9a2c9acc..209216d75 100644 --- a/examples/blueprint-construct/index.ts +++ b/examples/blueprint-construct/index.ts @@ -3,6 +3,7 @@ import * as ec2 from "aws-cdk-lib/aws-ec2"; import { CapacityType, KubernetesVersion, NodegroupAmiType } from 'aws-cdk-lib/aws-eks'; import { Construct } from "constructs"; import * as blueprints from '../../lib'; +//import { FlaggerAddOn } from '../../lib'; import * as team from '../teams'; const burnhamManifestDir = './examples/teams/team-burnham/'; @@ -124,9 +125,9 @@ export default class BlueprintConstruct extends Construct { }); blueprints.EksBlueprint.builder() - .addOns(...addOns) - .clusterProvider(clusterProvider) - .teams(...teams) + //.addOns(new FlaggerAddOn())//...addOns) + //.clusterProvider(clusterProvider) + .teams()//...teams) .enableControlPlaneLogTypes(blueprints.ControlPlaneLogType.API) .build(scope, blueprintID, props); } diff --git a/lib/addons/flagger/index.ts b/lib/addons/flagger/index.ts new file mode 100644 index 000000000..e8d122bef --- /dev/null +++ b/lib/addons/flagger/index.ts @@ -0,0 +1,43 @@ +import 'source-map-support/register'; +import * as blueprints from '../../../lib'; +import { Construct } from 'constructs'; + +/** + * User provided options for the Helm Chart + */ + export interface FlaggerAddOnProps extends blueprints.HelmAddOnUserProps { + version?: string, +} + +/** + * Default props to be used when creating the Helm chart + */ +const defaultProps: blueprints.HelmAddOnProps & FlaggerAddOnProps = { + name: "flagger", + namespace: "flagger", + chart: "flagger", + version: "1.0", + release: "flagger", + repository: "", + values: {}, + +}; + +/** + * Main class to instantiate the Helm chart + */ +export class FlaggerAddOn extends blueprints.HelmAddOn { + + readonly options: FlaggerAddOnProps; + + constructor(props?: FlaggerAddOnProps) { + super({...defaultProps, ...props}); + this.options = this.props as FlaggerAddOnProps; + } + + deploy(clusterInfo: blueprints.ClusterInfo): Promise { + const chart = this.addHelmChart(clusterInfo); + + return Promise.resolve(chart); + } +} \ No newline at end of file diff --git a/lib/addons/flagger/my_new_addon.ts b/lib/addons/flagger/my_new_addon.ts deleted file mode 100644 index 01dbac5dc..000000000 --- a/lib/addons/flagger/my_new_addon.ts +++ /dev/null @@ -1,65 +0,0 @@ -// filename=lib/kubevious_addon.ts -import 'source-map-support/register'; -import * as blueprints from '../../../lib'; -import { Construct } from 'constructs'; -import { setPath } from '../../utils'; - -/** - * User provided options for the Helm Chart - */ -export interface FlaggerAddOnProps extends blueprints.HelmAddOnUserProps { - version?: string, - ingressEnabled?: boolean, - flaggerServiceType?: string, -} - -/** - * Default props to be used when creating the Helm chart - */ -export const defaultProps: blueprints.HelmAddOnProps & FlaggerAddOnProps = { - name: "flagger-progressive-delivery", // Internal identifyer for our add-on - namespace: "flagger", // Namespace used to deploy the chart - chart: "flagger", // Name of the Chart to be deployed - version: "1.0", // version of the chart - release: "flagger", // Name for our chart in Kubernetes - repository: "https://flagger.io", // HTTPS address of the chart repository - values: {}, // Additional chart values - - ingressEnabled: false, - flaggerServiceType: "ClusterIP", -} - -/** - * Main class to instantiate the Helm chart - */ -export class FlaggerAddOn extends blueprints.HelmAddOn { - - readonly options: FlaggerAddOnProps - - constructor(props: FlaggerAddOnProps) { - super({ ...defaultProps, ...props }); - this.options = this.props as FlaggerAddOnProps; - } - - deploy(clusterInfo: blueprints.ClusterInfo): Promise { - let values: blueprints.Values = populateValues(this.options); - - const chart = this.addHelmChart(clusterInfo, values); - - return Promise.resolve(chart); - } -} - -/** - * populateValues populates the appropriate values used to customize the Helm chart - * @param helmOptions User provided values to customize the chart - */ -function populateValues(helmOptions: FlaggerAddOnProps): blueprints.Values { - const values = helmOptions.values ?? {}; - - setPath(values, "ingress.enabled", helmOptions.ingressEnabled); - setPath(values, "flagger.service.type", helmOptions.flaggerServiceType); - setPath(values, "mysql.generate_passwords", true); - - return values; -} diff --git a/lib/addons/index.ts b/lib/addons/index.ts index 271f9fa98..04a81e230 100644 --- a/lib/addons/index.ts +++ b/lib/addons/index.ts @@ -1,4 +1,3 @@ - export * from './appmesh'; export * from './argocd'; export * from './aws-for-fluent-bit'; @@ -31,6 +30,7 @@ export * from './ebs-csi-driver'; export * from './efs-csi-driver'; export * from './istio-base'; export * from './istio-control-plane'; +//export * from './flagger'; export class Constants { public static readonly BLUEPRINTS_ADDON = "blueprints-addon"; diff --git a/package.json b/package.json index a0c4e997f..db75b0543 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aws-quickstart/eks-blueprints", - "version": "1.0.4", + "version": "1.0.5", "license": "Apache-2.0", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -28,6 +28,7 @@ "typescript": "~4.5.4" }, "dependencies": { + "@aws-quickstart/eks-blueprints": "file:/Users/pevetoej/environment/cdk-eks-blueprints/aws-quickstart-eks-blueprints-1.0.5.tgz", "@types/assert": "^1.5.6", "@types/bcrypt": "^5.0.0", "@types/lodash.clonedeep": "^4.5.7", @@ -43,4 +44,4 @@ "yaml": "^1.10.2", "zod": "^3.17.3" } -} \ No newline at end of file +} From 9d2db1fa7fa0853d21d2fa8aeb44ab3b58fcd848 Mon Sep 17 00:00:00 2001 From: Eli Date: Wed, 20 Jul 2022 16:05:01 -0500 Subject: [PATCH 07/16] minor update --- examples/blueprint-construct/index.ts | 4 +- lib/addons/flagger/hpa.yaml | 20 +++++++ lib/addons/flagger/index.ts | 17 +++--- lib/addons/flagger/load-testing-service.yaml | 15 +++++ lib/addons/flagger/podinfo-canary.yaml | 61 ++++++++++++++++++++ 5 files changed, 107 insertions(+), 10 deletions(-) create mode 100644 lib/addons/flagger/hpa.yaml create mode 100644 lib/addons/flagger/load-testing-service.yaml create mode 100644 lib/addons/flagger/podinfo-canary.yaml diff --git a/examples/blueprint-construct/index.ts b/examples/blueprint-construct/index.ts index 209216d75..d4d032d3c 100644 --- a/examples/blueprint-construct/index.ts +++ b/examples/blueprint-construct/index.ts @@ -3,7 +3,7 @@ import * as ec2 from "aws-cdk-lib/aws-ec2"; import { CapacityType, KubernetesVersion, NodegroupAmiType } from 'aws-cdk-lib/aws-eks'; import { Construct } from "constructs"; import * as blueprints from '../../lib'; -//import { FlaggerAddOn } from '../../lib'; +import { FlaggerAddOn } from '../../lib/addons/flagger'; import * as team from '../teams'; const burnhamManifestDir = './examples/teams/team-burnham/'; @@ -125,7 +125,7 @@ export default class BlueprintConstruct extends Construct { }); blueprints.EksBlueprint.builder() - //.addOns(new FlaggerAddOn())//...addOns) + .addOns(new FlaggerAddOn())//...addOns) //.clusterProvider(clusterProvider) .teams()//...teams) .enableControlPlaneLogTypes(blueprints.ControlPlaneLogType.API) diff --git a/lib/addons/flagger/hpa.yaml b/lib/addons/flagger/hpa.yaml new file mode 100644 index 000000000..39e94a58d --- /dev/null +++ b/lib/addons/flagger/hpa.yaml @@ -0,0 +1,20 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: podinfo +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: podinfo + minReplicas: 2 + maxReplicas: 4 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + # scale up if usage is above + # 99% of the requested CPU (100m) + averageUtilization: 99 \ No newline at end of file diff --git a/lib/addons/flagger/index.ts b/lib/addons/flagger/index.ts index e8d122bef..7862af706 100644 --- a/lib/addons/flagger/index.ts +++ b/lib/addons/flagger/index.ts @@ -5,22 +5,23 @@ import { Construct } from 'constructs'; /** * User provided options for the Helm Chart */ - export interface FlaggerAddOnProps extends blueprints.HelmAddOnUserProps { - version?: string, +export interface FlaggerAddOnProps extends blueprints.HelmAddOnUserProps {//this is the root level + prometheusInstall?: boolean; + //meshProvider?: //need an enums for what you put from values; + } /** * Default props to be used when creating the Helm chart */ -const defaultProps: blueprints.HelmAddOnProps & FlaggerAddOnProps = { +export const defaultProps: blueprints.HelmAddOnProps & FlaggerAddOnProps = { name: "flagger", namespace: "flagger", chart: "flagger", - version: "1.0", + version: "1.22.0", release: "flagger", - repository: "", + repository: "https://flagger.app", values: {}, - }; /** @@ -31,12 +32,12 @@ export class FlaggerAddOn extends blueprints.HelmAddOn { readonly options: FlaggerAddOnProps; constructor(props?: FlaggerAddOnProps) { - super({...defaultProps, ...props}); + super({ ...defaultProps, ...props }); //merges your stuff and what they specify. They override our stuff, root level, and values properties this.options = this.props as FlaggerAddOnProps; } deploy(clusterInfo: blueprints.ClusterInfo): Promise { - const chart = this.addHelmChart(clusterInfo); + const chart = this.addHelmChart(clusterInfo, defaultProps.values); return Promise.resolve(chart); } diff --git a/lib/addons/flagger/load-testing-service.yaml b/lib/addons/flagger/load-testing-service.yaml new file mode 100644 index 000000000..772b20afe --- /dev/null +++ b/lib/addons/flagger/load-testing-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: flagger-loadtester + labels: + app: flagger-loadtester +spec: + type: ClusterIP + selector: + app: flagger-loadtester + ports: + - name: http + port: 80 + protocol: TCP + targetPort: http \ No newline at end of file diff --git a/lib/addons/flagger/podinfo-canary.yaml b/lib/addons/flagger/podinfo-canary.yaml new file mode 100644 index 000000000..a081ff8cb --- /dev/null +++ b/lib/addons/flagger/podinfo-canary.yaml @@ -0,0 +1,61 @@ +apiVersion: flagger.app/v1beta1 +kind: Canary +metadata: + name: podinfo + namespace: test +spec: + # service mesh provider can be: kubernetes, istio, appmesh, nginx, gloo + provider: kubernetes + # deployment reference + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: podinfo + # the maximum time in seconds for the canary deployment + # to make progress before rollback (default 600s) + progressDeadlineSeconds: 60 + # HPA reference (optional) + autoscalerRef: + apiVersion: autoscaling/v2beta2 + kind: HorizontalPodAutoscaler + name: podinfo + service: + port: 9898 + portDiscovery: true + analysis: + # schedule interval (default 60s) + interval: 30s + # max number of failed checks before rollback + threshold: 2 + # number of checks to run before rollback + iterations: 10 + # Prometheus checks based on + # http_request_duration_seconds histogram + metrics: + - name: request-success-rate + # minimum req success rate (non 5xx responses) + # percentage (0-100) + thresholdRange: + min: 99 + interval: 1m + - name: request-duration + # maximum req duration P99 + # milliseconds + thresholdRange: + max: 500 + interval: 30s + # acceptance/load testing hooks + webhooks: + - name: smoke-test + type: pre-rollout + url: http://flagger-loadtester.test/ + timeout: 15s + metadata: + type: bash + cmd: "curl -sd 'anon' http://podinfo-canary.test:9898/token | grep token" + - name: load-test + url: http://flagger-loadtester.test/ + timeout: 5s + metadata: + type: cmd + cmd: "hey -z 1m -q 10 -c 2 http://podinfo-canary.test:9898/" \ No newline at end of file From 2cca7a8570b05984cbc84d801f313f69496ea07d Mon Sep 17 00:00:00 2001 From: Eli Date: Thu, 21 Jul 2022 17:17:35 -0500 Subject: [PATCH 08/16] progress on bootstrap --- examples/blueprint-construct/index.ts | 3 +- lib/addons/flagger/hpa.yaml | 23 ++++---- lib/addons/flagger/index.ts | 40 ++++++++++--- lib/addons/flagger/load-tester.yaml | 62 ++++++++++++++++++++ lib/addons/flagger/load-testing-service.yaml | 15 ----- lib/addons/flagger/podinfo-canary.yaml | 2 +- package.json | 3 +- 7 files changed, 110 insertions(+), 38 deletions(-) create mode 100644 lib/addons/flagger/load-tester.yaml delete mode 100644 lib/addons/flagger/load-testing-service.yaml diff --git a/examples/blueprint-construct/index.ts b/examples/blueprint-construct/index.ts index 9721c1e0b..888662ac2 100644 --- a/examples/blueprint-construct/index.ts +++ b/examples/blueprint-construct/index.ts @@ -5,6 +5,7 @@ import { Construct } from "constructs"; import * as blueprints from '../../lib'; import { HelmAddOn } from '../../lib'; import * as team from '../teams'; +import {FlaggerAddOn} from '../../lib/addons/flagger' const burnhamManifestDir = './examples/teams/team-burnham/'; const rikerManifestDir = './examples/teams/team-riker/'; @@ -132,7 +133,7 @@ export default class BlueprintConstruct { }); blueprints.EksBlueprint.builder() - //.addOns(new FlaggerAddOn())//...addOns) + .addOns(new FlaggerAddOn())//...addOns) //.clusterProvider(clusterProvider) .teams()//...teams) .enableControlPlaneLogTypes(blueprints.ControlPlaneLogType.API) diff --git a/lib/addons/flagger/hpa.yaml b/lib/addons/flagger/hpa.yaml index 39e94a58d..18fa873ae 100644 --- a/lib/addons/flagger/hpa.yaml +++ b/lib/addons/flagger/hpa.yaml @@ -2,19 +2,20 @@ apiVersion: autoscaling/v2beta2 kind: HorizontalPodAutoscaler metadata: name: podinfo + namespace: test spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment - name: podinfo - minReplicas: 2 - maxReplicas: 4 + name: flagger-loadtester + minReplicas: 2 + maxReplicas: 4 metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - # scale up if usage is above - # 99% of the requested CPU (100m) - averageUtilization: 99 \ No newline at end of file + - type: Resource + resource: + name: cpu + target: + type: Utilization + # scale up if usage is above + # 99% of the requested CPU (100m) + averageUtilization: 99 \ No newline at end of file diff --git a/lib/addons/flagger/index.ts b/lib/addons/flagger/index.ts index 7862af706..50563d373 100644 --- a/lib/addons/flagger/index.ts +++ b/lib/addons/flagger/index.ts @@ -1,18 +1,35 @@ import 'source-map-support/register'; import * as blueprints from '../../../lib'; import { Construct } from 'constructs'; +import { Values } from "../../spi"; +import merge from "ts-deepmerge"; /** - * User provided options for the Helm Chart + * User provided options for the FlaggerAddonProps values. */ export interface FlaggerAddOnProps extends blueprints.HelmAddOnUserProps {//this is the root level prometheusInstall?: boolean; - //meshProvider?: //need an enums for what you put from values; + meshProvider?: MeshProviderOptions; +} +/** + * All the meshProvider values that can be chosen by the user. + */ +export const enum MeshProviderOptions { //could use a better name later + KUBERNETES = 'kubernetes', + ISTIO = 'istio', + LINKERD = 'linkerd', + APPMESH = 'appmesh', + CONTOUR = 'contour', + NGINX = 'nginx', + GLOO = 'gloo', + SKIPPER = 'skipper', + TRAEFIK = 'traefik', + OSM = 'osm' } /** - * Default props to be used when creating the Helm chart + * defaultProps makes the flagger namespace and chart. */ export const defaultProps: blueprints.HelmAddOnProps & FlaggerAddOnProps = { name: "flagger", @@ -20,25 +37,32 @@ export const defaultProps: blueprints.HelmAddOnProps & FlaggerAddOnProps = { chart: "flagger", version: "1.22.0", release: "flagger", - repository: "https://flagger.app", - values: {}, + repository: "https://flagger.app" }; /** - * Main class to instantiate the Helm chart + * This creates and deploys a cluster with the prometheus and mesh provider settings set unless the user specifies their own values for them. */ export class FlaggerAddOn extends blueprints.HelmAddOn { readonly options: FlaggerAddOnProps; constructor(props?: FlaggerAddOnProps) { - super({ ...defaultProps, ...props }); //merges your stuff and what they specify. They override our stuff, root level, and values properties + super({ ...defaultProps, ...props }); this.options = this.props as FlaggerAddOnProps; } deploy(clusterInfo: blueprints.ClusterInfo): Promise { - const chart = this.addHelmChart(clusterInfo, defaultProps.values); + let values: Values = { + prometheus: { + install: true + }, + meshProvider: MeshProviderOptions.KUBERNETES + }; + + values = merge(values, this.props.values ?? {}); + const chart = this.addHelmChart(clusterInfo, values); return Promise.resolve(chart); } } \ No newline at end of file diff --git a/lib/addons/flagger/load-tester.yaml b/lib/addons/flagger/load-tester.yaml new file mode 100644 index 000000000..c8f3d4974 --- /dev/null +++ b/lib/addons/flagger/load-tester.yaml @@ -0,0 +1,62 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: flagger-loadtester + labels: + app: flagger-loadtester + namespace: test +spec: + selector: + matchLabels: + app: flagger-loadtester + template: + metadata: + labels: + app: flagger-loadtester + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "8080" + openservicemesh.io/inbound-port-exclusion-list: "80, 8080" + spec: + containers: + - name: loadtester + image: ghcr.io/fluxcd/flagger-loadtester:0.22.0 + imagePullPolicy: IfNotPresent + ports: + - name: http-web + containerPort: 8080 + command: + - ./loadtester + - -port=8080 + - -log-level=info + - -timeout=1h + livenessProbe: + exec: + command: + - wget + - --quiet + - --tries=1 + - --timeout=4 + - --spider + - http://localhost:8080/healthz + timeoutSeconds: 5 + readinessProbe: + exec: + command: + - wget + - --quiet + - --tries=1 + - --timeout=4 + - --spider + - http://localhost:8080/healthz + timeoutSeconds: 5 + resources: + limits: + memory: "512Mi" + cpu: "1000m" + requests: + memory: "32Mi" + cpu: "10m" + securityContext: + readOnlyRootFilesystem: true + runAsUser: 10001 \ No newline at end of file diff --git a/lib/addons/flagger/load-testing-service.yaml b/lib/addons/flagger/load-testing-service.yaml deleted file mode 100644 index 772b20afe..000000000 --- a/lib/addons/flagger/load-testing-service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: flagger-loadtester - labels: - app: flagger-loadtester -spec: - type: ClusterIP - selector: - app: flagger-loadtester - ports: - - name: http - port: 80 - protocol: TCP - targetPort: http \ No newline at end of file diff --git a/lib/addons/flagger/podinfo-canary.yaml b/lib/addons/flagger/podinfo-canary.yaml index a081ff8cb..1fa3b19f2 100644 --- a/lib/addons/flagger/podinfo-canary.yaml +++ b/lib/addons/flagger/podinfo-canary.yaml @@ -10,7 +10,7 @@ spec: targetRef: apiVersion: apps/v1 kind: Deployment - name: podinfo + name: flagger-loadtester # the maximum time in seconds for the canary deployment # to make progress before rollback (default 600s) progressDeadlineSeconds: 60 diff --git a/package.json b/package.json index 80c3b0e9e..998f472cc 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "typescript": "~4.7.4" }, "dependencies": { - "@aws-quickstart/eks-blueprints": "file:/Users/pevetoej/environment/cdk-eks-blueprints/aws-quickstart-eks-blueprints-1.0.5.tgz", "@types/assert": "^1.5.6", "@types/bcrypt": "^5.0.0", "@types/lodash.clonedeep": "^4.5.7", @@ -39,7 +38,7 @@ "dot-object": "^2.1.4", "js-yaml": "4.1.0", "lint": "^1.1.2", - "lodash":"4.17.21", + "lodash": "4.17.21", "sync-request": "6.1.0", "ts-deepmerge": "^2.0.4", "ts-md5": "^1.2.11", From 39215e8ad1295e55e9f20b4d8609e29f433a50ca Mon Sep 17 00:00:00 2001 From: Eli Date: Sun, 24 Jul 2022 19:46:29 -0500 Subject: [PATCH 09/16] Flagger addon almost done, with docs --- docs/addons/flagger.md | 25 ++++++ docs/addons/index.md | 19 ++--- lib/addons/flagger/hpa.yaml | 4 +- lib/addons/flagger/load-tester.yaml | 106 ++++++++++++++----------- lib/addons/flagger/podinfo-canary.yaml | 7 +- 5 files changed, 99 insertions(+), 62 deletions(-) create mode 100644 docs/addons/flagger.md diff --git a/docs/addons/flagger.md b/docs/addons/flagger.md new file mode 100644 index 000000000..4a37f795c --- /dev/null +++ b/docs/addons/flagger.md @@ -0,0 +1,25 @@ +## Flagger Add-On + +[Flagger](https://flagger.app/) is a progressive delivery tool that automates the release process for applications running on Kubernetes. It reduces the risk of introducing a new software version in production by gradually shifting traffic to the new version while measuring metrics and running conformance tests. The Flagger add-on provisions the necessary Helm chart, and namespace to allow support for flagger in an EKS workload. + +## Usage + +```typescript +import 'source-map-support/register'; +import * as cdk from 'aws-cdk-lib'; +import * as blueprints from '@aws-quickstart/eks-blueprints'; + +const app = new cdk.App(); + +const addOn = new blueprints.addons.Flagger(); + +const blueprint = blueprints.EksBlueprint.builder() + .addOns(addOn) + .build(app, 'my-stack-name'); +``` + +## Functionality + +1. Creates the `flagger` namespace. +2. Deploys the `flagger` Helm chart into the cluster. +3. Supports [standard helm configuration options](./index.md#standard-helm-add-on-configuration-options) diff --git a/docs/addons/index.md b/docs/addons/index.md index dea812aed..f5e70160a 100644 --- a/docs/addons/index.md +++ b/docs/addons/index.md @@ -12,30 +12,31 @@ The framework currently supports the following add-ons. |------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------| | [`AppMeshAddOn`](./app-mesh) | Adds an AppMesh controller and CRDs (pending validation on the latest version of CDK) | | [`ArgoCDAddOn`](./argo-cd) | Provisions Argo CD into your cluster. | -| [`AWS for Fluent Bit`](./aws-for-fluent-bit) | Provisions Fluent Bit into your cluster for log aggregation and consumption. | +| [`AWS for Fluent Bit`](./aws-for-fluent-bit) | Provisions Fluent Bit into your cluster for log aggregation and consumption. | | [`AWS Load Balancer Controller`](./aws-load-balancer-controller) | Provisions the AWS Load Balancer Controller into your cluster. | -| [`AWS Node Termination Handler`](./aws-node-termination-handler) | Provisions Node Termination Handler into your cluster. | +| [`AWS Node Termination Handler`](./aws-node-termination-handler) | Provisions Node Termination Handler into your cluster. | | [`CalicoAddOn`](./calico) | Adds the Calico 1.7.1 CNI/Network policy engine | | [`ClusterAutoscalerAddOn`](./cluster-autoscaler) | Adds the standard cluster autoscaler | | [`ContainerInsightsAddOn`](./container-insights) | Adds Container Insights support integrating monitoring with CloudWatch | | [`CoreDnsAddOn`](./coredns.md) | Adds CoreDNS Amazon EKS add-on. CoreDNS is a flexible, extensible DNS server that can serve as the Kubernetes cluster DNS | -| [`DatadogAddOn`](./datadog.md) | Adds [Datadog](https://www.datadoghq.com/) Amazon EKS add-on. Datadog is the monitoring and security platform for cloud applications. | -| [`Dynatrace`](https://github.com/dynatrace-oss/dynatrace-eks-blueprints-addon) | Adds the [Dynatrace](https://www.dynatrace.com/) [OneAgent Operator](https://github.com/Dynatrace/dynatrace-oneagent-operator) | +| [`DatadogAddOn`](./datadog.md) | Adds [Datadog](https://www.datadoghq.com/)| Amazon EKS add-on. Datadog is the monitoring and security platform for cloud applications. | +| [`Dynatrace`](https://github.com/dynatrace-oss/dynatrace-eks-blueprints-addon)| Adds the [Dynatrace](https://www.dynatrace.com/) [OneAgent Operator](https://github.com/Dynatrace/dynatrace-oneagent-operator) | | [`EbsCsiDriverAddOn`](./ebs-csi-driver.md) | Adds EBS CSI Driver Amazon EKS add-on. This driver manages the lifecycle of Amazon EBS volumes for persistent storage | | [`EfsCsiDriverAddOn`](./efs-csi-driver.md) | Adds EFS CSI Driver Amazon EKS add-on. This driver manages the lifecycle of Amazon EFS volumes for persistent storage | | [`ExternalDnsAddOn`](./external-dns) | Adds [External DNS](https://github.com/kubernetes-sigs/external-dns) support for AWS to the cluster, integrating with Amazon Route 53 | -| [`Keptn`](https://github.com/keptn-sandbox/keptn-eks-blueprints-addon) | [Keptn](https://keptn.sh/) Control Plane and Execution Plane AddOn | +| [`FlaggerAddOn`](./flagger) | Adds support for Flagger progressive delivery and adds CRDs for Canary | +| [`Keptn`](https://github.com/keptn-sandbox/keptn-eks-blueprints-addon) | [Keptn](https://keptn.sh/) Control Plane and Execution Plane AddOn | | [`KubecostAddOn`](./kubecost.md) | Adds [Kubecost](https://kubecost.com) cost analyzer to the EKS cluster | -| [`KubeviousAddOn`](./kubevious.md) | Adds [Kubevious](https://github.com/kubevious/kubevious) open source Kubernetes dashboard to an EKS cluster | | +| [`KubeviousAddOn`](./kubevious.md) | Adds [Kubevious](https://github.com/kubevious/kubevious) open source Kubernetes dashboard to an EKS cluster | | [`KarpenterAddOn`](./karpenter.md) | Adds [Karpenter](https://github.com/awslabs/karpenter) support for Amazon EKS. | | [`KubeProxyAddOn`](./kube-proxy.md) | Adds kube-proxy Amazon EKS add-on. Kube-proxy maintains network rules on each Amazon EC2 node | | [`MetricsServerAddOn`](./metrics-server) | Adds metrics server (pre-req for HPA and other monitoring tools) | -| [`NewRelicAddOn`](./newrelic.md) | Adds [New Relic](https://newrelic.com/) and [Pixie](https://pixielabs.ai/) observability for Amazon EKS.| +| [`NewRelicAddOn`](./newrelic.md) | Adds [New Relic](https://newrelic.com/) and [Pixie](https://pixielabs.ai/) observability for Amazon EKS. | | [`NginxAddOn`](./nginx.md) | Adds NGINX ingress controller | -| [`OpaGatekeeperAddOn (Currently Not Supported, In Progress)`](./opa-gatekeeper.md) | Adds OPA Gatekeeper | +| [`OpaGatekeeperAddOn (Currently Not Supported, In Progress)`](./opa-gatekeeper.md)| Adds OPA Gatekeeper | | [`PixieAddOn`](./pixie.md) | Adds [Pixie](https://px.dev) to the EKS Cluster. Pixie provides auto-telemetry for requests, metrics, application profiles, and more. | | [`SecretsStoreAddOn`](./secrets-store.md) | Adds AWS Secrets Manager and Config Provider for Secret Store CSI Driver to the EKS Cluster | -| [`Snyk`](https://github.com/snyk-partners/snyk-monitor-eks-blueprints-addon) | Adds the [Snyk Monitor](https://github.com/snyk/kubernetes-monitor) to the EKS Cluster | +| [`Snyk`](https://github.com/snyk-partners/snyk-monitor-eks-blueprints-addon) | Adds the [Snyk Monitor](https://github.com/snyk/kubernetes-monitor) to the EKS Cluster | | [`SSMAgentAddOn`](./ssm-agent.md) | Adds [Amazon SSM Agent](https://docs.aws.amazon.com/systems-manager/latest/userguide/ssm-agent.html) to worker nodes | | [`VpcCniAddOn`](./vpc-cni.md) | Adds the Amazon VPC CNI Amazon EKS addon to support native VPC networking for Amazon EKS | | [`VeleroAddOn`](./velero.md) | Adds [Velero](https://velero.io/) to the EKS Cluster | diff --git a/lib/addons/flagger/hpa.yaml b/lib/addons/flagger/hpa.yaml index 18fa873ae..12de59de3 100644 --- a/lib/addons/flagger/hpa.yaml +++ b/lib/addons/flagger/hpa.yaml @@ -8,8 +8,8 @@ spec: apiVersion: apps/v1 kind: Deployment name: flagger-loadtester - minReplicas: 2 - maxReplicas: 4 + minReplicas: 2 + maxReplicas: 4 metrics: - type: Resource resource: diff --git a/lib/addons/flagger/load-tester.yaml b/lib/addons/flagger/load-tester.yaml index c8f3d4974..4cd296cc0 100644 --- a/lib/addons/flagger/load-tester.yaml +++ b/lib/addons/flagger/load-tester.yaml @@ -6,57 +6,73 @@ metadata: app: flagger-loadtester namespace: test spec: + replicas: 3 + minReadySeconds: 3 + revisionHistoryLimit: 5 + progressDeadlineSeconds: 60 + strategy: + rollingUpdate: + maxUnavailable: 0 + type: RollingUpdate selector: matchLabels: app: flagger-loadtester template: metadata: - labels: - app: flagger-loadtester annotations: prometheus.io/scrape: "true" - prometheus.io/port: "8080" - openservicemesh.io/inbound-port-exclusion-list: "80, 8080" + prometheus.io/port: "9797" + labels: + app: flagger-loadtester spec: containers: - - name: loadtester - image: ghcr.io/fluxcd/flagger-loadtester:0.22.0 - imagePullPolicy: IfNotPresent - ports: - - name: http-web - containerPort: 8080 - command: - - ./loadtester - - -port=8080 - - -log-level=info - - -timeout=1h - livenessProbe: - exec: - command: - - wget - - --quiet - - --tries=1 - - --timeout=4 - - --spider - - http://localhost:8080/healthz - timeoutSeconds: 5 - readinessProbe: - exec: - command: - - wget - - --quiet - - --tries=1 - - --timeout=4 - - --spider - - http://localhost:8080/healthz - timeoutSeconds: 5 - resources: - limits: - memory: "512Mi" - cpu: "1000m" - requests: - memory: "32Mi" - cpu: "10m" - securityContext: - readOnlyRootFilesystem: true - runAsUser: 10001 \ No newline at end of file + - name: flagger-loadtester + image: ghcr.io/stefanprodan/podinfo:6.1.6 + imagePullPolicy: IfNotPresent + ports: + - name: http + containerPort: 9898 + protocol: TCP + - name: http-metrics + containerPort: 9797 + protocol: TCP + - name: grpc + containerPort: 9999 + protocol: TCP + command: + - ./podinfo + - --port=9898 + - --port-metrics=9797 + - --grpc-port=9999 + - --grpc-service-name=podinfo + - --level=info + - --random-delay=false + - --random-error=false + env: + - name: PODINFO_UI_COLOR + value: "#34577c" + livenessProbe: + exec: + command: + - podcli + - check + - http + - localhost:9898/healthz + initialDelaySeconds: 5 + timeoutSeconds: 5 + readinessProbe: + exec: + command: + - podcli + - check + - http + - localhost:9898/readyz + initialDelaySeconds: 5 + timeoutSeconds: 5 + resources: + limits: + cpu: 2000m + memory: 512Mi + requests: + cpu: 100m + memory: 64Mi \ No newline at end of file diff --git a/lib/addons/flagger/podinfo-canary.yaml b/lib/addons/flagger/podinfo-canary.yaml index 1fa3b19f2..39e93a0c8 100644 --- a/lib/addons/flagger/podinfo-canary.yaml +++ b/lib/addons/flagger/podinfo-canary.yaml @@ -13,12 +13,7 @@ spec: name: flagger-loadtester # the maximum time in seconds for the canary deployment # to make progress before rollback (default 600s) - progressDeadlineSeconds: 60 - # HPA reference (optional) - autoscalerRef: - apiVersion: autoscaling/v2beta2 - kind: HorizontalPodAutoscaler - name: podinfo + progressDeadlineSeconds: 60 service: port: 9898 portDiscovery: true From 8459432fa96c9ac29a75472a91ac08b37ce1ddc3 Mon Sep 17 00:00:00 2001 From: Eli Date: Mon, 25 Jul 2022 16:25:24 -0500 Subject: [PATCH 10/16] Mostly done flagger addon, and docs --- docs/addons/flagger.md | 64 ++++++++++++++++++++++++++ docs/addons/index.md | 19 ++++---- examples/blueprint-construct/index.ts | 1 - lib/addons/flagger/hpa.yaml | 21 --------- lib/addons/flagger/index.ts | 10 ++-- lib/addons/flagger/load-tester.yaml | 62 ------------------------- lib/addons/flagger/podinfo-canary.yaml | 61 ------------------------ mkdocs.yml | 1 + 8 files changed, 82 insertions(+), 157 deletions(-) create mode 100644 docs/addons/flagger.md delete mode 100644 lib/addons/flagger/hpa.yaml delete mode 100644 lib/addons/flagger/load-tester.yaml delete mode 100644 lib/addons/flagger/podinfo-canary.yaml diff --git a/docs/addons/flagger.md b/docs/addons/flagger.md new file mode 100644 index 000000000..dc197a8ca --- /dev/null +++ b/docs/addons/flagger.md @@ -0,0 +1,64 @@ +## Flagger Add-On + +[Flagger](https://flagger.app/) is a progressive delivery tool that automates the release process for applications running on Kubernetes. It reduces the risk of introducing a new software version in production by gradually shifting traffic to the new version while measuring metrics and running conformance tests. The Flagger add-on provisions the necessary Helm chart, and namespace to allow support for flagger in an EKS workload. + +## Usage + +```typescript +import 'source-map-support/register'; +import * as cdk from 'aws-cdk-lib'; +import * as blueprints from '@aws-quickstart/eks-blueprints'; + +const app = new cdk.App(); + +const addOn = new blueprints.addons.Flagger(); + +const blueprint = blueprints.EksBlueprint.builder() + .addOns(addOn) + .build(app, 'my-stack-name'); +``` + +## Functionality + +1. Creates the `flagger` namespace. +2. Deploys the `flagger` Helm chart into the cluster. +3. Supports [standard helm configuration options](./index.md#standard-helm-add-on-configuration-options) + +## Configuration Options + +- `prometheus`: Pass true or false if you wish to track deployment metrics via prometheus. `True by default`. +- `crd`: Pass true or false. If true, create Flagger's CRDs (should be enabled for Helm v2 ONLY). If used in Helm v3 it will break the deployment so its `false by default`. +- `meshProvider`: Pass from the following enum list of meshProviderOptions. `KUBERNETES by default`. + +```typescript +export const enum MeshProviderOptions { + KUBERNETES = 'kubernetes', + ISTIO = 'istio', + LINKERD = 'linkerd', + APPMESH = 'appmesh', + CONTOUR = 'contour', + NGINX = 'nginx', + GLOO = 'gloo', + SKIPPER = 'skipper', + TRAEFIK = 'traefik', + OSM = 'osm' +} +``` + +- Example Configuration: + +```typescript +import * as blueprints from '@aws-quickstart/eks-blueprints'; + +const flagger = new blueprints.addons.FlaggerAddOn({ + values: { + prometheus: { + install: false + }, + meshProvider: MeshProviderOptions.APPMESH, + crd: { + create: true + } + } +}); +``` \ No newline at end of file diff --git a/docs/addons/index.md b/docs/addons/index.md index dea812aed..f5e70160a 100644 --- a/docs/addons/index.md +++ b/docs/addons/index.md @@ -12,30 +12,31 @@ The framework currently supports the following add-ons. |------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------| | [`AppMeshAddOn`](./app-mesh) | Adds an AppMesh controller and CRDs (pending validation on the latest version of CDK) | | [`ArgoCDAddOn`](./argo-cd) | Provisions Argo CD into your cluster. | -| [`AWS for Fluent Bit`](./aws-for-fluent-bit) | Provisions Fluent Bit into your cluster for log aggregation and consumption. | +| [`AWS for Fluent Bit`](./aws-for-fluent-bit) | Provisions Fluent Bit into your cluster for log aggregation and consumption. | | [`AWS Load Balancer Controller`](./aws-load-balancer-controller) | Provisions the AWS Load Balancer Controller into your cluster. | -| [`AWS Node Termination Handler`](./aws-node-termination-handler) | Provisions Node Termination Handler into your cluster. | +| [`AWS Node Termination Handler`](./aws-node-termination-handler) | Provisions Node Termination Handler into your cluster. | | [`CalicoAddOn`](./calico) | Adds the Calico 1.7.1 CNI/Network policy engine | | [`ClusterAutoscalerAddOn`](./cluster-autoscaler) | Adds the standard cluster autoscaler | | [`ContainerInsightsAddOn`](./container-insights) | Adds Container Insights support integrating monitoring with CloudWatch | | [`CoreDnsAddOn`](./coredns.md) | Adds CoreDNS Amazon EKS add-on. CoreDNS is a flexible, extensible DNS server that can serve as the Kubernetes cluster DNS | -| [`DatadogAddOn`](./datadog.md) | Adds [Datadog](https://www.datadoghq.com/) Amazon EKS add-on. Datadog is the monitoring and security platform for cloud applications. | -| [`Dynatrace`](https://github.com/dynatrace-oss/dynatrace-eks-blueprints-addon) | Adds the [Dynatrace](https://www.dynatrace.com/) [OneAgent Operator](https://github.com/Dynatrace/dynatrace-oneagent-operator) | +| [`DatadogAddOn`](./datadog.md) | Adds [Datadog](https://www.datadoghq.com/)| Amazon EKS add-on. Datadog is the monitoring and security platform for cloud applications. | +| [`Dynatrace`](https://github.com/dynatrace-oss/dynatrace-eks-blueprints-addon)| Adds the [Dynatrace](https://www.dynatrace.com/) [OneAgent Operator](https://github.com/Dynatrace/dynatrace-oneagent-operator) | | [`EbsCsiDriverAddOn`](./ebs-csi-driver.md) | Adds EBS CSI Driver Amazon EKS add-on. This driver manages the lifecycle of Amazon EBS volumes for persistent storage | | [`EfsCsiDriverAddOn`](./efs-csi-driver.md) | Adds EFS CSI Driver Amazon EKS add-on. This driver manages the lifecycle of Amazon EFS volumes for persistent storage | | [`ExternalDnsAddOn`](./external-dns) | Adds [External DNS](https://github.com/kubernetes-sigs/external-dns) support for AWS to the cluster, integrating with Amazon Route 53 | -| [`Keptn`](https://github.com/keptn-sandbox/keptn-eks-blueprints-addon) | [Keptn](https://keptn.sh/) Control Plane and Execution Plane AddOn | +| [`FlaggerAddOn`](./flagger) | Adds support for Flagger progressive delivery and adds CRDs for Canary | +| [`Keptn`](https://github.com/keptn-sandbox/keptn-eks-blueprints-addon) | [Keptn](https://keptn.sh/) Control Plane and Execution Plane AddOn | | [`KubecostAddOn`](./kubecost.md) | Adds [Kubecost](https://kubecost.com) cost analyzer to the EKS cluster | -| [`KubeviousAddOn`](./kubevious.md) | Adds [Kubevious](https://github.com/kubevious/kubevious) open source Kubernetes dashboard to an EKS cluster | | +| [`KubeviousAddOn`](./kubevious.md) | Adds [Kubevious](https://github.com/kubevious/kubevious) open source Kubernetes dashboard to an EKS cluster | | [`KarpenterAddOn`](./karpenter.md) | Adds [Karpenter](https://github.com/awslabs/karpenter) support for Amazon EKS. | | [`KubeProxyAddOn`](./kube-proxy.md) | Adds kube-proxy Amazon EKS add-on. Kube-proxy maintains network rules on each Amazon EC2 node | | [`MetricsServerAddOn`](./metrics-server) | Adds metrics server (pre-req for HPA and other monitoring tools) | -| [`NewRelicAddOn`](./newrelic.md) | Adds [New Relic](https://newrelic.com/) and [Pixie](https://pixielabs.ai/) observability for Amazon EKS.| +| [`NewRelicAddOn`](./newrelic.md) | Adds [New Relic](https://newrelic.com/) and [Pixie](https://pixielabs.ai/) observability for Amazon EKS. | | [`NginxAddOn`](./nginx.md) | Adds NGINX ingress controller | -| [`OpaGatekeeperAddOn (Currently Not Supported, In Progress)`](./opa-gatekeeper.md) | Adds OPA Gatekeeper | +| [`OpaGatekeeperAddOn (Currently Not Supported, In Progress)`](./opa-gatekeeper.md)| Adds OPA Gatekeeper | | [`PixieAddOn`](./pixie.md) | Adds [Pixie](https://px.dev) to the EKS Cluster. Pixie provides auto-telemetry for requests, metrics, application profiles, and more. | | [`SecretsStoreAddOn`](./secrets-store.md) | Adds AWS Secrets Manager and Config Provider for Secret Store CSI Driver to the EKS Cluster | -| [`Snyk`](https://github.com/snyk-partners/snyk-monitor-eks-blueprints-addon) | Adds the [Snyk Monitor](https://github.com/snyk/kubernetes-monitor) to the EKS Cluster | +| [`Snyk`](https://github.com/snyk-partners/snyk-monitor-eks-blueprints-addon) | Adds the [Snyk Monitor](https://github.com/snyk/kubernetes-monitor) to the EKS Cluster | | [`SSMAgentAddOn`](./ssm-agent.md) | Adds [Amazon SSM Agent](https://docs.aws.amazon.com/systems-manager/latest/userguide/ssm-agent.html) to worker nodes | | [`VpcCniAddOn`](./vpc-cni.md) | Adds the Amazon VPC CNI Amazon EKS addon to support native VPC networking for Amazon EKS | | [`VeleroAddOn`](./velero.md) | Adds [Velero](https://velero.io/) to the EKS Cluster | diff --git a/examples/blueprint-construct/index.ts b/examples/blueprint-construct/index.ts index 888662ac2..c8cb7140e 100644 --- a/examples/blueprint-construct/index.ts +++ b/examples/blueprint-construct/index.ts @@ -3,7 +3,6 @@ import * as ec2 from "aws-cdk-lib/aws-ec2"; import { CapacityType, KubernetesVersion, NodegroupAmiType } from 'aws-cdk-lib/aws-eks'; import { Construct } from "constructs"; import * as blueprints from '../../lib'; -import { HelmAddOn } from '../../lib'; import * as team from '../teams'; import {FlaggerAddOn} from '../../lib/addons/flagger' diff --git a/lib/addons/flagger/hpa.yaml b/lib/addons/flagger/hpa.yaml deleted file mode 100644 index 18fa873ae..000000000 --- a/lib/addons/flagger/hpa.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: autoscaling/v2beta2 -kind: HorizontalPodAutoscaler -metadata: - name: podinfo - namespace: test -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: flagger-loadtester - minReplicas: 2 - maxReplicas: 4 - metrics: - - type: Resource - resource: - name: cpu - target: - type: Utilization - # scale up if usage is above - # 99% of the requested CPU (100m) - averageUtilization: 99 \ No newline at end of file diff --git a/lib/addons/flagger/index.ts b/lib/addons/flagger/index.ts index 50563d373..1d7f82c5f 100644 --- a/lib/addons/flagger/index.ts +++ b/lib/addons/flagger/index.ts @@ -10,12 +10,13 @@ import merge from "ts-deepmerge"; export interface FlaggerAddOnProps extends blueprints.HelmAddOnUserProps {//this is the root level prometheusInstall?: boolean; meshProvider?: MeshProviderOptions; + crd?: boolean; } /** * All the meshProvider values that can be chosen by the user. */ -export const enum MeshProviderOptions { //could use a better name later +export const enum MeshProviderOptions { KUBERNETES = 'kubernetes', ISTIO = 'istio', LINKERD = 'linkerd', @@ -56,9 +57,12 @@ export class FlaggerAddOn extends blueprints.HelmAddOn { let values: Values = { prometheus: { - install: true + install: this.options.prometheusInstall ?? true }, - meshProvider: MeshProviderOptions.KUBERNETES + meshProvider: this.options.meshProvider ?? MeshProviderOptions.KUBERNETES, + crd: { + create: this.options.crd ?? true + } }; values = merge(values, this.props.values ?? {}); diff --git a/lib/addons/flagger/load-tester.yaml b/lib/addons/flagger/load-tester.yaml deleted file mode 100644 index c8f3d4974..000000000 --- a/lib/addons/flagger/load-tester.yaml +++ /dev/null @@ -1,62 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: flagger-loadtester - labels: - app: flagger-loadtester - namespace: test -spec: - selector: - matchLabels: - app: flagger-loadtester - template: - metadata: - labels: - app: flagger-loadtester - annotations: - prometheus.io/scrape: "true" - prometheus.io/port: "8080" - openservicemesh.io/inbound-port-exclusion-list: "80, 8080" - spec: - containers: - - name: loadtester - image: ghcr.io/fluxcd/flagger-loadtester:0.22.0 - imagePullPolicy: IfNotPresent - ports: - - name: http-web - containerPort: 8080 - command: - - ./loadtester - - -port=8080 - - -log-level=info - - -timeout=1h - livenessProbe: - exec: - command: - - wget - - --quiet - - --tries=1 - - --timeout=4 - - --spider - - http://localhost:8080/healthz - timeoutSeconds: 5 - readinessProbe: - exec: - command: - - wget - - --quiet - - --tries=1 - - --timeout=4 - - --spider - - http://localhost:8080/healthz - timeoutSeconds: 5 - resources: - limits: - memory: "512Mi" - cpu: "1000m" - requests: - memory: "32Mi" - cpu: "10m" - securityContext: - readOnlyRootFilesystem: true - runAsUser: 10001 \ No newline at end of file diff --git a/lib/addons/flagger/podinfo-canary.yaml b/lib/addons/flagger/podinfo-canary.yaml deleted file mode 100644 index 1fa3b19f2..000000000 --- a/lib/addons/flagger/podinfo-canary.yaml +++ /dev/null @@ -1,61 +0,0 @@ -apiVersion: flagger.app/v1beta1 -kind: Canary -metadata: - name: podinfo - namespace: test -spec: - # service mesh provider can be: kubernetes, istio, appmesh, nginx, gloo - provider: kubernetes - # deployment reference - targetRef: - apiVersion: apps/v1 - kind: Deployment - name: flagger-loadtester - # the maximum time in seconds for the canary deployment - # to make progress before rollback (default 600s) - progressDeadlineSeconds: 60 - # HPA reference (optional) - autoscalerRef: - apiVersion: autoscaling/v2beta2 - kind: HorizontalPodAutoscaler - name: podinfo - service: - port: 9898 - portDiscovery: true - analysis: - # schedule interval (default 60s) - interval: 30s - # max number of failed checks before rollback - threshold: 2 - # number of checks to run before rollback - iterations: 10 - # Prometheus checks based on - # http_request_duration_seconds histogram - metrics: - - name: request-success-rate - # minimum req success rate (non 5xx responses) - # percentage (0-100) - thresholdRange: - min: 99 - interval: 1m - - name: request-duration - # maximum req duration P99 - # milliseconds - thresholdRange: - max: 500 - interval: 30s - # acceptance/load testing hooks - webhooks: - - name: smoke-test - type: pre-rollout - url: http://flagger-loadtester.test/ - timeout: 15s - metadata: - type: bash - cmd: "curl -sd 'anon' http://podinfo-canary.test:9898/token | grep token" - - name: load-test - url: http://flagger-loadtester.test/ - timeout: 5s - metadata: - type: cmd - cmd: "hey -z 1m -q 10 -c 2 http://podinfo-canary.test:9898/" \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 19ab9dcc4..57f35198a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -28,6 +28,7 @@ nav: - EBS CSI Driver: 'addons/ebs-csi-driver.md' - EFS CSI Driver: 'addons/efs-csi-driver.md' - External DNS: 'addons/external-dns.md' + - Flagger: 'addons/flagger.md' - Karpenter: 'addons/karpenter.md' - Keptn: 'https://github.com/keptn-sandbox/keptn-eks-blueprints-addon' - Kube Proxy: 'addons/kube-proxy.md' From 5768589a7c951065eafd8456a7b806a854906e00 Mon Sep 17 00:00:00 2001 From: Eli Date: Wed, 27 Jul 2022 11:11:32 -0500 Subject: [PATCH 11/16] Removed CRD and added minor changes --- docs/addons/flagger.md | 15 ++------------- examples/blueprint-construct/index.ts | 2 +- lib/addons/flagger/index.ts | 23 ++++++++++++----------- lib/addons/index.ts | 2 +- lib/teams/application-team/index.ts | 11 ----------- 5 files changed, 16 insertions(+), 37 deletions(-) delete mode 100644 lib/teams/application-team/index.ts diff --git a/docs/addons/flagger.md b/docs/addons/flagger.md index 1c722b596..098e1fd75 100644 --- a/docs/addons/flagger.md +++ b/docs/addons/flagger.md @@ -27,7 +27,6 @@ const blueprint = blueprints.EksBlueprint.builder() ## Configuration Options - `prometheus`: Pass true or false if you wish to track deployment metrics via prometheus. `True by default`. -- `crd`: Pass true or false. If true, create Flagger's CRDs (should be enabled for Helm v2 ONLY). If used in Helm v3 it will break the deployment so its `false by default`. - `meshProvider`: Pass from the following enum list of meshProviderOptions. `KUBERNETES by default`. ```typescript @@ -50,15 +49,5 @@ export const enum MeshProviderOptions { ```typescript import * as blueprints from '@aws-quickstart/eks-blueprints'; -const flagger = new blueprints.addons.FlaggerAddOn({ - values: { - prometheus: { - install: false - }, - meshProvider: MeshProviderOptions.APPMESH, - crd: { - create: true - } - } -}); -``` +const flagger = new blueprints.addons.FlaggerAddOn(); +`` \ No newline at end of file diff --git a/examples/blueprint-construct/index.ts b/examples/blueprint-construct/index.ts index c8cb7140e..ef3a1fa8d 100644 --- a/examples/blueprint-construct/index.ts +++ b/examples/blueprint-construct/index.ts @@ -4,7 +4,7 @@ import { CapacityType, KubernetesVersion, NodegroupAmiType } from 'aws-cdk-lib/a import { Construct } from "constructs"; import * as blueprints from '../../lib'; import * as team from '../teams'; -import {FlaggerAddOn} from '../../lib/addons/flagger' +import {FlaggerAddOn} from '../../lib/addons/flagger'; const burnhamManifestDir = './examples/teams/team-burnham/'; const rikerManifestDir = './examples/teams/team-riker/'; diff --git a/lib/addons/flagger/index.ts b/lib/addons/flagger/index.ts index 1d7f82c5f..002adac05 100644 --- a/lib/addons/flagger/index.ts +++ b/lib/addons/flagger/index.ts @@ -1,5 +1,4 @@ -import 'source-map-support/register'; -import * as blueprints from '../../../lib'; +import * as blueprints from '../../'; import { Construct } from 'constructs'; import { Values } from "../../spi"; import merge from "ts-deepmerge"; @@ -7,10 +6,9 @@ import merge from "ts-deepmerge"; /** * User provided options for the FlaggerAddonProps values. */ -export interface FlaggerAddOnProps extends blueprints.HelmAddOnUserProps {//this is the root level +export interface FlaggerAddOnProps extends blueprints.HelmAddOnUserProps { prometheusInstall?: boolean; meshProvider?: MeshProviderOptions; - crd?: boolean; } /** @@ -38,11 +36,17 @@ export const defaultProps: blueprints.HelmAddOnProps & FlaggerAddOnProps = { chart: "flagger", version: "1.22.0", release: "flagger", - repository: "https://flagger.app" + repository: "https://flagger.app", + values: { + prometheus: { + install: true + }, + meshProvider: MeshProviderOptions.KUBERNETES + } }; /** - * This creates and deploys a cluster with the prometheus and mesh provider settings set unless the user specifies their own values for them. + * This creates and deploys a cluster with the FlaggerAddOnProps values for flagger settings with preset values unless the user specifies their own values. */ export class FlaggerAddOn extends blueprints.HelmAddOn { @@ -57,12 +61,9 @@ export class FlaggerAddOn extends blueprints.HelmAddOn { let values: Values = { prometheus: { - install: this.options.prometheusInstall ?? true + install: this.options.prometheusInstall ?? defaultProps.prometheusInstall }, - meshProvider: this.options.meshProvider ?? MeshProviderOptions.KUBERNETES, - crd: { - create: this.options.crd ?? true - } + meshProvider: this.options.meshProvider ?? defaultProps.meshProvider }; values = merge(values, this.props.values ?? {}); diff --git a/lib/addons/index.ts b/lib/addons/index.ts index 04a81e230..de8b743e7 100644 --- a/lib/addons/index.ts +++ b/lib/addons/index.ts @@ -30,7 +30,7 @@ export * from './ebs-csi-driver'; export * from './efs-csi-driver'; export * from './istio-base'; export * from './istio-control-plane'; -//export * from './flagger'; +export * from './flagger'; export class Constants { public static readonly BLUEPRINTS_ADDON = "blueprints-addon"; diff --git a/lib/teams/application-team/index.ts b/lib/teams/application-team/index.ts deleted file mode 100644 index 81a1b68a2..000000000 --- a/lib/teams/application-team/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { ArnPrincipal } from 'aws-cdk-lib/aws-iam'; -import { ApplicationTeam } from '../../../lib/teams'; - -export class TeamApplication extends ApplicationTeam { - constructor(name: string, accountID: string) { - super({ - name: name, - users: [new ArnPrincipal(`arn:aws:iam::${accountID}:user/application`)] - }); - } -} From 4361c80e1625f233c99165374eadeea779d4b05f Mon Sep 17 00:00:00 2001 From: Eli Date: Thu, 28 Jul 2022 12:17:12 -0500 Subject: [PATCH 12/16] minor changes --- docs/addons/flagger.md | 2 +- examples/blueprint-construct/index.ts | 10 +++++----- lib/addons/flagger/index.ts | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/addons/flagger.md b/docs/addons/flagger.md index 098e1fd75..86a873bea 100644 --- a/docs/addons/flagger.md +++ b/docs/addons/flagger.md @@ -20,7 +20,7 @@ const blueprint = blueprints.EksBlueprint.builder() ## Functionality -1. Creates the `flagger` namespace. +1. Creates the `flagger` namespace. This parameter is optional and may be provided by the user in the namespace field of your addon props. 2. Deploys the `flagger` Helm chart into the cluster. 3. Supports [standard helm configuration options](./index.md#standard-helm-add-on-configuration-options) diff --git a/examples/blueprint-construct/index.ts b/examples/blueprint-construct/index.ts index ef3a1fa8d..23da810ca 100644 --- a/examples/blueprint-construct/index.ts +++ b/examples/blueprint-construct/index.ts @@ -3,8 +3,8 @@ import * as ec2 from "aws-cdk-lib/aws-ec2"; import { CapacityType, KubernetesVersion, NodegroupAmiType } from 'aws-cdk-lib/aws-eks'; import { Construct } from "constructs"; import * as blueprints from '../../lib'; +import { HelmAddOn } from '../../lib'; import * as team from '../teams'; -import {FlaggerAddOn} from '../../lib/addons/flagger'; const burnhamManifestDir = './examples/teams/team-burnham/'; const rikerManifestDir = './examples/teams/team-riker/'; @@ -20,7 +20,7 @@ export interface BlueprintConstructProps { export default class BlueprintConstruct { constructor(scope: Construct, props: cdk.StackProps) { - //HelmAddOn.validateHelmVersions = true; + HelmAddOn.validateHelmVersions = true; // TODO: fix IAM user provisioning for admin user // Setup platform team. @@ -132,9 +132,9 @@ export default class BlueprintConstruct { }); blueprints.EksBlueprint.builder() - .addOns(new FlaggerAddOn())//...addOns) - //.clusterProvider(clusterProvider) - .teams()//...teams) + .addOns(...addOns) + .clusterProvider(clusterProvider) + .teams(...teams) .enableControlPlaneLogTypes(blueprints.ControlPlaneLogType.API) .build(scope, blueprintID, props); } diff --git a/lib/addons/flagger/index.ts b/lib/addons/flagger/index.ts index 002adac05..d168e627a 100644 --- a/lib/addons/flagger/index.ts +++ b/lib/addons/flagger/index.ts @@ -7,7 +7,7 @@ import merge from "ts-deepmerge"; * User provided options for the FlaggerAddonProps values. */ export interface FlaggerAddOnProps extends blueprints.HelmAddOnUserProps { - prometheusInstall?: boolean; + installPrometheus?: boolean; meshProvider?: MeshProviderOptions; } @@ -61,7 +61,7 @@ export class FlaggerAddOn extends blueprints.HelmAddOn { let values: Values = { prometheus: { - install: this.options.prometheusInstall ?? defaultProps.prometheusInstall + install: this.options.installPrometheus ?? defaultProps.installPrometheus }, meshProvider: this.options.meshProvider ?? defaultProps.meshProvider }; From 4efc9bb1366484e7c4552b014603736c79ab7479 Mon Sep 17 00:00:00 2001 From: Eli Date: Thu, 28 Jul 2022 15:21:30 -0500 Subject: [PATCH 13/16] fixed cdk list issue --- lib/addons/flagger/index.ts | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/lib/addons/flagger/index.ts b/lib/addons/flagger/index.ts index d168e627a..1b62455e8 100644 --- a/lib/addons/flagger/index.ts +++ b/lib/addons/flagger/index.ts @@ -1,16 +1,15 @@ -import * as blueprints from '../../'; +import { HelmAddOn, HelmAddOnUserProps, HelmAddOnProps } from "../helm-addon"; +import { ClusterInfo } from "../../spi"; import { Construct } from 'constructs'; import { Values } from "../../spi"; import merge from "ts-deepmerge"; - /** * User provided options for the FlaggerAddonProps values. */ -export interface FlaggerAddOnProps extends blueprints.HelmAddOnUserProps { +export interface FlaggerAddOnProps extends HelmAddOnUserProps { installPrometheus?: boolean; meshProvider?: MeshProviderOptions; } - /** * All the meshProvider values that can be chosen by the user. */ @@ -26,11 +25,10 @@ export const enum MeshProviderOptions { TRAEFIK = 'traefik', OSM = 'osm' } - /** * defaultProps makes the flagger namespace and chart. */ -export const defaultProps: blueprints.HelmAddOnProps & FlaggerAddOnProps = { +export const defaultProps: HelmAddOnProps & FlaggerAddOnProps = { name: "flagger", namespace: "flagger", chart: "flagger", @@ -48,24 +46,19 @@ export const defaultProps: blueprints.HelmAddOnProps & FlaggerAddOnProps = { /** * This creates and deploys a cluster with the FlaggerAddOnProps values for flagger settings with preset values unless the user specifies their own values. */ -export class FlaggerAddOn extends blueprints.HelmAddOn { - +export class FlaggerAddOn extends HelmAddOn{ readonly options: FlaggerAddOnProps; - constructor(props?: FlaggerAddOnProps) { super({ ...defaultProps, ...props }); this.options = this.props as FlaggerAddOnProps; } - - deploy(clusterInfo: blueprints.ClusterInfo): Promise { - + deploy(clusterInfo: ClusterInfo): Promise { let values: Values = { prometheus: { install: this.options.installPrometheus ?? defaultProps.installPrometheus }, meshProvider: this.options.meshProvider ?? defaultProps.meshProvider }; - values = merge(values, this.props.values ?? {}); const chart = this.addHelmChart(clusterInfo, values); return Promise.resolve(chart); From 12da84cc00c9767ad726828ba2fe6ab35d9c536b Mon Sep 17 00:00:00 2001 From: Eli Date: Thu, 28 Jul 2022 16:08:53 -0500 Subject: [PATCH 14/16] Fixed code line spacing --- lib/addons/flagger/index.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/addons/flagger/index.ts b/lib/addons/flagger/index.ts index 1b62455e8..9d1a09f8c 100644 --- a/lib/addons/flagger/index.ts +++ b/lib/addons/flagger/index.ts @@ -1,8 +1,8 @@ import { HelmAddOn, HelmAddOnUserProps, HelmAddOnProps } from "../helm-addon"; -import { ClusterInfo } from "../../spi"; import { Construct } from 'constructs'; -import { Values } from "../../spi"; +import { Values, ClusterInfo } from "../../spi"; import merge from "ts-deepmerge"; + /** * User provided options for the FlaggerAddonProps values. */ @@ -10,6 +10,7 @@ export interface FlaggerAddOnProps extends HelmAddOnUserProps { installPrometheus?: boolean; meshProvider?: MeshProviderOptions; } + /** * All the meshProvider values that can be chosen by the user. */ @@ -25,6 +26,7 @@ export const enum MeshProviderOptions { TRAEFIK = 'traefik', OSM = 'osm' } + /** * defaultProps makes the flagger namespace and chart. */ @@ -47,11 +49,14 @@ export const defaultProps: HelmAddOnProps & FlaggerAddOnProps = { * This creates and deploys a cluster with the FlaggerAddOnProps values for flagger settings with preset values unless the user specifies their own values. */ export class FlaggerAddOn extends HelmAddOn{ + readonly options: FlaggerAddOnProps; + constructor(props?: FlaggerAddOnProps) { super({ ...defaultProps, ...props }); this.options = this.props as FlaggerAddOnProps; } + deploy(clusterInfo: ClusterInfo): Promise { let values: Values = { prometheus: { From 795899cf824a774625d8f27b5f23efc982399c76 Mon Sep 17 00:00:00 2001 From: Eli Date: Thu, 28 Jul 2022 16:14:32 -0500 Subject: [PATCH 15/16] more spacing in code --- lib/addons/flagger/index.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/addons/flagger/index.ts b/lib/addons/flagger/index.ts index 9d1a09f8c..9fdaffbc7 100644 --- a/lib/addons/flagger/index.ts +++ b/lib/addons/flagger/index.ts @@ -7,6 +7,7 @@ import merge from "ts-deepmerge"; * User provided options for the FlaggerAddonProps values. */ export interface FlaggerAddOnProps extends HelmAddOnUserProps { + installPrometheus?: boolean; meshProvider?: MeshProviderOptions; } @@ -15,6 +16,7 @@ export interface FlaggerAddOnProps extends HelmAddOnUserProps { * All the meshProvider values that can be chosen by the user. */ export const enum MeshProviderOptions { + KUBERNETES = 'kubernetes', ISTIO = 'istio', LINKERD = 'linkerd', @@ -31,6 +33,7 @@ export const enum MeshProviderOptions { * defaultProps makes the flagger namespace and chart. */ export const defaultProps: HelmAddOnProps & FlaggerAddOnProps = { + name: "flagger", namespace: "flagger", chart: "flagger", @@ -38,6 +41,7 @@ export const defaultProps: HelmAddOnProps & FlaggerAddOnProps = { release: "flagger", repository: "https://flagger.app", values: { + prometheus: { install: true }, @@ -48,24 +52,29 @@ export const defaultProps: HelmAddOnProps & FlaggerAddOnProps = { /** * This creates and deploys a cluster with the FlaggerAddOnProps values for flagger settings with preset values unless the user specifies their own values. */ -export class FlaggerAddOn extends HelmAddOn{ +export class FlaggerAddOn extends HelmAddOn { readonly options: FlaggerAddOnProps; constructor(props?: FlaggerAddOnProps) { + super({ ...defaultProps, ...props }); this.options = this.props as FlaggerAddOnProps; } deploy(clusterInfo: ClusterInfo): Promise { + let values: Values = { + prometheus: { install: this.options.installPrometheus ?? defaultProps.installPrometheus }, meshProvider: this.options.meshProvider ?? defaultProps.meshProvider }; + values = merge(values, this.props.values ?? {}); const chart = this.addHelmChart(clusterInfo, values); + return Promise.resolve(chart); } } \ No newline at end of file From 6a788b27adf04cf5bae1c9f108392bd86a5cf0b7 Mon Sep 17 00:00:00 2001 From: Eli Date: Fri, 29 Jul 2022 10:52:10 -0500 Subject: [PATCH 16/16] some spacing, and comment changes --- lib/addons/flagger/index.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/addons/flagger/index.ts b/lib/addons/flagger/index.ts index 9fdaffbc7..21f13614a 100644 --- a/lib/addons/flagger/index.ts +++ b/lib/addons/flagger/index.ts @@ -7,8 +7,16 @@ import merge from "ts-deepmerge"; * User provided options for the FlaggerAddonProps values. */ export interface FlaggerAddOnProps extends HelmAddOnUserProps { - + + /** + * Controls if prometheus is installed with the addon or not. + * default: true + */ installPrometheus?: boolean; + /** + * Controls what mesh provider from MeshProviderOptions enums list is used. + * default: MeshProviderOptions.KUBERNETES + */ meshProvider?: MeshProviderOptions; } @@ -41,7 +49,6 @@ export const defaultProps: HelmAddOnProps & FlaggerAddOnProps = { release: "flagger", repository: "https://flagger.app", values: { - prometheus: { install: true }, @@ -65,7 +72,6 @@ export class FlaggerAddOn extends HelmAddOn { deploy(clusterInfo: ClusterInfo): Promise { let values: Values = { - prometheus: { install: this.options.installPrometheus ?? defaultProps.installPrometheus },