apiVersion: v1
kind: ConfigMap
metadata:
  name: hedgedoc
  namespace: hedgedoc
  labels:
    app.kubernetes.io/name: hedgedoc
    app.kubernetes.io/version: "1.11.0"
    app.kubernetes.io/part-of: hedgedoc
data:
  TZ: Europe/Moscow
  CMD_DB_DIALECT: postgres
  DB_HOST: shared-pg-rw.cnpg.svc.cluster.local
  DB_PORT: "5432"
  DB_USER: hedgedoc
  DB_NAME: hedgedoc
  CMD_DOMAIN: hedgedoc.t0rt1k.tech
  CMD_PROTOCOL_USESSL: "true"
  CMD_URL_ADDPORT: "false"
  CMD_ALLOW_ORIGIN: '["hedgedoc.t0rt1k.tech"]'
  CMD_EMAIL: "false"
  CMD_ALLOW_EMAIL_REGISTER: "false"
  CMD_SESSION_SECRET: szMYcoyJoKavpbzwK6KvLyKYCBbT96FB4sA8ibDpDuo=
  CMD_OAUTH2_CLIENT_ID: "01KW7DDGXPYA3BMZT87QZ8W1H9"
  CMD_OAUTH2_CLIENT_SECRET: "mQ56gsIfvaCXrWdV2oCI"
  CMD_OAUTH2_AUTHORIZATION_URL: "https://auth.t0rt1k.tech/authorize"
  CMD_OAUTH2_TOKEN_URL: "https://auth.t0rt1k.tech/oauth2/token"
  CMD_OAUTH2_USER_PROFILE_URL: "https://auth.t0rt1k.tech/oauth2/userinfo"
  CMD_OAUTH2_SCOPE: "openid email"
  CMD_OAUTH2_PROVIDERNAME: "t0rt1k Matrix"
  CMD_OAUTH2_USER_PROFILE_ID_ATTR: "sub"
  CMD_OAUTH2_USER_PROFILE_USERNAME_ATTR: "sub"
  CMD_OAUTH2_USER_PROFILE_DISPLAY_NAME_ATTR: "email"
  CMD_OAUTH2_USER_PROFILE_EMAIL_ATTR: "email"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: hedgedoc-config
  namespace: hedgedoc
  labels:
    app.kubernetes.io/name: hedgedoc
    app.kubernetes.io/version: "1.11.0"
    app.kubernetes.io/part-of: hedgedoc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
---
apiVersion: v1
kind: Service
metadata:
  name: hedgedoc
  namespace: hedgedoc
  labels:
    app.kubernetes.io/name: hedgedoc
    app.kubernetes.io/version: "1.11.0"
    app.kubernetes.io/part-of: hedgedoc
spec:
  type: ClusterIP
  selector:
    app.kubernetes.io/name: hedgedoc
  ports:
    - port: 3000
      targetPort: http
      protocol: TCP
      name: http
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hedgedoc
  namespace: hedgedoc
  labels:
    app.kubernetes.io/name: hedgedoc
    app.kubernetes.io/version: "1.11.0"
    app.kubernetes.io/part-of: hedgedoc
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
  selector:
    matchLabels:
      app.kubernetes.io/name: hedgedoc
  template:
    metadata:
      labels:
        app.kubernetes.io/name: hedgedoc
        app.kubernetes.io/version: "1.11.0"
        app.kubernetes.io/part-of: hedgedoc
    spec:
      containers:
        - name: hedgedoc
          image: ghcr.io/linuxserver/hedgedoc:1.11.0-ls193
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: hedgedoc
            - secretRef:
                name: hedgedoc
          ports:
            - name: http
              containerPort: 3000
              protocol: TCP
          volumeMounts:
            - mountPath: /config
              name: config
          livenessProbe:
            tcpSocket:
              port: http
            initialDelaySeconds: 30
            failureThreshold: 5
            timeoutSeconds: 10
          readinessProbe:
            tcpSocket:
              port: http
            initialDelaySeconds: 30
            failureThreshold: 5
            timeoutSeconds: 10
          resources:
            requests:
              cpu: 100m
              memory: 256Mi
            limits:
              cpu: 500m
              memory: 512Mi
      volumes:
        - name: config
          persistentVolumeClaim:
            claimName: hedgedoc-config
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: hedgedoc
  namespace: hedgedoc
  labels:
    app.kubernetes.io/name: hedgedoc
    app.kubernetes.io/version: "1.11.0"
    app.kubernetes.io/part-of: hedgedoc
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-production
    traefik.ingress.kubernetes.io/router.entrypoints: websecure
    traefik.ingress.kubernetes.io/router.tls: "true"
spec:
  ingressClassName: traefik
  tls:
    - hosts:
        - hedgedoc.t0rt1k.tech
      secretName: hedgedoc-tls
  rules:
    - host: hedgedoc.t0rt1k.tech
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: hedgedoc
                port:
                  number: 3000
