---
apiVersion: v1
kind: Secret
metadata:
  name: joplin-env
  namespace: joplin
type: Opaque
stringData:
  APP_BASE_URL: "https://note.expertfab.de"
  APP_PORT: "22300"
  DB_CLIENT: "pg"
  POSTGRES_HOST: "joplin-postgres"
  POSTGRES_PORT: "5432"
  POSTGRES_DATABASE: "joplin"
  POSTGRES_USER: "joplin"
  POSTGRES_PASSWORD: "TXIlCX4DUdKZuqbYt2lTaxMXvz6cJi"
  MAILER_ENABLED: "1"
  MAILER_HOST: "smtprelay.expertfab.de"
  MAILER_PORT: "587"
  MAILER_SECURITY: "starttls"
  MAILER_AUTH_USER: "it-admin@expertfab.de"
  MAILER_AUTH_PASSWORD: "Relay22$$"
  MAILER_NOREPLY_NAME: "ExpertFab Joplin"
  MAILER_NOREPLY_EMAIL: "it-admin@expertfab.de"
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: joplin
  namespace: joplin
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  selector:
    matchLabels:
      app: joplin
  template:
    metadata:
      labels:
        app: joplin
    spec:
      containers:
        - name: joplin
          image: joplin/server:latest
          ports:
            - containerPort: 22300
          envFrom:
            - secretRef:
                name: joplin-env
          readinessProbe:
            httpGet:
              path: /api/ping
              port: 22300
              httpHeaders:
                - name: Host
                  value: note.expertfab.de
            initialDelaySeconds: 30
            periodSeconds: 10
            failureThreshold: 6
          livenessProbe:
            httpGet:
              path: /api/ping
              port: 22300
              httpHeaders:
                - name: Host
                  value: note.expertfab.de
            initialDelaySeconds: 90
            periodSeconds: 30
            failureThreshold: 5
          resources:
            requests:
              cpu: 100m
              memory: 512Mi
            limits:
              cpu: 1000m
              memory: 1500Mi
---
apiVersion: v1
kind: Service
metadata:
  name: joplin
  namespace: joplin
spec:
  selector:
    app: joplin
  ports:
    - port: 22300
      targetPort: 22300
