---
# Source: outside-deploy/charts/srs-cluster/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: helm-srs-cm
  namespace: xtgt
  labels:
    cmii.app: video-live-srs
    cmii.type: middleware
    helm.sh/chart: srs-cluster-2.1.0
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/version: "2.0.0"
data:
  srs.rtc.conf: |-
    listen              30935;
    max_connections     4096;
    srs_log_tank        console;
    srs_log_file        /home/srs.log;
    daemon              off;
    http_api {
        enabled         on;
        listen          30985;
        crossdomain     on;
    }
    stats {
        network         0;
    }
    http_server {
        enabled         on;
        listen          30080;
        dir             /home/hls;
    }
    rtc_server {
        enabled         on;
        listen          30090;
        candidate       $CANDIDATE;
    }
    vhost __defaultVhost__ {
        http_hooks {
            enabled       on;
            on_publish    http://helm-srs-op-svc:8080/hooks/on_publish;
        }
        http_remux {
            enabled     on;
        }
        rtc {
            enabled     on;
            rtmp_to_rtc on;
            rtc_to_rtmp on;
            keep_bframe off;
        }
        tcp_nodelay     on;
        min_latency     on;
        play {
            gop_cache       off;
            mw_latency      0;
            mw_msgs         0;
        }
        publish {
            firstpkt_timeout    4000;
            normal_timeout      2000;
            mr off;
        }
        dvr {
            enabled         off;
            dvr_path        /home/dvr/[app]/[stream]/[2006][01]/[timestamp].mp4;
            dvr_plan        session;
        }
        hls {
            enabled         on;
            hls_path        /home/hls;
            hls_fragment    10;
            hls_window      60;
            hls_m3u8_file   [app]/[stream].m3u8;
            hls_ts_file     [app]/[stream]/[2006][01][02]/[timestamp]-[duration].ts;
            hls_cleanup     on;
        }
    }

  srs.op.conf: |-
    debug: false
    server:
      port: 8080

    spring:
      application:
        name: cmii-srs-operator
      platform:
        info:
          name: cmii-live-srs-operator
          description: cmii-live-srs-operator
          version: 1.2.0
          scanPackage: com.cmii.live
      datasource:
        type: com.alibaba.druid.pool.DruidDataSource
        url: jdbc:mysql://helm-mysql:3306/cmii_live_srs_op?characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
        username: k8s_admin
        password: fP#UaH6qQ3)8
        driver-class-name: com.mysql.cj.jdbc.Driver
      boot:
        admin:
          client:
            enabled: false
            url: http://127.0.0.1:8888
            instance:
              service-url: http://127.0.0.1:8080

    druid:
      mysql:
        usePingMethod: false

    management:
      endpoints:
        enabled-by-default: true
        web:
          exposure:
            include: '*'
      endpoint:
        health:
          show-details: always

    live:
      srs:
        rtmp-base: "rtmp://172.32.12.34:30935"
        rtsp-base: "rtsp://172.32.12.34:30554"
        srt-base: "srt://172.32.12.34:23333"
        flv-base: "http://172.32.12.34:30500"
        rtc-base: "webrtc://172.32.12.34:30500"
        api-base: "http://helm-srs-rtc-svc:30985"
      hls:
        max-ts: 200
        interval-ms: 6000
      minio:
        endpoint: http://172.32.12.38:9000
        access-key: cmii
        secret-key: B#923fC7mk
        bucket: srs-hls
      sync:
        onStart: false
        pool:
          core: 8
          max: 12
          queue: 0
          keepalive: 20
        interval:
          sync: 150
          elect: 8
          keepalive: 20
          heartbeat: 8

    logging:
      level:
        com.cmii.live.srs.mapper: info
---
# Source: outside-deploy/charts/srs-cluster/templates/service.yaml
---

apiVersion: v1
kind: Service
metadata:
  name: srs-rtc
  namespace: xtgt
spec:
  type: ClusterIP
  clusterIP: None
  selector:
    srs-role: webrtc
  ports:
    - name: srsrtc-rtmp
      port: 30935
      targetPort: 30935
    - name: srsrtc-hls
      port: 30080
      targetPort: 30080
---
# Source: outside-deploy/charts/srs-cluster/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: helm-srs-rtc-svc
  namespace: xtgt
spec:
  type: NodePort
  selector:
    srs-role: webrtc
  ports:
    - name: srs-rtmp
      port: 30935
      targetPort: 30935
      nodePort: 30935
    - name: srs-api
      port: 30985
      targetPort: 30985
      nodePort: 30985
    - name: srs-rtc
      port: 30090
      targetPort: 30090
      nodePort: 30090
      protocol: UDP
    - name: srs-flv
      port: 30080
      targetPort: 30080
      nodePort: 30080
---
# Source: outside-deploy/charts/srs-cluster/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: helm-srs-op-svc
  namespace: xtgt
spec:
  type: ClusterIP
  selector:
    srs-role: op
  ports:
    - port: 8080
      targetPort: 8080
---
# Source: outside-deploy/charts/srs-cluster/templates/operator-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: helm-srs-op
  namespace: xtgt
  labels:
    srs-role: op
    cmii.app: video-live-srs
    cmii.type: middleware
    helm.sh/chart: srs-cluster-2.1.0
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/version: "2.0.0"
spec:
  replicas: 1
  selector:
    matchLabels:
      srs-role: op
  template:
    metadata:
      labels:
        srs-role: op
        cmii.app: video-live-srs
        cmii.type: middleware
        helm.sh/chart: srs-cluster-2.1.0
        app.kubernetes.io/managed-by: Helm
        app.kubernetes.io/version: "2.0.0"
    spec:
      imagePullSecrets:
        - name: harborsecret
      affinity:
        {}
      containers:
        - name: operator
          image: "172.32.12.34:8033/cmii/cmii-srs-operator:v1.0.0"
          imagePullPolicy: Always
          resources:
            limits:
              memory: 4Gi
              cpu: 4800m
            requests:
              memory: 256Mi
              cpu: 100m
          ports:
            - name: operator
              containerPort: 8080
              protocol: TCP
          volumeMounts:
            - name: srs-conf-file
              mountPath: /cmii/application.yaml
              subPath: application.yaml
      volumes:
        - name: srs-conf-file
          configMap:
            name: "helm-srs-cm"
            items:
              - key: "srs.op.conf"
                path: "application.yaml"
---
# Source: outside-deploy/charts/srs-cluster/templates/webrtc-statefulset.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: helm-srs-rtc
  namespace: xtgt
  labels:
    srs-role: webrtc
    cmii.app: video-live-srs
    cmii.type: middleware
    helm.sh/chart: srs-cluster-2.1.0
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/version: "2.0.0"
spec:
  serviceName: srsrtc
  replicas: 1
  selector:
    matchLabels:
      srs-role: webrtc
  template:
    metadata:
      labels:
        srs-role: webrtc
        cmii.app: video-live-srs
        cmii.type: middleware
        helm.sh/chart: srs-cluster-2.1.0
        app.kubernetes.io/managed-by: Helm
        app.kubernetes.io/version: "2.0.0"
    spec:
      imagePullSecrets:
        - name: harborsecret
      affinity:
      containers:
        - name: helm-srs
          image: "172.32.12.34:8033/cmii/ossrs/srs:v4.0-b9"
          resources:
            limits:
              memory: 4Gi
              cpu: 1200m
            requests:
              memory: 256Mi
              cpu: 100m
          ports:
            - name: srs-rtmp
              containerPort: 30935
              protocol: TCP
            - name: srs-api
              containerPort: 30985
              protocol: TCP
            - name: srs-flv
              containerPort: 30080
              protocol: TCP
            - name: srs-webrtc
              containerPort: 30090
              protocol: UDP
          env:
            - name: CANDIDATE
              value: "172.32.12.34"
          volumeMounts:
            - name: srs-conf-file
              mountPath: /usr/local/srs/conf/docker.conf
              subPath: docker.conf
            - name: srs-vol
              mountPath: /home/dvr
              subPath: "default/helm-srs/dvr"
            - name: srs-vol
              mountPath: /home/hls
              subPath: "default/helm-srs/hls"
        - name: oss-adaptor
          image: "172.32.12.34:8033/cmii/cmii-srs-oss-adaptor:v1.0.0-no-retention"
          imagePullPolicy: Always
          resources:
            limits:
              memory: 4Gi
              cpu: 1200m
            requests:
              memory: 256Mi
              cpu: 100m
          env:
            - name: OSS_ENDPOINT
              value: http://172.32.12.38:9000
            - name: OSS_AK
              value: ossuser
            - name: OSS_SK
              value: B#923fC7mk
            - name: OSS_BUCKET
              value: srs-hls
            - name: SRS_OP
              value: "http://helm-srs-op-svc:8080"
            - name: MYSQL_ENDPOINT
              value: helm-mysql:3306
            - name: MYSQL_USERNAME
              value: k8s_admin
            - name: MYSQL_PASSWORD
              value: fP#UaH6qQ3)8
          volumeMounts:
            - name: srs-vol
              mountPath: /cmii/share/hls
              subPath: default/helm-srs/hls
      volumes:
        - name: srs-conf-file
          configMap:
            name: "helm-srs-cm"
            items:
              - key: "srs.rtc.conf"
                path: "docker.conf"
        - name: srs-vol
          emptyDir:
            sizeLimit: 10Gi

