Skip to content

Commit

Permalink
add kube configs for timeline service
Browse files Browse the repository at this point in the history
  • Loading branch information
worstell committed Dec 5, 2024
1 parent 58f3b79 commit db50b14
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 4 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ENV PATH="$PATH:/root"
EXPOSE 8891
EXPOSE 8892
EXPOSE 8893
EXPOSE 8894

# Environment variables for all (most) services
ENV FTL_ENDPOINT="http://host.docker.internal:8892"
Expand Down
2 changes: 1 addition & 1 deletion backend/timeline/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

type Config struct {
Bind *url.URL `help:"Socket to bind to." default:"http://127.0.0.1:8890" env:"FTL_BIND"`
Bind *url.URL `help:"Socket to bind to." default:"http://127.0.0.1:8894" env:"FTL_BIND"`
}

func (c *Config) SetDefaults() {
Expand Down
7 changes: 6 additions & 1 deletion charts/ftl/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,9 @@ app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/name: {{ include "ftl.fullname" . }}
app.kubernetes.io/component: http-ingress
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{- end -}}
{{- define "ftl-timeline.selectorLabels" -}}
app.kubernetes.io/name: {{ include "ftl.fullname" . }}
app.kubernetes.io/component: timeline
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
83 changes: 83 additions & 0 deletions charts/ftl/templates/timeline-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{{- if .Values.timeline.enabled }}
{{ $version := printf "v%s" .Chart.Version -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "ftl.fullname" . }}-timeline
labels:
{{- include "ftl.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.timeline.replicas }}
revisionHistoryLimit: {{ .Values.timeline.revisionHistoryLimit }}
selector:
matchLabels:
{{- include "ftl-timeline.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "ftl-timeline.selectorLabels" . | nindent 8 }}
{{- if .Values.timeline.podAnnotations }}
annotations:
{{- toYaml .Values.timeline.podAnnotations | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ .Values.timeline.serviceAccountName }}
containers:
- name: app
image: "{{ .Values.timeline.image.repository }}:{{ .Values.timeline.image.tag | default $version }}"
imagePullPolicy: {{ .Values.timeline.image.pullPolicy }}
resources:
limits:
cpu: "{{ .Values.timeline.resources.limits.cpu }}"
memory: "{{ .Values.timeline.resources.limits.memory }}"
requests:
cpu: "{{ .Values.timeline.resources.requests.cpu }}"
memory: "{{ .Values.timeline.resources.requests.memory }}"
{{- if .Values.timeline.envFrom }}
envFrom:
{{- if .Values.timeline.envFrom }}
{{- toYaml .Values.timeline.envFrom | nindent 12 }}
{{- end }}
{{- end }}
env:
{{- if .Values.timeline.env }}
{{- toYaml .Values.timeline.env | nindent 12 }}
{{- end }}

ports:
{{- range .Values.timeline.ports }}
- name: {{ .name }}
containerPort: {{ .containerPort }}
protocol: {{ .protocol | default "TCP" }}
{{- end }}
readinessProbe:
{{- if .Values.timeline.readinessProbe }}
{{- toYaml .Values.timeline.readinessProbe | nindent 12 }}
{{- else }}
httpGet:
path: /healthz
port: 8894
initialDelaySeconds: 1
periodSeconds: 2
timeoutSeconds: 2
successThreshold: 1
failureThreshold: 15
{{- end }}
{{- if .Values.timeline.nodeSelector }}
nodeSelector:
{{- toYaml .Values.timeline.nodeSelector | nindent 8 }}
{{- end }}
{{- if .Values.timeline.affinity }}
affinity:
{{- toYaml .Values.timeline.affinity | nindent 8 }}
{{- end }}
{{- if .Values.timeline.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml .Values.timeline.topologySpreadConstraints | nindent 8 }}
{{- end }}
{{- if .Values.timeline.tolerations }}
tolerations:
{{- toYaml .Values.timeline.tolerations | nindent 8 }}
{{- end }}

{{- end }}
8 changes: 8 additions & 0 deletions charts/ftl/templates/timeline-role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{- if .Values.timeline.enabled }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Values.timeline.serviceAccountName }}
namespace: {{ .Release.Namespace }}

{{- end }}
24 changes: 24 additions & 0 deletions charts/ftl/templates/timeline-services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if .Values.timeline.enabled }}
apiVersion: v1
kind: Service
metadata:
labels:
{{- include "ftl.labels" . | nindent 4 }}
name: {{ include "ftl.fullname" . }}-timeline
{{- if .Values.timeline.service.annotations }}
annotations:
{{- toYaml .Values.timeline.service.annotations | nindent 4 }}
{{- end }}
spec:
ports:
{{- range .Values.timeline.service.ports }}
- name: {{ .name }}
port: {{ .port }}
protocol: {{ .protocol | default "TCP" }}
targetPort: {{ .targetPort }}
{{- end }}
selector:
{{- include "ftl-timeline.selectorLabels" . | nindent 4 }}
type: {{ .Values.timeline.service.type | default "ClusterIP" }}

{{- end }}
59 changes: 59 additions & 0 deletions charts/ftl/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,62 @@ ingress:
affinity: null
topologySpreadConstraints: null
tolerations: null

timeline:
enabled: true
env:
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: FTL_ENDPOINT
value: "http://ftl-controller:8892"
- name: FTL_BIND
value: "http://$(MY_POD_IP):8894"
- name: HOST_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
ports:
- name: http
containerPort: 8894
protocol: TCP

ingressAnnotations:
kubernetes.io/ingress.class: nginx
replicas: 2
revisionHistoryLimit: 0

image:
repository: "ftl0/ftl-timeline"
pullPolicy: IfNotPresent

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

envFrom: null
serviceAccountName: ftl-timeline

readinessProbe: null

service:
type: ClusterIP
annotations: null
ports:
- name: "http-8894"
port: 80
protocol: TCP
targetPort: 8894

podAnnotations:
proxy.istio.io/config: |
holdApplicationUntilProxyStarts: true
nodeSelector: null
affinity: null
topologySpreadConstraints: null
tolerations: null
2 changes: 2 additions & 0 deletions deployment/Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ full-deploy: build-all-images setup-istio-cluster
kubectl rollout restart deployment ftl-provisioner || true # if this exists already restart it to get the latest image
kubectl rollout restart deployment ftl-cron || true # if this exists already restart it to get the latest image
kubectl rollout restart deployment ftl-http-ingress || true # if this exists already restart it to get the latest image
kubectl rollout restart deployment ftl-timeline || true # if this exists already restart it to get the latest image
just apply || sleep 5 # wait for CRDs to be created, the initial apply will usually fail
just apply

Expand All @@ -37,6 +38,7 @@ wait-for-kube:
kubectl wait --for=condition=ready pod/ftl-postgresql-0 --timeout=5m
kubectl wait --for=condition=available deployment/ftl-controller --timeout=5m
kubectl wait --for=condition=available deployment/ftl-http-ingress --timeout=5m
kubectl wait --for=condition=available deployment/ftl-timeline --timeout=5m
kubectl wait --for=condition=available deployment/registry --timeout=5m
sleep 1
ftl status || sleep 5 && ftl status
Expand Down
10 changes: 8 additions & 2 deletions internal/integration/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,11 @@ func run(t *testing.T, actionsOrOptions ...ActionOrOption) {
controller = rpc.Dial(ftlv1connect.NewControllerServiceClient, "http://localhost:8892", log.Debug)
console = rpc.Dial(pbconsoleconnect.NewConsoleServiceClient, "http://localhost:8892", log.Debug)
schema = rpc.Dial(ftlv1connect.NewSchemaServiceClient, "http://localhost:8892", log.Debug)
timeline = rpc.Dial(timelinev1connect.NewTimelineServiceClient, "http://localhost:8890", log.Debug)
}
if opts.startProvisioner {
provisioner = rpc.Dial(provisionerconnect.NewProvisionerServiceClient, "http://localhost:8893", log.Debug)
}
timeline = rpc.Dial(timelinev1connect.NewTimelineServiceClient, "http://localhost:8894", log.Debug)

testData := filepath.Join(cwd, "testdata", language)
if opts.testDataDir != "" {
Expand All @@ -360,7 +360,6 @@ func run(t *testing.T, actionsOrOptions ...ActionOrOption) {
ic.Controller = controller
ic.Schema = schema
ic.Console = console
ic.Timeline = timeline

Infof("Waiting for controller to be ready")
ic.AssertWithRetry(t, func(t testing.TB, ic TestContext) {
Expand All @@ -379,6 +378,13 @@ func run(t *testing.T, actionsOrOptions ...ActionOrOption) {
})
}

ic.Timeline = timeline
Infof("Waiting for timeline to be ready")
ic.AssertWithRetry(t, func(t testing.TB, ic TestContext) {
_, err := ic.Timeline.Ping(ic, connect.NewRequest(&ftlv1.PingRequest{}))
assert.NoError(t, err)
})

Infof("Starting test")

for _, action := range actions {
Expand Down

0 comments on commit db50b14

Please sign in to comment.