summaryrefslogtreecommitdiff
path: root/templates/default/kubernetes/flumotion-worker-deploy.yml.j2
blob: f369e2575a626c73f72a6ae0978f4ec045e4476d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: {{ deploy.namespace }}
  name: flumotion-worker-{{ deploy.worker.name }}
  labels:
    app: flumotion
    type: worker
    worker: {{ deploy.worker.name }}
spec:
  replicas: 1
  selector:
    matchLabels:
      app: flumotion
      type: worker
      worker: {{ deploy.worker.name }}
  strategy:
    type: Recreate
  revisionHistoryLimit: 5
  template:
    metadata:
      labels:
        app: flumotion
        type: worker
        worker: {{ deploy.worker.name }}
    spec:
      nodeName: {{ deploy.worker.name }}
      securityContext:
        runAsUser: 998
        fsGroup: 998
      terminationGracePeriodSeconds: 0
%% if 'record' in deploy.worker.flags
      initContainers:
%%   for record_name in deploy.worker.flags.record
      - name: prepare-record-{{ record_name }}
        image: busybox
        command: ['sh', '-c', 'chown 998:998 /srv/record && chmod 0755 /srv/record']
        securityContext:
          runAsUser: 0
        volumeMounts:
        - name: record-{{ record_name }}
          mountPath: /srv/record
%%   endfor
%% endif
      containers:
%% for subname, sub in deploy.worker.subs.items()
      - name: {{ subname }}
        image: spreadspace/flumotion:worker-{{ desc.globals.deployment.parameter.flumotion_image_version }}
        imagePullPolicy: Always
        env:
        - name: WORKER_PASSWORD
          valueFrom:
            secretKeyRef:
              name: flumotion-worker-{{ deploy.worker.name }}
              key: password
        args:
        - --verbose
        - -H {{ desc.globals.manager.host }}
        - -P {{ desc.globals.manager.port }}
        - -T {{ desc.globals.manager.transport }}
        - -n {{ sub.fullname }}
        - -u {{ deploy.worker.name }}
        - -p $(WORKER_PASSWORD)
        - -F {{ 7000 + loop.index0 * 10 }}-{{ 7001 + loop.index0 * 10 }}
        volumeMounts:
        - name: home
          mountPath: /srv
%%   set _needs_ = { 'decklink_libs': False, 'privileged': False }
%%   if 'input' in sub.flags
%%     for input_name in deploy.worker.flags.input
%%       if desc.inputs[input_name].type == 'decklink'
%%         if _needs_.update({'decklink_libs': True, 'privileged': True})
%#             jinja variables are weird... https://stackoverflow.com/questions/9486393
%%         endif
        - name: decklink-device-{{ desc.inputs[input_name].properties.device }}
          mountPath: /dev/blackmagic/dv{{ desc.inputs[input_name].properties.device }}
%%       endif
%%     endfor
%%     if _needs_.decklink_libs
        - name: decklink-libs
          subPath: libDeckLinkAPI.so
          mountPath: /usr/lib/libDeckLinkAPI.so
        - name: decklink-libs
          subPath: libDeckLinkPreviewAPI.so
          mountPath: /usr/lib/libDeckLinkPreviewAPI.so
%%     endif
%%   endif
%%   if 'record' in deploy.worker.flags
%%     for record_name in deploy.worker.flags.record
        - name: record-{{ record_name }}
          mountPath: /srv/recordings/{{ record_name }}
%%     endfor
%%   endif
%%   if _needs_.privileged
        securityContext:
          privileged: true
%%   endif
%% endfor
      volumes:
      - name: home
        emptyDir:
          medium: Memory
%% if 'input' in deploy.worker.flags
%%   set _needs_ = { 'decklink_libs': False }
%%   for input_name in deploy.worker.flags.input
%%     if desc.inputs[input_name].type == 'decklink'
%%       if _needs_.update({'decklink_libs': True})
%#           jinja variables are weird... https://stackoverflow.com/questions/9486393
%%       endif
      - name: decklink-device-{{ desc.inputs[input_name].properties.device }}
        hostPath:
          type: File {# CharDevice doesn't work for some reason... #}
          path: /dev/blackmagic/dv{{ desc.inputs[input_name].properties.device }}
%%     endif
%%   endfor
%%   if _needs_.decklink_libs
      - name: decklink-libs
        hostPath:
          type: Directory
          path: /usr/lib/
          readOnly: true
%%   endif
%% endif
%% if 'record' in deploy.worker.flags
%%   for record_name in deploy.worker.flags.record
      - name: record-{{ record_name }}
        hostPath:
          type: DirectoryOrCreate
          path: {{ desc.records[record_name].directory }}/{{ record_name }}
%%   endfor
%% endif