Skip to content
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

chore(session-recordings): separate session recordings from events #666

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
15 changes: 12 additions & 3 deletions charts/posthog/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,17 @@ spec:

- pathType: Prefix
path: "/s/"
backend: *INGESTION
backend: &SESSION_RECORDINGS
service:
name: {{ template "posthog.fullname" . }}-session-recordings
port:
number: {{ .Values.service.externalPort }}
- pathType: Exact
path: "/s"
backend: *INGESTION
backend: *SESSION_RECORDINGS

{{- else }}

- pathType: ImplementationSpecific
path: "/capture/*"
backend: *INGESTION
Expand All @@ -147,7 +152,11 @@ spec:
backend: *INGESTION
- pathType: ImplementationSpecific
path: "/s/*"
backend: *INGESTION
backend:
service:
name: {{ template "posthog.fullname" . }}-session-recordings
port:
number: {{ .Values.service.externalPort }}
{{- end }}
{{- if .Values.ingress.tls }}
{{ toYaml .Values.ingress.tls | indent 4 }}
Expand Down
167 changes: 167 additions & 0 deletions charts/posthog/templates/session-recordings-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
{{- if .Values.sessionRecordings.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "posthog.fullname" . }}-session-recordings
labels: {{- include "_snippet-metadata-labels-common" . | nindent 4 }}
annotations: {{- include "_snippet-metadata-annotations-common" . | nindent 4 }}
spec:
selector:
matchLabels:
app: {{ template "posthog.fullname" . }}
release: "{{ .Release.Name }}"
role: session-recordings
{{- if not .Values.sessionRecordings.hpa.enabled }}
replicas: {{ .Values.sessionRecordings.replicacount }}
{{- end }}
template:
metadata:
annotations:
checksum/secrets.yaml: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }}
{{- if .Values.web.podAnnotations }}
{{ toYaml .Values.web.podAnnotations | indent 8 }}
{{- end }}
labels:
app: {{ template "posthog.fullname" . }}
release: "{{ .Release.Name }}"
role: session-recordings
{{- if (eq (default .Values.image.tag "none") "latest") }}
date: "{{ now | unixEpoch }}"
{{- end }}
{{- if .Values.web.podLabels }}
{{ toYaml .Values.web.podLabels | indent 8 }}
{{- end }}
spec:
terminationGracePeriodSeconds: {{ include "snippet.web-deployments.terminationGracePeriodSeconds" . }}
serviceAccountName: {{ template "posthog.serviceAccountName" . }}

{{- if .Values.web.affinity }}
affinity:
{{ toYaml .Values.web.affinity | indent 8 }}
{{- end }}

{{- if .Values.web.nodeSelector }}
nodeSelector:
{{ toYaml .Values.web.nodeSelector | indent 8 }}
{{- end }}

{{- if .Values.web.tolerations }}
tolerations:
{{ toYaml .Values.web.tolerations | indent 8 }}
{{- end }}

{{- if .Values.web.schedulerName }}
schedulerName: "{{ .Values.web.schedulerName }}"
{{- end }}

{{- if .Values.image.imagePullSecrets }}
imagePullSecrets:
{{ toYaml .Values.image.imagePullSecrets | indent 8 }}
{{- end }}

# I do not know for sure if the old one has been used anywhere, so do both :(
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}

{{- if .Values.sessionRecordings.podSecurityContext.enabled }}
securityContext: {{- omit .Values.sessionRecordings.podSecurityContext "enabled" | toYaml | nindent 8 }}
{{- end }}

containers:
- name: {{ .Chart.Name }}-session-recordings
image: {{ template "posthog.image.fullPath" . }}
command:
- ./bin/docker-server
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.service.internalPort }}
# Expose the port on which Prometheus /metrics endpoint resides
- containerPort: 8001
env:
# Kafka env variables
{{- include "snippet.kafka-env" . | indent 8 }}

# Object Storage env variables
{{- include "snippet.objectstorage-env" . | indent 8 }}

# Redis env variables
{{- include "snippet.redis-env" . | indent 8 }}

# statsd env variables
{{- include "snippet.statsd-env" . | indent 8 }}

- name: DISABLE_SECURE_SSL_REDIRECT
value: '1'
- name: IS_BEHIND_PROXY
value: '1'
{{- if eq .Values.web.secureCookies false }}
- name: SECURE_COOKIES
value: '0'
{{- end }}
# PostHog app settings
{{- include "snippet.posthog-env" . | indent 8 }}
{{- include "snippet.posthog-sentry-env" . | indent 8 }}
- name: PRIMARY_DB
value: clickhouse
{{- include "snippet.postgresql-env" . | nindent 8 }}
{{- include "snippet.clickhouse-env" . | nindent 8 }}
{{- include "snippet.email-env" . | nindent 8 }}
{{- if .Values.env }}
{{ toYaml .Values.env | indent 8 }}
{{- end }}
{{- if .Values.sessionRecordings.env }}
{{ toYaml .Values.sessionRecordings.env | indent 8 }}
{{- else if .Values.web.env }}
{{ toYaml .Values.web.env | indent 8 }}
{{- end }}

{{- include "snippet.web-deployments.lifecycle" . | nindent 8 }}

livenessProbe:
httpGet:
path: /_livez
port: {{ .Values.service.internalPort }}
scheme: HTTP
failureThreshold: {{ .Values.web.livenessProbe.failureThreshold }}
initialDelaySeconds: {{ .Values.web.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.web.livenessProbe.periodSeconds }}
successThreshold: {{ .Values.web.livenessProbe.successThreshold }}
timeoutSeconds: {{ .Values.web.livenessProbe.timeoutSeconds }}
readinessProbe:
httpGet:
# For readiness, we are using the events role as this should be the
# same.
path: /_readyz?role=events
port: {{ .Values.service.internalPort }}
scheme: HTTP
failureThreshold: {{ .Values.web.readinessProbe.failureThreshold }}
initialDelaySeconds: {{ .Values.web.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.web.readinessProbe.periodSeconds }}
successThreshold: {{ .Values.web.readinessProbe.successThreshold }}
timeoutSeconds: {{ .Values.web.readinessProbe.timeoutSeconds }}
startupProbe:
httpGet:
# For startup, we want to make sure that everything is in place,
# including postgres. This does however mean we would not be able to
# deploy new releases when we have a postgres outage
path: /_readyz
port: {{ .Values.service.internalPort }}
scheme: HTTP
failureThreshold: {{ .Values.web.startupProbe.failureThreshold }}
initialDelaySeconds: {{ .Values.web.startupProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.web.startupProbe.periodSeconds }}
successThreshold: {{ .Values.web.startupProbe.successThreshold }}
timeoutSeconds: {{ .Values.web.startupProbe.timeoutSeconds }}
resources:
{{ toYaml .Values.sessionRecordings.resources | indent 12 }}
{{- if .Values.sessionRecordings.securityContext.enabled }}
securityContext: {{- omit .Values.sessionRecordings.securityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
initContainers:
{{- include "_snippet-initContainers-wait-for-service-dependencies" . | indent 8 }}
{{- include "_snippet-initContainers-wait-for-migrations" . | indent 8 }}
{{- end }}
25 changes: 25 additions & 0 deletions charts/posthog/templates/session-recordings-hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- if and .Values.sessionRecordings.enabled .Values.sessionRecordings.hpa.enabled -}}
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "posthog.fullname" . }}-session-recordings
labels: {{- include "_snippet-metadata-labels-common" . | nindent 4 }}
spec:
scaleTargetRef:
kind: Deployment
apiVersion: apps/v1
name: {{ template "posthog.fullname" . }}-session-recordings
minReplicas: {{ .Values.sessionRecordings.hpa.minpods }}
maxReplicas: {{ .Values.sessionRecordings.hpa.maxpods }}
metrics:
{{- with .Values.sessionRecordings.hpa.cputhreshold }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
behavior:
{{ toYaml .Values.sessionRecordings.hpa.behavior | nindent 4 }}
{{- end }}
32 changes: 32 additions & 0 deletions charts/posthog/templates/session-recordings-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if .Values.sessionRecordings.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ template "posthog.fullname" . }}-session-recordings
annotations: {{- include "_snippet-metadata-annotations-common" . | nindent 4 }}
{{- range $key, $value := .Values.service.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
labels: {{- include "_snippet-metadata-labels-common" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.externalPort }}
targetPort: {{ .Values.service.internalPort }}
protocol: TCP
name: {{ .Values.service.name }}
{{- if and (.Values.service.nodePort) (eq .Values.service.type "NodePort") }}
nodePort: {{ .Values.service.nodePort }}
{{- end }}
{{- if .Values.service.externalIPs }}
externalIPs:
{{ toYaml .Values.service.externalIPs | indent 4 }}
{{- end }}
selector:
app: {{ template "posthog.fullname" . }}
role: session-recordings
{{- with .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
4 changes: 2 additions & 2 deletions charts/posthog/tests/__snapshot__/ingress.yaml.snap
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ the "spec" path should match the snapshot when using default values:
pathType: Exact
- backend:
service:
name: RELEASE-NAME-posthog-events
name: RELEASE-NAME-posthog-session-recordings
port:
number: 8000
path: /s/
pathType: Prefix
- backend:
service:
name: RELEASE-NAME-posthog-events
name: RELEASE-NAME-posthog-session-recordings
port:
number: 8000
path: /s
Expand Down
Loading