8000 feat: schema mirror chart updates by matt2e · Pull Request #5585 · block/ftl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: schema mirror chart updates #5585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ DOCKER_IMAGES := '''
"timeline": {},
"lease": {},
"admin": {},
"schema": {}
"schema": {},
"schema-mirror": {}
}
'''
USER_HERMIT_PACKAGES := "openjdk maven go-1"
Expand Down Expand Up @@ -158,7 +159,7 @@ build-without-frontend +tools: build-protos build-zips capture-hermit-versions

# Build all backend binaries
build-backend:
just build ftl ftl-runner ftl-sqlc ftl-admin ftl-cron ftl-http-ingress ftl-lease ftl-provisioner ftl-schema ftl-timeline
just build ftl ftl-runner ftl-sqlc ftl-admin ftl-cron ftl-http-ingress ftl-lease ftl-provisioner ftl-schema ftl-schema-mirror ftl-timeline

# Build all backend tests
build-backend-tests:
Expand Down
7 changes: 4 additions & 3 deletions backend/schemaservice/schemaservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,12 @@ func New(
receiverClient: receiverClient,
rpcOpts: rpcOpts,
}
svc.rpcOpts = append(svc.rpcOpts, rpc.GRPC(ftlv1connect.NewSchemaServiceHandler, svc))
svc.rpcOpts = append(svc.rpcOpts, rpc.GRPC(ftlv1connect.NewSchemaServiceHandler, svc), rpc.StartHook(func(ctx context.Context) error {
go svc.pushSchema(ctx)
return nil
}))
}

go svc.pushSchema(ctx)

svc.devMode = devMode

return svc
Expand Down
5 changes: 5 additions & 0 deletions charts/ftl/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ app.kubernetes.io/name: {{ include "ftl.fullname" . }}
app.kubernetes.io/component: schema
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{- define "ftl-schema-mirror.selectorLabels" -}}
app.kubernetes.io/name: {{ include "ftl.fullname" . }}
app.kubernetes.io/component: schema-mirror
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{/*
Common pod configuration, boilerplate that is not generally used
*/}}
Expand Down
6 changes: 5 additions & 1 deletion charts/ftl/templates/cron-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ spec:
- name: FTL_TIMELINE_ENDPOINT
value: "http://{{ include "ftl.fullname" . }}-timeline:{{ .Values.timeline.port }}"
- name: FTL_SCHEMA_ENDPOINT
value: "http://{{ include "ftl.fullname" . }}-schema:{{ $.Values.schema.services.schema.port }}"
value: {{ if $.Values.schemaMirror.service.enabled -}}
http://{{ include "ftl.fullname" . }}-schema-mirror.{{ .Release.Namespace }}:{{ $.Values.schemaMirror.service.port }}
{{- else -}}
http://{{ include "ftl.fullname" . }}-schema.{{ .Release.Namespace }}:{{ $.Values.schema.services.schema.port }}
{{- end }}
- name: LOG_LEVEL
value: "{{ .Values.cron.logLevel | default .Values.logLevel }}"
- name: LOG_JSON
Expand Down
6 changes: 5 additions & 1 deletion charts/ftl/templates/http-ingress-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ spec:
- name: FTL_TIMELINE_ENDPOINT
value: "http://{{ include "ftl.fullname" . }}-timeline:{{ .Values.timeline.port }}"
- name: FTL_SCHEMA_ENDPOINT
value: "http://{{ include "ftl.fullname" . }}-schema:{{ $.Values.schema.services.schema.port }}"
value: {{ if $.Values.schemaMirror.service.enabled -}}
http://{{ include "ftl.fullname" . }}-schema-mirror.{{ .Release.Namespace }}:{{ $.Values.schemaMirror.service.port }}
{{- else -}}
http://{{ include "ftl.fullname" . }}-schema.{{ .Release.Namespace }}:{{ $.Values.schema.services.schema.port }}
{{- end }}
- name: LOG_LEVEL
value: "{{ .Values.ingress.logLevel | default .Values.logLevel }}"
- name: LOG_JSON
Expand Down
6 changes: 5 additions & 1 deletion charts/ftl/templates/runner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ data:
- name: FTL_ARTEFACT_REGISTRY
value: "{{ .Values.registry.repository }}"
- name: FTL_SCHEMA_ENDPOINT
value: http://{{ include "ftl.fullname" . }}-schema.{{ .Release.Namespace }}:{{ .Values.schema.services.schema.port }}
value: {{ if $.Values.schemaMirror.service.enabled -}}
http://{{ include "ftl.fullname" . }}-schema-mirror.{{ .Release.Namespace }}:{{ $.Values.schemaMirror.service.port }}
{{- else -}}
http://{{ include "ftl.fullname" . }}-schema.{{ .Release.Namespace }}:{{ $.Values.schema.services.schema.port }}
{{- end }}
- name: FTL_LEASE_ENDPOINT
value: http://{{ include "ftl.fullname" . }}-lease.{{ .Release.Namespace }}:{{ .Values.lease.port }}
- name: FTL_TIMELINE_ENDPOINT
Expand Down
4 changes: 4 additions & 0 deletions charts/ftl/templates/schema-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ spec:
value: "http://{{ include "ftl.fullname" . }}-schema:{{ $.Values.schema.services.schema.port }}"
- name: FTL_TIMELINE_ENDPOINT
value: "http://{{ include "ftl.fullname" . }}-timeline:{{ .Values.timeline.port }}"
{{- if .Values.schemaMirror.enabled }}
- name: FTL_SCHEMA_MIRROR_ENDPOINT
value: "http://{{ include "ftl.fullname" . }}-schema-mirror.{{ .Release.Namespace }}:{{ .Values.schemaMirror.service.port }}"
{{- end }}
- name: FTL_REALM
value: {{ .Values.realmName }}
ports:
Expand Down
73 changes: 73 additions & 0 deletions charts/ftl/templates/schema-mirror-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{{ $version := printf "v%s" .Chart.Version -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "ftl.fullname" . }}-schema-mirror
labels:
{{- include "ftl.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.schemaMirror.replicas }}
podManagementPolicy: Parallel
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
ordinals:
start: 1
revisionHistoryLimit: {{ .Values.schemaMirror.revisionHistoryLimit }}
serviceName: {{ .Values.schemaMirror.serviceName }}
selector:
matchLabels:
{{- include "ftl-schema-mirror.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "ftl-schema-mirror.selectorLabels" . | nindent 8 }}
annotations:
{{- if .Values.schemaMirror.podAnnotations }}
{{- toYaml .Values.schemaMirror.podAnnotations | nindent 8 }}
{{- end }}
{{ if .Values.istio.holdApplicationUntilProxyStarts }}
proxy.istio.io/config: |
holdApplicationUntilProxyStarts: true
{{- end }}
spec:
serviceAccountName: {{ .Values.schemaMirror.serviceAccountName }}
securityContext:
fsGroup: 1000
containers:
- name: app
image: "{{ .Values.schemaMirror.image.repository | default (printf "%s/%s" .Values.image.base .Values.schemaMirror.image.name) }}:{{ .Values.schemaMirror.image.tag | default .Values.image.tag | default $version }}"
imagePullPolicy: {{ .Values.schemaMirror.image.pullPolicy | default .Values.image.pullPolicy }}
{{- if .Values.schemaMirror.envFrom }}
envFrom:
{{- if .Values.schemaMirror.envFrom }}
{{- toYaml .Values.schemaMirror.envFrom | nindent 12 }}
{{- end }}
{{- else if or .Values.secrets.logEncryptionKey .Values.secrets.asyncEncryptionKey }}
envFrom:
- secretRef:
name: {{ include "ftl.fullname" . }}-secrets
{{- end }}
env:
{{- if .Values.schemaMirror.env }}
{{- toYaml .Values.schemaMirror.env | nindent 12 }}
{{- end }}
- name: FTL_BIND
value: "http://0.0.0.0:{{ .Values.schemaMirror.service.port }}"
- name: LOG_LEVEL
value: "{{ .Values.schemaMirror.logLevel | default .Values.logLevel }}"
- name: LOG_JSON
value: "{{ .Values.schemaMirror.logJson | default .Values.logJson }}"
- name: FTL_TIMELINE_ENDPOINT
value: "http://{{ include "ftl.fullname" . }}-timeline:{{ .Values.timeline.port }}"
- name: FTL_REALM
value: {{ .Values.realmName }}
ports:
- name: http2
containerPort: {{ .Values.schemaMirror.service.port }}
protocol: "TCP"
{{- include "ftl.resources" .Values.schemaMirror | nindent 10 }}
{{- include "ftl.healthProbes" .Values.schemaMirror | nindent 10 }}
{{- include "ftl.securityContext" .Values.schemaMirror | nindent 10 }}
{{- include "ftl.commonPodConfig" .Values.schemaMirror | nindent 6 }}
11 changes: 11 additions & 0 deletions charts/ftl/templates/schema-mirror-role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if .Values.schemaMirror.enabled }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Values.schemaMirror.serviceAccountName }}
namespace: {{ .Release.Namespace }}
{{- if .Values.schemaMirror.schemaMirrorRoleArn }}
annotations:
eks.amazonaws.com/role-arn: {{ .Values.schemaMirror.schemaMirrorRoleArn }}
{{- end }}
{{- end }}
18 changes: 18 additions & 0 deletions charts/ftl/templates/schema-mirror-services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
labels:
{{- include "ftl.labels" . | nindent 4 }}
name: {{ include "ftl.fullname" . }}-schema-mirror
{{- if .Values.schemaMirror.service.annotations }}
annotations:
{{- toYaml .Values.schemaMirror.service.annotations | nindent 4 }}
{{- end }}
spec:
ports:
- name: http2
port: {{ .Values.schemaMirror.service.port }}
protocol: TCP
selector:
{{- include "ftl-schema-mirror.selectorLabels" . | nindent 4 }}
type: {{ .Values.schemaMirror.service.type | default "ClusterIP" }}
35 changes: 35 additions & 0 deletions charts/ftl/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,41 @@ schema:
topologySpreadConstraints: null
tolerations: null

schemaMirror:
enabled: true
replicas: 1
env: null

revisionHistoryLimit: 0

image:
repository: null
tag: null
pullPolicy: null
name: "ftl-schema-mirror"

resources:
requests:
memory: 256Mi
cpu: 10m
limits:
memory: 256Mi
cpu: 2

envFrom: null
serviceAccountName: ftl-schema-mirror

readinessProbe: null

service:
annotations: null
port: 8892
podAnnotations: null
nodeSelector: null
affinity: null
topologySpreadConstraints: null
tolerations: null

console:
enabled: true
env: null
Expand Down
20 changes: 10 additions & 10 deletions cmd/ftl-schema/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import (
)

var cli struct {
Version kong.VersionFlag `help:"Show version."`
Bind *url.URL `help:"Socket to bind to." default:"http://127.0.0.1:8892" env:"FTL_BIND"`
ObservabilityConfig observability.Config `embed:"" prefix:"o11y-"`
LogConfig log.Config `embed:"" prefix:"log-"`
SchemaServiceConfig schemaservice.Config `embed:""`
TimelineEndpoint *url.URL `help:"Timeline Service endpoint." env:"FTL_TIMELINE_ENDPOINT" default:"http://127.0.0.1:8898"`
MirrorEndpoint optional.Option[*url.URL] `help:"Schema Mirror endpoint." env:"FTL_SCHEMA_MIRROR_ENDPOINT"`
Realm string `help:"Realm to use." env:"FTL_REALM" default:"ftl"`
Version kong.VersionFlag `help:"Show version."`
Bind *url.URL `help:"Socket to bind to." default:"http://127.0.0.1:8892" env:"FTL_BIND"`
ObservabilityConfig observability.Config `embed:"" prefix:"o11y-"`
LogConfig log.Config `embed:"" prefix:"log-"`
SchemaServiceConfig schemaservice.Config `embed:""`
TimelineEndpoint *url.URL `help:"Timeline Service endpoint." env:"FTL_TIMELINE_ENDPOINT" default:"http://127.0.0.1:8898"`
MirrorEndpoint *url.URL `help:"Schema Mirror endpoint." env:"FTL_SCHEMA_MIRROR_ENDPOINT"`
Realm string `help:"Realm to use." env:"FTL_REALM" default:"ftl"`
}

func main() {
Expand All @@ -49,8 +49,8 @@ func main() {
timelineClient := timelineclient.NewClient(ctx, cli.TimelineEndpoint)

var pushClient optional.Option[ftlv1connect.SchemaMirrorServiceClient]
if e, ok := cli.MirrorEndpoint.Get(); ok {
pushClient = optional.Some(rpc.Dial(ftlv1connect.NewSchemaMirrorServiceClient, e.String(), log.Debug))
if cli.MirrorEndpoint != nil {
pushClient = optional.Some(rpc.Dial(ftlv1connect.NewSchemaMirrorServiceClient, cli.MirrorEndpoint.String(), log.Debug))
}

svc := schemaservice.New(ctx, cli.SchemaServiceConfig, timelineClient, pushClient, cli.Realm, false)
Expand Down
Loading
0