From ee09481bcdb0d737801b5b141c89fa954a0972c2 Mon Sep 17 00:00:00 2001 From: brandon Date: Sat, 3 Apr 2021 10:29:12 -0500 Subject: [PATCH] update ingress --- helm-guestbook/templates/ingress.yaml | 39 ++++++++++++++++++++++ helm-guestbook/templates/rollout.yaml | 24 ++++++------- helm-guestbook/templates/root_service.yaml | 20 +++++++++++ helm-guestbook/values.yaml | 33 ++++++++++++++++-- 4 files changed, 101 insertions(+), 15 deletions(-) create mode 100644 helm-guestbook/templates/ingress.yaml create mode 100644 helm-guestbook/templates/root_service.yaml diff --git a/helm-guestbook/templates/ingress.yaml b/helm-guestbook/templates/ingress.yaml new file mode 100644 index 0000000..d5d9907 --- /dev/null +++ b/helm-guestbook/templates/ingress.yaml @@ -0,0 +1,39 @@ +{{- if .Values.ingress.enabled -}} +apiVersion: networking.k8s.io/v1beta1 +kind: Ingress +metadata: + name: {{ template "helm-guestbook.fullname" . }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + rules: + # host rule to only reach the desired pods (aka canary/preview) + - host: guestbook-desired.argoproj.io + http: + paths: + - backend: + serviceName: guestbook-canary-service + servicePort: {{ .Values.service.port }} + path: /* + # host rule to only reach the stable pods + - host: guestbook-stable.argoproj.io + http: + paths: + - backend: + serviceName: {{ template "helm-guestbook.fullname" . }} + servicePort: {{ .Values.service.port }} + path: /* + # default rule which omits host, and will split traffic between desired vs. stable + - http: + paths: + - path: /* + backend: + # serviceName must match either: canary.trafficRouting.alb.rootService (if specified), + # or canary.stableService (if rootService is omitted) + serviceName: root-service + # servicePort must be the value: use-annotation + # This instructs AWS Load Balancer Controller to look to annotations on how to direct traffic + servicePort: use-annotation +{{- end }} \ No newline at end of file diff --git a/helm-guestbook/templates/rollout.yaml b/helm-guestbook/templates/rollout.yaml index f544d16..57081ea 100644 --- a/helm-guestbook/templates/rollout.yaml +++ b/helm-guestbook/templates/rollout.yaml @@ -66,16 +66,14 @@ spec: maxUnavailable: 0 canaryService: guestbook-canary-service stableService: {{ template "helm-guestbook.fullname" . }} - steps: - - setWeight: 20 - - pause: - duration: 1m # 1 minute - - setWeight: 40 - - pause: - duration: 1m # 1 minute - - setWeight: 60 - - pause: - duration: 1m # 1 minute - - setWeight: 80 - - pause: - duration: 1m # 1 minute \ No newline at end of file + trafficRouting: + alb: + # The referenced ingress will be injected with a custom action annotation, directing + # the AWS Load Balancer Controller to split traffic between the canary and stable + # Service, according to the desired traffic weight (required). + ingress: {{ template "helm-guestbook.fullname" . }} + # Reference to a Service that the Ingress must target in one of the rules (optional). + # If omitted, uses canary.stableService. + rootService: guestbook-root-service + # Service port is the port which the Service listens on (required). + servicePort: {{ .Values.service.port }} diff --git a/helm-guestbook/templates/root_service.yaml b/helm-guestbook/templates/root_service.yaml new file mode 100644 index 0000000..6999145 --- /dev/null +++ b/helm-guestbook/templates/root_service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: guestbook-root-service + namespace: {{ template "helm-guestbook.fullname" . }} + labels: + app: {{ template "helm-guestbook.name" . }} + chart: {{ template "helm-guestbook.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + app: {{ template "helm-guestbook.name" . }} + release: {{ .Release.Name }} diff --git a/helm-guestbook/values.yaml b/helm-guestbook/values.yaml index d1563f3..1bca953 100644 --- a/helm-guestbook/values.yaml +++ b/helm-guestbook/values.yaml @@ -14,8 +14,37 @@ service: port: 80 ingress: - enabled: false - annotations: {} + enabled: true + annotations: + kubernetes.io/ingress.class: alb + alb.ingress.kubernetes.io/actions.root-service: | + { + "Type":"forward", + "ForwardConfig":{ + "TargetGroups":[ + { + "Weight":20, + "ServiceName":"canary-service", + "ServicePort":"{{ .Values.service.port }}" + }, + { + "Weight":40, + "ServiceName":"canary-service", + "ServicePort":"{{ .Values.service.port }}" + }, + { + "Weight":60, + "ServiceName":"canary-service", + "ServicePort":"{{ .Values.service.port }}" + }, + { + "Weight":80, + "ServiceName":"stable-service", + "ServicePort":"{{ .Values.service.port }}" + } + ] + } + } # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" path: /