-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from dasmeta/DMVP-5664-flagger-canary-deploym…
…ents-ability DMVP-5664 flagger canary deployments ability
- Loading branch information
Showing
11 changed files
with
346 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{{- if .Values.rolloutStrategy.enabled -}} | ||
{{- if eq .Values.rolloutStrategy.operator "flagger" -}} | ||
apiVersion: flagger.app/v1beta1 | ||
kind: Canary | ||
metadata: | ||
name: {{ include "base.fullname" . }} | ||
spec: | ||
provider: {{ .Values.rolloutStrategy.configs.provider | default "nginx" }} | ||
# deployment reference | ||
targetRef: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
name: {{ include "base.fullname" . }} | ||
# ingress reference (TODO: there is supports for multiple ingresses, check and implement multiple ingress support here also ) | ||
ingressRef: | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
name: {{ include "base.fullname" . }} | ||
{{- if .Values.autoscaling.enabled }} | ||
# HPA reference (optional) | ||
autoscalerRef: | ||
apiVersion: autoscaling/v2 | ||
kind: HorizontalPodAutoscaler | ||
name: {{ include "base.fullname" . }} | ||
primaryScalerReplicas: | ||
# min and max replicas count for primary hpa, default to main app hpa, the main app hpa values also being used for canary deploy hpa so we use this options to have custom values for primary hpa | ||
minReplicas: {{ .Values.rolloutStrategy.configs.primaryScalerMinReplicas | default .Values.autoscaling.minReplicas }} | ||
maxReplicas: {{ .Values.rolloutStrategy.configs.primaryScalerMaxReplicas | default .Values.autoscaling.maxReplicas }} | ||
{{- end }} | ||
|
||
# the maximum time in seconds for the canary deployment to make progress before it is rollback (default 600s) | ||
progressDeadlineSeconds: {{ .Values.rolloutStrategy.configs.progressDeadlineSeconds | default 600 }} | ||
service: | ||
# ClusterIP port number | ||
port: {{ .Values.service.port }} | ||
# container port number or name | ||
targetPort: {{ .Values.service.targetPort | default .Values.containerPort }} | ||
analysis: | ||
# minimum percentage of canary pods that must be ready before considering canary ready for traffic shifting (default 100) | ||
canaryReadyThreshold: {{ .Values.rolloutStrategy.configs.canaryReadyThreshold | default 100 }} | ||
# minimum percentage of primary pods that must be ready before considering primary ready for traffic shifting (default 100) | ||
primaryReadyThreshold: {{ .Values.rolloutStrategy.configs.primaryReadyThreshold | default 100 }} | ||
# schedule interval (default 60s) | ||
interval: {{ .Values.rolloutStrategy.configs.interval | default "60s" }} | ||
# max number of failed metric checks before rollback (default 10) | ||
threshold: {{ .Values.rolloutStrategy.configs.threshold | default 10 }} | ||
# max traffic percentage (0-100) routed to canary (default 30) | ||
maxWeight: {{ .Values.rolloutStrategy.configs.maxWeight | default 30 }} | ||
# canary increment step percentage (0-100) (default 10) | ||
stepWeight: {{ .Values.rolloutStrategy.configs.stepWeight | default 10 }} | ||
# metrics checks | ||
metrics: | ||
{{- toYaml .Values.rolloutStrategy.configs.metrics | nindent 6 }} | ||
{{- if .Values.rolloutStrategy.configs.webhooks }} | ||
# testing (optional) | ||
webhooks: | ||
{{- toYaml .Values.rolloutStrategy.configs.webhooks | nindent 6 }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: v2 | ||
name: flagger-metric-template | ||
description: A Helm chart for Kubernetes to create Flagger metric templates | ||
|
||
# A chart can be either an 'application' or a 'library' chart. | ||
# | ||
# Application charts are a collection of templates that can be packaged into versioned archives | ||
# to be deployed. | ||
# | ||
# Library charts provide useful utilities or functions for the chart developer. They're included as | ||
# a dependency of application charts to inject those utilities and functions into the rendering | ||
# pipeline. Library charts do not define any templates and therefore cannot be deployed. | ||
type: application | ||
|
||
# This is the chart version. This version number should be incremented each time you make changes | ||
# to the chart and its templates, including the app version. | ||
# Versions are expected to follow Semantic Versioning (https://semver.org/) | ||
version: 0.1.0 | ||
|
||
# This is the version number of the application being deployed. This version number should be | ||
# incremented each time you make changes to the application. Versions are not expected to | ||
# follow Semantic Versioning. They should reflect the version the application is using. | ||
# It is recommended to use it with quotes. | ||
appVersion: "0.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This helm chart allows to create flagger custom metric templates to use in canary rollout | ||
|
||
## There is option named `createNginxCustomMetricTemplates`(which is true by default) to create nginx custom metrics named `request-success-rate-custom` and `request-duration-custom` | ||
|
||
## example of custom metric templates | ||
```yaml | ||
metricTemplates: | ||
- name: my-custom-request-rate-metric-template | ||
query: | | ||
sum(rate(nginx_ingress_controller_requests{exported_namespace="{{ namespace }}",ingress="{{ ingress }}",status!~"5.*"}[1m]))/sum(rate(nginx_ingress_controller_requests{exported_namespace="{{ namespace }}",ingress="{{ ingress }}"}[1m]))*100 | ||
``` |
60 changes: 60 additions & 0 deletions
60
charts/flagger-metric-template/templates/flagger-canary-nginx-custom.metric-template.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{{- if .Values.createNginxCustomMetricTemplates -}} | ||
apiVersion: flagger.app/v1beta1 | ||
kind: MetricTemplate | ||
metadata: | ||
name: request-success-rate-custom | ||
spec: | ||
provider: | ||
{{- toYaml .Values.provider | nindent 4 }} | ||
query: | | ||
sum( | ||
rate( | ||
nginx_ingress_controller_requests{ | ||
exported_namespace="{{ "{{" }} namespace {{ "}}" }}", | ||
ingress="{{ "{{" }} ingress {{ "}}" }}", | ||
canary!="", | ||
status!~"5.*" | ||
}[{{ "{{" }} interval {{ "}}" }}] | ||
) | ||
) | ||
/ | ||
sum( | ||
rate( | ||
nginx_ingress_controller_requests{ | ||
exported_namespace="{{ "{{" }} namespace {{ "}}" }}", | ||
ingress="{{ "{{" }} ingress {{ "}}" }}", | ||
canary!="" | ||
}[{{ "{{" }} interval {{ "}}" }}] | ||
) | ||
) | ||
* 100 | ||
--- | ||
apiVersion: flagger.app/v1beta1 | ||
kind: MetricTemplate | ||
metadata: | ||
name: request-duration-custom | ||
spec: | ||
provider: | ||
{{- toYaml .Values.provider | nindent 4 }} | ||
query: | | ||
sum( | ||
rate( | ||
nginx_ingress_controller_response_duration_seconds_sum{ | ||
exported_namespace="{{ "{{" }} namespace {{ "}}" }}", | ||
ingress="{{ "{{" }} ingress {{ "}}" }}", | ||
canary!="" | ||
}[{{ "{{" }} interval {{ "}}" }}] | ||
) | ||
) | ||
/ | ||
sum( | ||
rate( | ||
nginx_ingress_controller_response_duration_seconds_count{ | ||
exported_namespace="{{ "{{" }} namespace {{ "}}" }}", | ||
ingress="{{ "{{" }} ingress {{ "}}" }}", | ||
canary!="" | ||
}[{{ "{{" }} interval {{ "}}" }}] | ||
) | ||
) | ||
* 1000 | ||
{{- end }} |
11 changes: 11 additions & 0 deletions
11
charts/flagger-metric-template/templates/metric-templates.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{{- range $key, $metricTemplate := .Values.metricTemplates }} | ||
--- | ||
apiVersion: flagger.app/v1beta1 | ||
kind: MetricTemplate | ||
metadata: | ||
name: {{ $metricTemplate.name }} | ||
spec: | ||
provider: | ||
{{- toYaml $.Values.provider | nindent 4 }} | ||
query: {{ $metricTemplate.query }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Default values for flagger-metric-template. | ||
# This is a YAML-formatted file. | ||
# Declare variables to be passed into your templates. | ||
|
||
# metrics provider config for metric-templates, for more info check doc https://docs.flagger.app/usage/metrics#custom-metrics | ||
provider: | ||
type: prometheus | ||
address: http://prometheus-service.monitoring:9090 | ||
|
||
# Whether to create `request-success-rate-custom` and `request-duration-custom` nginx metric templates, this can be used in case we use custom prometheus operator instead of flagger helm included one | ||
createNginxCustomMetricTemplates: true | ||
|
||
# List of custom metric template configs | ||
metricTemplates: [] | ||
## example for metric templates | ||
# metricTemplates: | ||
# - name: my-custom-request-rate-metric-template | ||
# query: | | ||
# sum(rate(nginx_ingress_controller_requests{exported_namespace="{{ namespace }}",ingress="{{ ingress }}",status!~"5.*"}[1m]))/sum(rate(nginx_ingress_controller_requests{exported_namespace="{{ namespace }}",ingress="{{ ingress }}"}[1m]))*100 |