Browse Source

update ingress

pull/82/head
brandon 4 years ago
parent
commit
ee09481bcd
  1. 39
      helm-guestbook/templates/ingress.yaml
  2. 24
      helm-guestbook/templates/rollout.yaml
  3. 20
      helm-guestbook/templates/root_service.yaml
  4. 33
      helm-guestbook/values.yaml

39
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 }}

24
helm-guestbook/templates/rollout.yaml

@ -66,16 +66,14 @@ spec:
maxUnavailable: 0 maxUnavailable: 0
canaryService: guestbook-canary-service canaryService: guestbook-canary-service
stableService: {{ template "helm-guestbook.fullname" . }} stableService: {{ template "helm-guestbook.fullname" . }}
steps: trafficRouting:
- setWeight: 20 alb:
- pause: # The referenced ingress will be injected with a custom action annotation, directing
duration: 1m # 1 minute # the AWS Load Balancer Controller to split traffic between the canary and stable
- setWeight: 40 # Service, according to the desired traffic weight (required).
- pause: ingress: {{ template "helm-guestbook.fullname" . }}
duration: 1m # 1 minute # Reference to a Service that the Ingress must target in one of the rules (optional).
- setWeight: 60 # If omitted, uses canary.stableService.
- pause: rootService: guestbook-root-service
duration: 1m # 1 minute # Service port is the port which the Service listens on (required).
- setWeight: 80 servicePort: {{ .Values.service.port }}
- pause:
duration: 1m # 1 minute

20
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 }}

33
helm-guestbook/values.yaml

@ -14,8 +14,37 @@ service:
port: 80 port: 80
ingress: ingress:
enabled: false enabled: true
annotations: {} 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/ingress.class: nginx
# kubernetes.io/tls-acme: "true" # kubernetes.io/tls-acme: "true"
path: / path: /

Loading…
Cancel
Save