apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    k8s-app: prosody
  name: prosody
  namespace: jitsi
spec:
  replicas: 1 # one prosody instance per shard
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  selector:
    matchLabels:
      k8s-app: prosody
      shard: "0"
  template:
    metadata:
      labels:
        k8s-app: prosody
        shard: "0"
    spec:
      volumes:
        - name: prosody
          configMap:
            name: prosody
            items:
              - key: mod_prometheus.lua
                path: mod_prometheus.lua
              - key: mod_measure_stanza_counts.lua
                path: mod_measure_stanza_counts.lua
              - key: mod_measure_client_presence.lua
                path: mod_measure_client_presence.lua
              - key: jitsi-meet.cfg.lua
                path: jitsi-meet.cfg.lua
      containers:
        - name: prosody
          image: jitsi/prosody:stable-5870
          imagePullPolicy: Always
          ports:
            - name: metrics
              containerPort: 5280
          readinessProbe:
            # the command that is called obeys standard exit codes
            exec:
              command:
                - prosodyctl
                - --config
                - /config/prosody.cfg.lua
                - status
          volumeMounts:
          # add-ons that allow exporting of metrics to prometheus (mod_prometheus.lua)
          # or enrich the available stats (mod_measure_stanza_counts.lua,
          # mod_measure_client_presence.lua)
          - name: prosody
            mountPath: /prosody-plugins-custom/mod_prometheus.lua
            subPath: mod_prometheus.lua
          - name: prosody
            mountPath: /usr/lib/prosody/modules/mod_measure_stanza_counts.lua
            subPath: mod_measure_stanza_counts.lua
          - name: prosody
            mountPath: /usr/lib/prosody/modules/mod_measure_client_presence.lua
            subPath: mod_measure_client_presence.lua
          # - name: prosody
          #   mountPath: /defaults/conf.d/jitsi-meet.cfg.lua
          #   subPath: jitsi-meet.cfg.lua
          env:
            - name: XMPP_DOMAIN
              value: peopleundercloud.com
            - name: XMPP_AUTH_DOMAIN
              value: auth.peopleundercloud.com
            - name: XMPP_MUC_DOMAIN
              value: muc.peopleundercloud.com
            - name: XMPP_INTERNAL_MUC_DOMAIN
              value: internal-muc.peopleundercloud.com
            - name: JICOFO_COMPONENT_SECRET
              valueFrom:
                secretKeyRef:
                  name: jitsi-config
                  key: JICOFO_COMPONENT_SECRET
            - name: JVB_AUTH_USER
              value: jvb
            - name: JVB_AUTH_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: jitsi-config
                  key: JVB_AUTH_PASSWORD
            - name: JICOFO_AUTH_USER
              value: focus
            - name: JICOFO_AUTH_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: jitsi-config
                  key: JICOFO_AUTH_PASSWORD
            - name: TZ
              value: Asia/Seoul
            - name: JVB_TCP_HARVESTER_DISABLED
              value: "true"
            - name: XMPP_MUC_MODULES
              value: muc_meeting_id,muc_domain_mapper
            # activate add-ons that enrich the available stats of prosody
            - name: GLOBAL_MODULES
              value: prometheus,measure_stanza_counts,measure_client_presence
            # config to allow exporting metrics in prometheus format by prometheus add-on
            - name: GLOBAL_CONFIG
              value: statistics = "internal";\nstatistics_interval = 15;
            # - name: TURNCREDENTIALS_SECRET
            #   valueFrom:
            #     secretKeyRef:
            #       name: jitsi-config
            #       key: TURNCREDENTIALS_SECRET
            # - name: TURN_HOST
            #   valueFrom:
            #     secretKeyRef:
            #       name: jitsi-config
            #       key: TURN_HOST
            # - name: STUN_PORT
            #   valueFrom:
            #     secretKeyRef:
            #       name: jitsi-config
            #       key: STUN_PORT
            # - name: TURN_PORT
            #   valueFrom:
            #     secretKeyRef:
            #       name: jitsi-config
            #       key: TURN_PORT
            # - name: TURNS_PORT
            #   valueFrom:
            #     secretKeyRef:
            #       name: jitsi-config
            #       key: TURNS_PORT
            - name: ENABLE_XMPP_WEBSOCKET
              value: "1"
            - name: PUBLIC_URL
              value: https://peopleundercloud.com
