apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
  labels:
    app.kubernetes.io/name: ${FQDN}-app
    app.kubernetes.io/component: app
  namespace: ${NS}
  name: ${FQDN}-app
spec:
  progressDeadlineSeconds: 600
  replicas: 2
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app.kubernetes.io/name: ${FQDN}-app
      app.kubernetes.io/component: app
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app.kubernetes.io/name: ${FQDN}-app
        app.kubernetes.io/component: app
    spec:
      containers:
      - env:
        - name: ALLOWED_HOSTS
          value: ${ALLOWED_HOSTS}
        - name: HOSTNAME
          value: ${FQDN_DOTS}
        - name: ADMIN_PASS
          valueFrom:
            secretKeyRef:
              key: ADMIN_PASS
              name: ${FQDN}-auth
        - name: DICTIONARIES
          value: fr_FR en_GB en_US
        - name: LOG_LEVEL
          value: warning
        image: tiredofit/libreoffice-online:2.1.6
        imagePullPolicy: Always
        name: collabora
        ports:
        - containerPort: 9980
          name: api
          protocol: TCP
        resources:
          limits:
            memory: 5Gi
        securityContext:
          capabilities:
            add:
            - MKNOD
            - NET_ADMIN
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
---
apiVersion: v1
data:
  ADMIN_PASS: 
kind: Secret
metadata:
  name: ${FQDN}-auth
  namespace: ${NS}
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app.kubernetes.io/name: ${FQDN}
  name: ${FQDN}
  namespace: ${NS}
spec:
  ports:
  - name: api
    port: 9980
    protocol: TCP
    targetPort: api
  selector:
    app.kubernetes.io/name: ${FQDN}-app
  sessionAffinity: None
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/tls-acme: "true"
    nginx.ingress.kubernetes.io/upstream-hash-by: $arg_WOPISrc
  name: ${FQDN}
  namespace: ${NS}
spec:
  rules:
  - host: ${FQDN_DOTS}
    http:
      paths:
      - backend:
          serviceName: ${FQDN}
          servicePort: api
        path: /
  tls:
  - hosts:
    - ${FQDN_DOTS}
    secretName: ${FQDN}-tls
