Skip to content

Commit b8be010

Browse files
committed
🚚(helm) add posthog proxy
To contourn ads blocker, we add a proxy to the posthog service. This way, we can access the service from the same domain as the frontend.
1 parent 97cfa2c commit b8be010

11 files changed

Lines changed: 328 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ and this project adheres to
1212
## Added
1313

1414
- github actions to managed Crowdin workflow
15+
- 📈Integrate Posthog #540
16+
1517

1618
## Changed
1719

docs/examples/impress.values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ backend:
4040
LOGIN_REDIRECT_URL: https://impress.127.0.0.1.nip.io
4141
LOGIN_REDIRECT_URL_FAILURE: https://impress.127.0.0.1.nip.io
4242
LOGOUT_REDIRECT_URL: https://impress.127.0.0.1.nip.io
43+
POSTHOG_KEY: "{'id': 'posthog_key', 'host': 'https://product.impress.127.0.0.1.nip.io'}"
4344
DB_HOST: postgresql
4445
DB_NAME: impress
4546
DB_USER: dinum
@@ -121,6 +122,12 @@ yProvider:
121122
COLLABORATION_SERVER_SECRET: my-secret
122123
Y_PROVIDER_API_KEY: my-secret
123124

125+
posthog:
126+
ingress:
127+
enabled: false
128+
ingressAssets:
129+
enabled: false
130+
124131
ingress:
125132
enabled: true
126133
host: impress.127.0.0.1.nip.io

src/helm/env.d/dev/values.impress.yaml.gotmpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ ingressAdmin:
148148
enabled: true
149149
host: impress.127.0.0.1.nip.io
150150

151+
posthog:
152+
ingress:
153+
enabled: false
154+
155+
ingressAssets:
156+
enabled: false
157+
151158
ingressMedia:
152159
enabled: true
153160
host: impress.127.0.0.1.nip.io

src/helm/impress/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apiVersion: v2
22
type: application
33
name: docs
4-
version: 0.0.2
4+
version: 2.0.1-beta.7
55
appVersion: latest

src/helm/impress/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,37 @@
176176
| `frontend.extraVolumeMounts` | Additional volumes to mount on the frontend. | `[]` |
177177
| `frontend.extraVolumes` | Additional volumes to mount on the frontend. | `[]` |
178178

179+
### posthog
180+
181+
| Name | Description | Value |
182+
| -------------------------------------- | ----------------------------------------------------------- | ------------------------- |
183+
| `posthog.ingress.enabled` | Enable or disable the ingress resource creation | `false` |
184+
| `posthog.ingress.className` | Kubernetes ingress class name to use (e.g., nginx, traefik) | `nil` |
185+
| `posthog.ingress.host` | Primary hostname for the ingress resource | `impress.example.com` |
186+
| `posthog.ingress.path` | URL path prefix for the ingress routes (e.g., /) | `/` |
187+
| `posthog.ingress.hosts` | Additional hostnames array to be included in the ingress | `[]` |
188+
| `posthog.ingress.tls.enabled` | Enable or disable TLS/HTTPS for the ingress | `true` |
189+
| `posthog.ingress.tls.additional` | Additional TLS configurations for extra hosts/certificates | `[]` |
190+
| `posthog.ingress.customBackends` | Custom backend service configurations for the ingress | `[]` |
191+
| `posthog.ingress.annotations` | Additional Kubernetes annotations to apply to the ingress | `{}` |
192+
| `posthog.ingressAssets.enabled` | Enable or disable the ingress resource creation | `false` |
193+
| `posthog.ingressAssets.className` | Kubernetes ingress class name to use (e.g., nginx, traefik) | `nil` |
194+
| `posthog.ingressAssets.host` | Primary hostname for the ingress resource | `impress.example.com` |
195+
| `posthog.ingressAssets.paths` | URL paths prefix for the ingress routes (e.g., /static) | `["/static","/array"]` |
196+
| `posthog.ingressAssets.hosts` | Additional hostnames array to be included in the ingress | `[]` |
197+
| `posthog.ingressAssets.tls.enabled` | Enable or disable TLS/HTTPS for the ingress | `true` |
198+
| `posthog.ingressAssets.tls.additional` | Additional TLS configurations for extra hosts/certificates | `[]` |
199+
| `posthog.ingressAssets.customBackends` | Custom backend service configurations for the ingress | `[]` |
200+
| `posthog.ingressAssets.annotations` | Additional Kubernetes annotations to apply to the ingress | `{}` |
201+
| `posthog.service.type` | Service type (e.g. ExternalName, ClusterIP, LoadBalancer) | `ExternalName` |
202+
| `posthog.service.externalName` | External service hostname when type is ExternalName | `eu.i.posthog.com` |
203+
| `posthog.service.port` | Port number for the service | `443` |
204+
| `posthog.service.annotations` | Additional annotations to apply to the service | `{}` |
205+
| `posthog.assetsService.type` | Service type (e.g. ExternalName, ClusterIP, LoadBalancer) | `ExternalName` |
206+
| `posthog.assetsService.externalName` | External service hostname when type is ExternalName | `eu-assets.i.posthog.com` |
207+
| `posthog.assetsService.port` | Port number for the service | `443` |
208+
| `posthog.assetsService.annotations` | Additional annotations to apply to the service | `{}` |
209+
179210
### yProvider
180211

181212
| Name | Description | Value |

src/helm/impress/templates/_helpers.tpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@ Requires top level scope
148148
{{ include "impress.fullname" . }}-frontend
149149
{{- end }}
150150

151+
{{/*
152+
Full name for the Posthog
153+
154+
Requires top level scope
155+
*/}}
156+
{{- define "impress.posthog.fullname" -}}
157+
{{ include "impress.fullname" . }}-posthog
158+
{{- end }}
159+
151160
{{/*
152161
Full name for the yProvider
153162
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{{- if .Values.posthog.ingress.enabled -}}
2+
{{- $fullName := include "impress.fullname" . -}}
3+
{{- if and .Values.posthog.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
4+
{{- if not (hasKey .Values.posthog.ingress.annotations "kubernetes.io/ingress.class") }}
5+
{{- $_ := set .Values.posthog.ingress.annotations "kubernetes.io/ingress.class" .Values.posthog.ingress.className}}
6+
{{- end }}
7+
{{- end }}
8+
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
9+
apiVersion: networking.k8s.io/v1
10+
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
11+
apiVersion: networking.k8s.io/v1beta1
12+
{{- else -}}
13+
apiVersion: extensions/v1beta1
14+
{{- end }}
15+
kind: Ingress
16+
metadata:
17+
name: {{ $fullName }}-posthog
18+
namespace: {{ .Release.Namespace | quote }}
19+
labels:
20+
{{- include "impress.labels" . | nindent 4 }}
21+
{{- with .Values.posthog.ingress.annotations }}
22+
annotations:
23+
{{- toYaml . | nindent 4 }}
24+
{{- end }}
25+
spec:
26+
{{- if and .Values.posthog.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
27+
ingressClassName: {{ .Values.posthog.ingress.className }}
28+
{{- end }}
29+
{{- if .Values.posthog.ingress.tls.enabled }}
30+
tls:
31+
{{- if .Values.posthog.ingress.host }}
32+
- secretName: {{ $fullName }}-posthog-tls
33+
hosts:
34+
- {{ .Values.posthog.ingress.host | quote }}
35+
{{- end }}
36+
{{- range .Values.posthog.ingress.tls.additional }}
37+
- hosts:
38+
{{- range .hosts }}
39+
- {{ . | quote }}
40+
{{- end }}
41+
secretName: {{ .secretName }}
42+
{{- end }}
43+
{{- end }}
44+
rules:
45+
{{- if .Values.posthog.ingress.host }}
46+
- host: {{ .Values.posthog.ingress.host | quote }}
47+
http:
48+
paths:
49+
- path: {{ .Values.posthog.ingress.path }}
50+
{{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }}
51+
pathType: Prefix
52+
{{- end }}
53+
backend:
54+
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
55+
service:
56+
name: {{ include "impress.posthog.fullname" . }}-proxy
57+
port:
58+
number: {{ .Values.posthog.service.port }}
59+
{{- else }}
60+
serviceName: {{ include "impress.posthog.fullname" . }}-proxy
61+
servicePort: {{ .Values.posthog.service.port }}
62+
{{- end }}
63+
{{- end }}
64+
{{- range .Values.posthog.ingress.hosts }}
65+
- host: {{ . | quote }}
66+
http:
67+
paths:
68+
- path: {{ $.Values.posthog.ingress.path | quote }}
69+
{{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }}
70+
pathType: Prefix
71+
{{- end }}
72+
backend:
73+
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
74+
service:
75+
name: {{ include "impress.posthog.fullname" . }}-proxy
76+
port:
77+
number: {{ $.Values.posthog.service.port }}
78+
{{- else }}
79+
serviceName: {{ include "impress.posthog.fullname" . }}-proxy
80+
servicePort: {{ $.Values.posthog.service.port }}
81+
{{- end }}
82+
{{- with $.Values.posthog.service.customBackends }}
83+
{{- toYaml . | nindent 10 }}
84+
{{- end }}
85+
{{- end }}
86+
{{- end }}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{{- if .Values.posthog.ingressAssets.enabled -}}
2+
{{- $fullName := include "impress.fullname" . -}}
3+
{{- if and .Values.posthog.ingressAssets.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
4+
{{- if not (hasKey .Values.posthog.ingressAssets.annotations "kubernetes.io/ingress.class") }}
5+
{{- $_ := set .Values.posthog.ingressAssets.annotations "kubernetes.io/ingress.class" .Values.posthog.ingressAssets.className}}
6+
{{- end }}
7+
{{- end }}
8+
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
9+
apiVersion: networking.k8s.io/v1
10+
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
11+
apiVersion: networking.k8s.io/v1beta1
12+
{{- else -}}
13+
apiVersion: extensions/v1beta1
14+
{{- end }}
15+
kind: Ingress
16+
metadata:
17+
name: {{ $fullName }}-posthog-assets
18+
namespace: {{ .Release.Namespace | quote }}
19+
labels:
20+
{{- include "impress.labels" . | nindent 4 }}
21+
{{- with .Values.posthog.ingressAssets.annotations }}
22+
annotations:
23+
{{- toYaml . | nindent 4 }}
24+
{{- end }}
25+
spec:
26+
{{- if and .Values.posthog.ingressAssets.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
27+
ingressClassName: {{ .Values.posthog.ingressAssets.className }}
28+
{{- end }}
29+
{{- if .Values.posthog.ingressAssets.tls.enabled }}
30+
tls:
31+
{{- if .Values.posthog.ingressAssets.host }}
32+
- secretName: {{ $fullName }}-posthog-tls
33+
hosts:
34+
- {{ .Values.posthog.ingressAssets.host | quote }}
35+
{{- end }}
36+
{{- range .Values.posthog.ingressAssets.tls.additional }}
37+
- hosts:
38+
{{- range .hosts }}
39+
- {{ . | quote }}
40+
{{- end }}
41+
secretName: {{ .secretName }}
42+
{{- end }}
43+
{{- end }}
44+
rules:
45+
{{- if .Values.posthog.ingressAssets.host }}
46+
- host: {{ .Values.posthog.ingressAssets.host | quote }}
47+
http:
48+
paths:
49+
{{- range .Values.posthog.ingressAssets.paths }}
50+
- path: {{ . | quote }}
51+
{{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }}
52+
pathType: Prefix
53+
{{- end }}
54+
backend:
55+
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
56+
service:
57+
name: {{ include "impress.posthog.fullname" $ }}-assets-proxy
58+
port:
59+
number: {{ $.Values.posthog.assetsService.port }}
60+
{{- else }}
61+
serviceName: {{ include "impress.posthog.fullname" $ }}-assets-proxy
62+
servicePort: {{ $.Values.posthog.assetsService.port }}
63+
{{- end }}
64+
{{- end }}
65+
{{- end }}
66+
{{- end }}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{- if .Values.posthog.ingressAssets.enabled -}}
2+
{{- $envVars := include "impress.common.env" (list . .Values.posthog) -}}
3+
{{- $fullName := include "impress.posthog.fullname" . -}}
4+
{{- $component := "posthog" -}}
5+
apiVersion: v1
6+
kind: Service
7+
metadata:
8+
name: {{ $fullName }}-assets-proxy
9+
namespace: {{ .Release.Namespace | quote }}
10+
labels:
11+
{{- include "impress.common.labels" (list . $component) | nindent 4 }}
12+
annotations:
13+
{{- toYaml $.Values.posthog.assetsService.annotations | nindent 4 }}
14+
spec:
15+
type: {{ .Values.posthog.assetsService.type }}
16+
externalName: {{ .Values.posthog.assetsService.externalName }}
17+
ports:
18+
- port: {{ .Values.posthog.assetsService.port }}
19+
targetPort: {{ .Values.posthog.assetsService.targetPort }}
20+
protocol: TCP
21+
name: https
22+
selector:
23+
{{- include "impress.common.selectorLabels" (list . $component) | nindent 4 }}
24+
{{- end }}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{- if .Values.posthog.ingress.enabled -}}
2+
{{- $envVars := include "impress.common.env" (list . .Values.posthog) -}}
3+
{{- $fullName := include "impress.posthog.fullname" . -}}
4+
{{- $component := "posthog" -}}
5+
apiVersion: v1
6+
kind: Service
7+
metadata:
8+
name: {{ $fullName }}-proxy
9+
namespace: {{ .Release.Namespace | quote }}
10+
labels:
11+
{{- include "impress.common.labels" (list . $component) | nindent 4 }}
12+
annotations:
13+
{{- toYaml $.Values.posthog.service.annotations | nindent 4 }}
14+
spec:
15+
type: {{ .Values.posthog.service.type }}
16+
externalName: {{ .Values.posthog.service.externalName }}
17+
ports:
18+
- port: {{ .Values.posthog.service.port }}
19+
targetPort: {{ .Values.posthog.service.targetPort }}
20+
protocol: TCP
21+
name: https
22+
selector:
23+
{{- include "impress.common.selectorLabels" (list . $component) | nindent 4 }}
24+
{{- end }}

0 commit comments

Comments
 (0)