Skip to content

Commit

Permalink
feat(rollout): add service(s) if statement
Browse files Browse the repository at this point in the history
  • Loading branch information
bluesky6529 committed Nov 15, 2022
1 parent 2498748 commit 45fa6cf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
25 changes: 22 additions & 3 deletions simple/templates/rollout.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,34 @@ spec:
{{ end }}
{{- if .Values.rollout.strategy.blueGreen }}
blueGreen:
{{- if .Values.services }}
{{- if and .Values.rollout.strategy.blueGreen.activeService .Values.rollout.strategy.blueGreen.previewService }}
activeService: {{ .Values.rollout.strategy.blueGreen.activeService }}
previewService: {{ .Values.rollout.strategy.blueGreen.previewService }}
{{- else }}
{{ fail "Because you use \"services\", so you should define .rollout.strategy.blueGreen.activeService and .rollout.strategy.blueGreen.previewService" }}
{{- end }}
{{- else if .Values.service }}
activeService: {{ .Values.rollout.strategy.blueGreen.activeService | default .Values.name }}
previewService: {{ .Values.rollout.strategy.blueGreen.previewService| default (printf "%s-preview" .Values.name) }}
{{- end }}
autoPromotionEnabled: {{ .Values.rollout.strategy.blueGreen.autoPromotionEnabled }}
{{- if .Values.rollout.strategy.blueGreen.extra }}
{{- toYaml .Values.rollout.strategy.blueGreen.extra |nindent 6 }}
{{- end }}
{{ else if .Values.rollout.strategy.canary }}
canary:
{{- if .Values.services }}
{{- if and .Values.rollout.strategy.canary.canaryService .Values.rollout.strategy.canary.stableService }}
canaryService: {{ .Values.rollout.strategy.canary.canaryService }}
stableService: {{ .Values.rollout.strategy.canary.stableService }}
{{- else }}
{{ fail "Because you use \"services\", so you should define .rollout.strategy.canary.canaryService and .rollout.strategy.canary.stableService" }}
{{- end }}
{{- else if .Values.service}}
canaryService: {{ .Values.rollout.strategy.canary.canaryService| default (printf "%s-canary" .Values.name) }}
stableService: {{ .Values.rollout.strategy.canary.stableService | default (printf "%s-stable" .Values.name) }}
{{- end }}
steps:
{{- toYaml .Values.rollout.strategy.canary.steps | nindent 6 }}
{{ if .Values.rollout.strategy.canary.trafficRouting }}
Expand All @@ -53,7 +72,7 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.rollout.strategy.canary.canaryService }}
name: {{ .Values.rollout.strategy.canary.canaryService | default (printf "%s-canary" .Values.name) }}
spec:
{{- if hasKey .Values.service "type" }}
{{- if eq .Values.service.type "ExternalName" }}
Expand Down Expand Up @@ -88,9 +107,9 @@ apiVersion: v1
kind: Service
metadata:
{{- if .Values.rollout.strategy.blueGreen }}
name: {{ .Values.rollout.strategy.blueGreen.previewService }}
name: {{ .Values.rollout.strategy.blueGreen.previewService | default (printf "%s-preview" .Values.name) }}
{{- else }}
name: {{ .Values.rollout.strategy.canary.stableService }}
name: {{ .Values.rollout.strategy.canary.stableService | default (printf "%s-stable" .Values.name) }}
{{- end }}
spec:
{{- if hasKey .Values.service "type" }}
Expand Down
14 changes: 7 additions & 7 deletions simple/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -261,21 +261,21 @@ externalSecrets: {}
# notifications.argoproj.io/subscribe.on-rollout-completed.slack_webhook: ""
# revisionHistoryLimit: 10
# strategy:
# # blueGreen and canary can't exist at the same time
# # blueGreen and canary CANNOT exist at the same time
# blueGreen:
# activeService: "app-name"
# previewService: "app-name-preview"
# activeService: "app-name" # If uses service, this is an optional value; if uses services, then this is a required value
# previewService: "app-name-preview" # If uses service, this is an optional value; if uses services, then this is a required value
# autoPromotionEnabled: false # Required value. if you don't want auto promotion, type false.
# extra:
# autoPromotionEnabled: false # remember to add this if you don't want auto promotion
# prePromotionAnalysis:
# templates:
# - templateName: success-rate
# args:
# - name: service-name
# value: guestbook-svc.default.svc.cluster.local
# canary:
# canaryService: "app-name-canary"
# stableService: "app-name-stable"
# canaryService: "app-name-canary" # If uses service, this is an optional value; if uses services, then this is a required value
# stableService: "app-name-stable"# If uses service, this is an optional value; if uses services, then this is a required value
# steps:
# - setWeight: 10
# - pause: { duration: 1h }
Expand All @@ -284,7 +284,7 @@ externalSecrets: {}
# - templateName: success-rate
# - setWeight: 100
# trafficRouting:
# alb: # if you choose trafficRouting.alb, remember to modify ingress servicePort: use-annotation
# alb: # If choose trafficRouting.alb, remember to modify ingress servicePort: use-annotation
# ingress: ingress
# servicePort: 443
# rootService: "app-name" # origin service name
Expand Down

0 comments on commit 45fa6cf

Please sign in to comment.