Skip to content

Commit

Permalink
Support ingress mode in the chart.
Browse files Browse the repository at this point in the history
If you set ingress.enabled to True, the GUI always uses a LoadBalancer, the "face" deployment is always an "ingress", and there's a new workload called "cell" that does the actual face-workload functionality. It's done this way so that the GUI doesn't change, and so that the request into the cluster is always made with a path of "/face/".

Signed-off-by: Flynn <[email protected]>
  • Loading branch information
kflynn committed Oct 2, 2024
1 parent 24d1bfd commit b34713b
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 9 deletions.
8 changes: 8 additions & 0 deletions faces-chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@
{{- include "partials.select-errorFraction" (dict "source" .Values.face) -}}
{{- end -}}

{{- define "partials.ingress-image" -}}
{{- include "partials.select-image" (dict "source" .Values.ingress "root" .) -}}
{{- end -}}

{{- define "partials.ingress-imagePullPolicy" -}}
{{- include "partials.select-imagePullPolicy" (dict "source" .Values.ingress "root" .) -}}
{{- end -}}

{{- define "partials.color-image" -}}
{{- include "partials.select-image" (dict "source" .Values.color "default" .Values.backend "root" .) -}}
{{- end -}}
Expand Down
20 changes: 12 additions & 8 deletions faces-chart/templates/face.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
{{- $name := "face" -}}
{{- if .Values.ingress.enabled -}}
{{- $name = "cell" -}}
{{- end -}}
---
apiVersion: v1
kind: Service
metadata:
name: face
name: {{ $name }}
namespace: {{ .Release.Namespace }}
labels:
service: face
service: {{ $name }}
spec:
type: ClusterIP
selector:
service: face
service: {{ $name }}
ports:
- port: 80
targetPort: http
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: face
name: {{ $name }}
namespace: {{ .Release.Namespace }}
labels:
service: face
service: {{ $name }}
spec:
replicas: 1
selector:
matchLabels:
service: face
service: {{ $name }}
template:
metadata:
labels:
service: face
service: {{ $name }}
spec:
containers:
- name: face
- name: {{ $name }}
image: {{ include "partials.face-image" . }}
imagePullPolicy: {{ include "partials.face-imagePullPolicy" . }}
ports:
Expand Down
6 changes: 5 additions & 1 deletion faces-chart/templates/faces-gui.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{{- $serviceType := .Values.gui.serviceType -}}
{{- if .Values.ingress.enabled -}}
{{- $serviceType = "LoadBalancer" -}}
{{- end -}}
---
apiVersion: v1
kind: Service
Expand All @@ -7,7 +11,7 @@ metadata:
labels:
service: faces-gui
spec:
type: {{ .Values.gui.serviceType }}
type: {{ $serviceType }}
selector:
service: faces-gui
ports:
Expand Down
56 changes: 56 additions & 0 deletions faces-chart/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{- if .Values.ingress.enabled -}}
---
apiVersion: v1
kind: Service
metadata:
name: face
namespace: {{ .Release.Namespace }}
labels:
service: face
spec:
type: ClusterIP
selector:
service: face
ports:
- port: 80
targetPort: http
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: face
namespace: {{ .Release.Namespace }}
labels:
service: face
spec:
replicas: 1
selector:
matchLabels:
service: face
template:
metadata:
labels:
service: face
spec:
containers:
- name: face
image: {{ include "partials.ingress-image" . }}
imagePullPolicy: {{ include "partials.ingress-imagePullPolicy" . }}
ports:
- name: http
containerPort: 8000
env:
- name: FACES_SERVICE
value: "ingress"
- name: USER_HEADER_NAME
value: {{ .Values.authHeader | quote }}
- name: CELL_SERVICE
value: {{ .Values.ingress.cellService | quote }}
resources:
requests:
cpu: 100m
memory: 64Mi
limits:
cpu: 250m
memory: 128Mi
{{- end -}}
8 changes: 8 additions & 0 deletions faces-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ face:
errorFraction: "20"
delayBuckets: ""

ingress:
enabled: False # If set to True, enables the ingress workload
image: "" # If set, overrides the imageName/imageTag pair
imageName: ghcr.io/buoyantio/faces-workload
imageTag: "" # If not set, uses the defaultImageTag
imagePullPolicy: "" # If not set, uses the default imagePullPolicy
cellService: "cell" # Override if desired

backend:
image: "" # If set, overrides the imageName/imageTag pair
imageName: ghcr.io/buoyantio/faces-workload
Expand Down

0 comments on commit b34713b

Please sign in to comment.