Skip to content
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

Canary with Flagger #78

Merged
merged 12 commits into from
Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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