-
Notifications
You must be signed in to change notification settings - Fork 207
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
Flagger addon #440
base: main
Are you sure you want to change the base?
Flagger addon #440
Changes from 10 commits
25a5798
85c3fd9
159cb5a
050652a
81916a4
9e1705c
9d2db1f
79135f2
2cca7a8
39215e8
8459432
4ac7046
5768589
4361c80
4efc9bb
1a1a313
12da84c
795899c
6a788b2
3b7a146
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this parameter is optional and may provided by the user in the namespace field of your addon props. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed it to this: 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) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import { Construct } from "constructs"; | |
import * as blueprints from '../../lib'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix the GitHub actions warnings. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure what you mean by that? Are you saying I should have it instead of ../../lib be the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use file view : https://github.com/aws-quickstart/cdk-eks-blueprints/pull/440/files#diff-40d4a72c979379c5b6ab47139c410af18bd607fd5b4f8a26d1aaef9956d8d447 scroll down from my comment and observe github actions warnings. |
||
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 +21,7 @@ export interface BlueprintConstructProps { | |
export default class BlueprintConstruct { | ||
constructor(scope: Construct, props: cdk.StackProps) { | ||
|
||
HelmAddOn.validateHelmVersions = true; | ||
//HelmAddOn.validateHelmVersions = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please fix the three github actions warning below like 'teams' is assigned a value but never used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I revert this file back to what it was before since I was using it for testing purposes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, please revert. |
||
|
||
// TODO: fix IAM user provisioning for admin user | ||
// Setup platform team. | ||
|
@@ -132,9 +133,9 @@ export default class BlueprintConstruct { | |
}); | ||
|
||
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); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: autoscaling/v2beta2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is this file for ? why is it in the source control? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was in the file example I got this from and figured an example api version in the file wouldn't hurt the test I was using it for. And I have not deleted those temporary yaml files yet, I can do that now. |
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import 'source-map-support/register'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't need this import. Why was it added? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure might have been from a quick fix I did but it was not faded so I assumed it was doing something. I have deleted it and see it did not mess anything up. |
||
import * as blueprints from '../../../lib'; | ||
import { Construct } from 'constructs'; | ||
import { Values } from "../../spi"; | ||
import merge from "ts-deepmerge"; | ||
|
||
/** | ||
shapirov103 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* User provided options for the FlaggerAddonProps values. | ||
*/ | ||
export interface FlaggerAddOnProps extends blueprints.HelmAddOnUserProps {//this is the root level | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please remove the comment // this is the root level There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was a personal note I forgot to remove, thanks for the catch. |
||
prometheusInstall?: boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's rename to https://github.com/aws-quickstart/cdk-eks-blueprints/blob/main/lib/addons/appmesh/index.ts#L17 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense. |
||
meshProvider?: MeshProviderOptions; | ||
} | ||
|
||
/** | ||
shapirov103 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* 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' | ||
} | ||
|
||
/** | ||
shapirov103 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* defaultProps makes the flagger namespace and chart. | ||
*/ | ||
export const defaultProps: blueprints.HelmAddOnProps & FlaggerAddOnProps = { | ||
name: "flagger", | ||
namespace: "flagger", | ||
chart: "flagger", | ||
version: "1.22.0", | ||
release: "flagger", | ||
repository: "https://flagger.app" | ||
}; | ||
|
||
/** | ||
* 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line break here. |
||
|
||
constructor(props?: FlaggerAddOnProps) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line break here. |
||
super({ ...defaultProps, ...props }); | ||
this.options = this.props as FlaggerAddOnProps; | ||
} | ||
|
||
deploy(clusterInfo: blueprints.ClusterInfo): Promise<Construct> { | ||
|
||
let values: Values = { | ||
prometheus: { | ||
install: true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are hardcoding the option that we allows customers to pass, ignoring their setting. |
||
}, | ||
meshProvider: MeshProviderOptions.KUBERNETES | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't hardcode there values. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought the way this worked was it set values to these, then if the user put in their own values |
||
}; | ||
|
||
values = merge(values, this.props.values ?? {}); | ||
const chart = this.addHelmChart(clusterInfo, values); | ||
return Promise.resolve(chart); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
apiVersion: apps/v1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this file |
||
kind: Deployment | ||
metadata: | ||
name: flagger-loadtester | ||
labels: | ||
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: | ||
annotations: | ||
prometheus.io/scrape: "true" | ||
prometheus.io/port: "9797" | ||
labels: | ||
app: flagger-loadtester | ||
spec: | ||
containers: | ||
- 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
apiVersion: flagger.app/v1beta1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this file |
||
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 | ||
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/" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { ArnPrincipal } from 'aws-cdk-lib/aws-iam'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this file here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops when I was trying to figure stuff out for patterns and add a team for it I think I put this into the wrong program when I swapped between them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is still in the code, why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is gone now, guess I got distracted by other issues and never got around to deleting it. I have done it now though. |
||
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`)] | ||
}); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you want to describe supported configuration options?