plausible/kubernetes/plausible.yaml

150 lines
4.7 KiB
YAML

apiVersion: v1
kind: Service
metadata:
name: plausible
labels:
app.kubernetes.io/name: plausible
app.kubernetes.io/component: server
spec:
type: LoadBalancer
ports:
- name: http
port: 8000
targetPort: 8000
protocol: TCP
selector:
app.kubernetes.io/name: plausible
app.kubernetes.io/component: server
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: plausible
labels:
app.kubernetes.io/name: plausible
app.kubernetes.io/component: server
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: plausible
app.kubernetes.io/component: server
template:
metadata:
labels:
app.kubernetes.io/name: plausible
app.kubernetes.io/component: server
spec:
restartPolicy: Always
# see https://github.com/plausible/analytics/blob/master/Dockerfile
securityContext:
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
initContainers:
- name: plausible-init
image: plausible/analytics:latest
command:
- "/bin/sh"
- "-c"
args:
- sleep 30 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh db init-admin
envFrom:
- configMapRef:
name: plausible-config
env:
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: plausible-db-user
key: username
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: plausible-db-user
key: password
- name: CLICKHOUSE_USER
valueFrom:
secretKeyRef:
name: plausible-events-db-user
key: username
- name: CLICKHOUSE_PASSWORD
valueFrom:
secretKeyRef:
name: plausible-events-db-user
key: password
- name: DATABASE_URL
value: postgres://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@$(PLAUSIBLE_DB_SERVICE_HOST):$(PLAUSIBLE_DB_SERVICE_PORT)/plausible
- name: CLICKHOUSE_DATABASE_URL
value: http://$(CLICKHOUSE_USER):$(CLICKHOUSE_PASSWORD)@$(PLAUSIBLE_EVENTS_DB_SERVICE_HOST):$(PLAUSIBLE_EVENTS_DB_SERVICE_PORT)/plausible
- name: SMTP_HOST_ADDR
value: $(PLAUSIBLE_SMTP_SERVICE_HOST)
securityContext:
allowPrivilegeEscalation: false
resources:
limits:
memory: 2Gi
cpu: 1500m
requests:
memory: 50Mi
cpu: 10m
containers:
- name: plausible
image: plausible/analytics:latest
imagePullPolicy: Always
ports:
- containerPort: 8000
envFrom:
- configMapRef:
name: plausible-config
env:
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: plausible-db-user
key: username
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: plausible-db-user
key: password
- name: CLICKHOUSE_USER
valueFrom:
secretKeyRef:
name: plausible-events-db-user
key: username
- name: CLICKHOUSE_PASSWORD
valueFrom:
secretKeyRef:
name: plausible-events-db-user
key: password
- name: DATABASE_URL
value: postgres://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@$(PLAUSIBLE_DB_SERVICE_HOST):$(PLAUSIBLE_DB_SERVICE_PORT)/plausible
- name: CLICKHOUSE_DATABASE_URL
value: http://$(CLICKHOUSE_USER):$(CLICKHOUSE_PASSWORD)@$(PLAUSIBLE_EVENTS_DB_SERVICE_HOST):$(PLAUSIBLE_EVENTS_DB_SERVICE_PORT)/plausible
- name: SMTP_HOST_ADDR
value: $(PLAUSIBLE_SMTP_SERVICE_HOST)
securityContext:
allowPrivilegeEscalation: false
resources:
limits:
memory: 2Gi
cpu: 1500m
requests:
memory: 140Mi
cpu: 10m
readinessProbe:
httpGet:
path: /api/health
port: 8000
initialDelaySeconds: 35
failureThreshold: 6
periodSeconds: 10
livenessProbe:
httpGet:
path: /api/health
port: 8000
initialDelaySeconds: 45
failureThreshold: 3
periodSeconds: 10