Skip to content

Commit

Permalink
Add support for internal-frontend (#602)
Browse files Browse the repository at this point in the history
* Add support for internal-frontend

* Disabling internal-frontend by default and ensuring that deployments, services and pdbs are not created if disabled

* Implementing requested changes to internalFrontend naming and ports

* Further updates to internalFrontend, backwards compatibility

* restoring a line I accidentally deleted while resolving a merge conflict

---------

Co-authored-by: Tom Wheeler <[email protected]>
  • Loading branch information
dcaputo-harmoni and tomwheeler authored Dec 18, 2024
1 parent ac23333 commit 34e5abb
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 20 deletions.
12 changes: 12 additions & 0 deletions charts/temporal/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -439,3 +439,15 @@ Usage:
{{- tpl (.value | toYaml) .context }}
{{- end }}
{{- end -}}

{{/*
To modify camelCase to hyphenated internal-frontend service name
*/}}
{{- define "serviceName" -}}
{{- $service := index . 0 -}}
{{- if eq $service "internalFrontend" }}
{{- print "internal-frontend" }}
{{- else }}
{{- print $service }}
{{- end }}
{{- end -}}
8 changes: 8 additions & 0 deletions charts/temporal/templates/admintools-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,17 @@ spec:
env:
# TEMPORAL_CLI_ADDRESS is deprecated, use TEMPORAL_ADDRESS instead
- name: TEMPORAL_CLI_ADDRESS
{{- if and (hasKey .Values.server "internalFrontend") .Values.server.internalFrontend.enabled }}
value: {{ include "temporal.fullname" $ }}-internal-frontend:{{ .Values.server.internalFrontend.service.port }}
{{- else }}
value: {{ include "temporal.fullname" $ }}-frontend:{{ .Values.server.frontend.service.port }}
{{- end }}
- name: TEMPORAL_ADDRESS
{{- if and (hasKey .Values.server "internalFrontend") .Values.server.internalFrontend.enabled }}
value: {{ include "temporal.fullname" $ }}-internal-frontend:{{ .Values.server.internalFrontend.service.port }}
{{- else }}
value: {{ include "temporal.fullname" $ }}-frontend:{{ .Values.server.frontend.service.port }}
{{- end }}
{{- if .Values.admintools.additionalEnv }}
{{- toYaml .Values.admintools.additionalEnv | nindent 12 }}
{{- end }}
Expand Down
11 changes: 11 additions & 0 deletions charts/temporal/templates/server-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ data:
membershipPort: {{ $server.frontend.service.membershipPort }}
bindOnIP: "0.0.0.0"
{{- if and (hasKey .Values.server "internalFrontend") .Values.server.internalFrontend.enabled }}
internal-frontend:
rpc:
grpcPort: {{ $server.internalFrontend.service.port }}
httpPort: {{ $server.internalFrontend.service.httpPort }}
membershipPort: {{ $server.internalFrontend.service.membershipPort }}
bindOnIP: "0.0.0.0"
{{- end }}
history:
rpc:
grpcPort: {{ $server.history.service.port }}
Expand Down Expand Up @@ -177,8 +186,10 @@ data:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- if not (and (hasKey .Values.server "internalFrontend") .Values.server.internalFrontend.enabled) }}
publicClient:
hostPort: "{{ include "temporal.componentname" (list $ "frontend") }}:{{ $server.frontend.service.port }}"
{{- end }}
dynamicConfigClient:
filepath: "/etc/temporal/dynamic_config/dynamic_config.yaml"
Expand Down
13 changes: 10 additions & 3 deletions charts/temporal/templates/server-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{{- if $.Values.server.enabled }}
{{- range $service := (list "frontend" "history" "matching" "worker") }}
{{ $serviceValues := index $.Values.server $service }}
{{- range $rawService := (list "frontend" "internalFrontend" "history" "matching" "worker") }}
{{- $service := include "serviceName" (list $rawService) }}
{{- $serviceValues := index $.Values.server $rawService }}
{{- if or (not (hasKey $serviceValues "enabled")) $serviceValues.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -84,6 +86,10 @@ spec:
secretKeyRef:
name: {{ include "temporal.persistence.secretName" (list $ "visibility") }}
key: {{ include "temporal.persistence.secretKey" (list $ "visibility") }}
{{- if and (hasKey $.Values.server "internalFrontend") $.Values.server.internalFrontend.enabled }}
- name: USE_INTERNAL_FRONTEND
value: "1"
{{- end }}
{{- if $.Values.server.versionCheckDisabled }}
- name: TEMPORAL_VERSION_CHECK_DISABLED
value: "1"
Expand All @@ -102,7 +108,7 @@ spec:
containerPort: {{ $serviceValues.service.port }}
protocol: TCP
{{- end }}
{{- if eq $service "frontend" }}
{{- if or (eq $service "frontend") (eq $service "internal-frontend") }}
- name: http
containerPort: {{ $serviceValues.service.httpPort }}
protocol: TCP
Expand Down Expand Up @@ -170,3 +176,4 @@ spec:
---
{{- end }}
{{- end }}
{{- end }}
6 changes: 5 additions & 1 deletion charts/temporal/templates/server-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ spec:
args: ['temporal operator namespace describe -n {{ $namespace.name }} || temporal operator namespace create -n {{ $namespace.name }}{{- if hasKey $namespace "retention" }} --retention {{ $namespace.retention }}{{- end }}']
env:
- name: TEMPORAL_ADDRESS
{{- if and (hasKey .Values.server "internalFrontend") .Values.server.internalFrontend.enabled }}
value: {{ include "temporal.fullname" $ }}-internal-frontend.{{ $.Release.Namespace }}.svc:{{ .Values.server.internalFrontend.service.port }}
{{- else }}
value: "{{ include "temporal.fullname" $ }}-frontend.{{ $.Release.Namespace }}.svc:{{ $.Values.server.frontend.service.port }}"
{{- end }}
{{- with $.Values.admintools.additionalVolumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
Expand Down Expand Up @@ -193,4 +197,4 @@ spec:
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}{{- end -}}
{{- end -}}{{- end -}}
7 changes: 5 additions & 2 deletions charts/temporal/templates/server-pdb.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{{- if $.Values.server.enabled }}
{{- range $service := (list "frontend" "history" "matching" "worker") }}
{{- $serviceValues := index $.Values.server $service -}}
{{- range $rawService := (list "frontend" "internalFrontend" "history" "matching" "worker") }}
{{- $service := include "serviceName" (list $rawService) }}
{{- $serviceValues := index $.Values.server $rawService }}
{{- if or (not (hasKey $serviceValues "enabled")) $serviceValues.enabled }}
{{- if and (gt ($serviceValues.replicaCount | int) 1) ($serviceValues.podDisruptionBudget) }}
apiVersion: policy/v1
kind: PodDisruptionBudget
Expand All @@ -19,3 +21,4 @@ spec:
---
{{- end }}
{{- end }}
{{- end }}
7 changes: 5 additions & 2 deletions charts/temporal/templates/server-service-monitor.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{{- if $.Values.server.enabled }}
{{- range $service := (list "frontend" "matching" "history" "worker") }}
{{- $serviceValues := index $.Values.server $service -}}
{{- range $rawService := (list "frontend" "internalFrontend" "matching" "history" "worker") }}
{{- $service := include "serviceName" (list $rawService) }}
{{- $serviceValues := index $.Values.server $rawService }}
{{- if or (not (hasKey $serviceValues "enabled")) $serviceValues.enabled }}
{{- if (default $.Values.server.metrics.serviceMonitor.enabled $serviceValues.metrics.serviceMonitor.enabled) }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
Expand Down Expand Up @@ -33,3 +35,4 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- end }}
32 changes: 20 additions & 12 deletions charts/temporal/templates/server-service.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
{{- if $.Values.server.enabled }}
{{- range $rawService := (list "frontend" "internalFrontend") }}
{{- $service := include "serviceName" (list $rawService) }}
{{- $serviceValues := index $.Values.server $rawService }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "temporal.componentname" (list $ "frontend") }}
name: {{ include "temporal.componentname" (list $ $service) }}
labels:
{{- include "temporal.resourceLabels" (list $ "frontend" "") | nindent 4 }}
{{- if .Values.server.frontend.service.annotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.server.frontend.service.annotations "context" $) | nindent 4 }}
{{- include "temporal.resourceLabels" (list $ $service "") | nindent 4 }}
{{- if $serviceValues.service.annotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $serviceValues.service.annotations "context" $) | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.server.frontend.service.type }}
type: {{ $serviceValues.service.type }}
ports:
- port: {{ .Values.server.frontend.service.port }}
- port: {{ $serviceValues.service.port }}
targetPort: rpc
protocol: TCP
name: grpc-rpc
{{- if hasKey .Values.server.frontend.service "nodePort" }}
nodePort: {{ .Values.server.frontend.service.nodePort }}
{{- if hasKey $serviceValues.service "nodePort" }}
nodePort: {{ $serviceValues.service.nodePort }}
{{- end }}
- port: {{ .Values.server.frontend.service.httpPort }}
- port: {{ $serviceValues.service.httpPort }}
targetPort: http
protocol: TCP
name: http
# TODO: Allow customizing the node HTTP port
selector:
app.kubernetes.io/name: {{ include "temporal.name" $ }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/component: frontend

---
{{- range $service := (list "frontend" "matching" "history" "worker") }}
{{ $serviceValues := index $.Values.server $service }}
{{- end }}
{{- end }}

{{- range $rawService := (list "frontend" "internalFrontend" "matching" "history" "worker") }}
{{- $service := include "serviceName" (list $rawService) }}
{{- $serviceValues := index $.Values.server $rawService }}
{{- if or (not (hasKey $serviceValues "enabled")) $serviceValues.enabled }}
apiVersion: v1
kind: Service
metadata:
Expand Down
29 changes: 29 additions & 0 deletions charts/temporal/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,35 @@ server:
containerSecurityContext: {}
topologySpreadConstraints: []
podDisruptionBudget: {}
internalFrontend:
# Enable this to create internal-frontend
enabled: false
service:
# Evaluated as template
annotations: {}
type: ClusterIP
port: 7236
membershipPort: 6936
httpPort: 7246
metrics:
annotations:
enabled: true
serviceMonitor: {}
# enabled: false
prometheus: {}
# timerType: histogram
deploymentLabels: {}
deploymentAnnotations: {}
podAnnotations: {}
podLabels: {}
resources: {}
nodeSelector: {}
tolerations: []
affinity: {}
additionalEnv: []
containerSecurityContext: {}
topologySpreadConstraints: []
podDisruptionBudget: {}
history:
service:
# type: ClusterIP
Expand Down

0 comments on commit 34e5abb

Please sign in to comment.