Skip to content

Commit

Permalink
Merge pull request #78 from vfarcic/canary
Browse files Browse the repository at this point in the history
Canary with Flagger
  • Loading branch information
jstrachan authored Jan 3, 2020
2 parents 3b349fa + ea59442 commit 6bd30e4
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 1 deletion.
58 changes: 58 additions & 0 deletions packs/go/charts/templates/canary.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{{- if .Values.canary.enabled }}
apiVersion: flagger.app/v1alpha3
kind: Canary
metadata:
name: {{ template "fullname" . }}
labels:
draft: {{ default "draft-app" .Values.draft }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
spec:
provider: istio
targetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "fullname" . }}
progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }}
{{- if .Values.hpa.enabled }}
autoscalerRef:
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
name: {{ template "fullname" . }}
{{- end }}
service:
port: {{ .Values.service.externalPort }}
targetPort: {{ .Values.service.internalPort }}
gateways:
- {{ template "fullname" . }}
hosts:
- {{ .Values.canary.host }}
canaryAnalysis:
interval: {{ .Values.canary.canaryAnalysis.interval }}
threshold: {{ .Values.canary.canaryAnalysis.threshold }}
maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }}
stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }}
metrics:
- name: request-success-rate
threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }}
interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }}
- name: request-duration
threshold: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }}
interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }}

---

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: {{ template "fullname" . }}
spec:
selector:
istio: ingressgateway
servers:
- port:
number: {{ .Values.service.externalPort }}
name: http
protocol: HTTP
hosts:
- {{ .Values.canary.host }}
{{- end }}
3 changes: 3 additions & 0 deletions packs/go/charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ metadata:
draft: {{ default "draft-app" .Values.draft }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
spec:
{{- if .Values.hpa.enabled }}
{{- else }}
replicas: {{ .Values.replicaCount }}
{{- end }}
template:
metadata:
labels:
Expand Down
25 changes: 25 additions & 0 deletions packs/go/charts/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- if .Values.hpa.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "fullname" . }}
labels:
draft: {{ default "draft-app" .Values.draft }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "fullname" . }}
minReplicas: {{ .Values.hpa.minReplicas }}
maxReplicas: {{ .Values.hpa.maxReplicas }}
metrics:
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }}
{{- end }}
2 changes: 1 addition & 1 deletion packs/go/charts/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.knativeDeploy }}
{{- if or .Values.knativeDeploy .Values.canary.enabled }}
{{- else }}
apiVersion: v1
kind: Service
Expand Down
30 changes: 30 additions & 0 deletions packs/go/charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,36 @@ env:
# enable this flag to use knative serve to deploy the app
knativeDeploy: false

# HorizontalPodAutoscaler
hpa:
enabled: false
minReplicas: 2
maxReplicas: 6
cpuTargetAverageUtilization: 80
memoryTargetAverageUtilization: 80

# Canary deployments
# If enabled, Istio and Flagger need to be installed in the cluster
canary:
enabled: false
progressDeadlineSeconds: 60
canaryAnalysis:
interval: "1m"
threshold: 5
maxWeight: 60
stepWeight: 20
# WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics.
metrics:
requestSuccessRate:
threshold: 99
interval: "1m"
requestDuration:
threshold: 1000
interval: "1m"
# The host is using Istio Gateway and is currently not auto-generated
# Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production)
host: acme.com

service:
name: REPLACE_ME_APP_NAME
type: ClusterIP
Expand Down

0 comments on commit 6bd30e4

Please sign in to comment.