castcaster 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aeeeab55c758c6bf640166c74e55d6009d1f989d2cd9c180389eebfcd151cc95
4
- data.tar.gz: ea2cb64b68c93fa92c52410e2670b7a04209c319c49cf30b017755d5e2c19973
3
+ metadata.gz: 6cfc730dee7e05508a526a93c38d64669abbbd9d1289a19c993c65aa5873088f
4
+ data.tar.gz: f33155983bec1ef5da984a049dd003feb00b9dac84354e33c570d27107747899
5
5
  SHA512:
6
- metadata.gz: 926b2539b225dde8414027650ff6a560818b080149592df3ca4ebc1107af806e1159945be0ab619817b8bc09b0b662e517c9a705fd76f406414212b1cfdaaf24
7
- data.tar.gz: b411a61134433e9ea1d7469cf4bbf39133fdb6293db92ea5c41014a97fc5018efd07dcf24343e1aad87a55fc8fbdb8f88ed10a52e4204cce8e6788a303d2811c
6
+ metadata.gz: 10d93fb87a6dd4bb0a26ae759576b1fff0bc766405e0cb73263c726e5ac7161c6babdb678d5f7aa2835bfd2d93b090ccebd331077a6c419e403596cb88a44df9
7
+ data.tar.gz: 447d81f4b40ac9f49cb2b35358c01294dfddfd32036500326487d326bb5a852c5057c8cd72b6afb81c2f0b133fa0d67aca1494ee63b1a15806463189235f1494
@@ -41,7 +41,7 @@ module CastCaster
41
41
 
42
42
  desc 'deploy', 'Generate compose.yml'
43
43
  option :engine, type: :string, aliases: '-e', desc: 'Override engine'
44
- option :mode, type: :string, aliases: '-m', default: 'compose', desc: 'compose | swarm | k8s'
44
+ option :mode, type: :string, aliases: '-m', default: 'compose', desc: 'compose | swarm'
45
45
  option :with_traefik, type: :boolean, desc: 'Include Traefik'
46
46
  def deploy
47
47
  cfg = Config.new.load
@@ -51,8 +51,6 @@ module CastCaster
51
51
  case options[:mode]
52
52
  when 'swarm'
53
53
  dpl = Deploy::Swarm.new(engine, channels, cfg)
54
- when 'k8s'
55
- dpl = Deploy::K8s.new(engine, channels, cfg)
56
54
  else
57
55
  dpl = Deploy::Compose.new(engine, channels)
58
56
  dpl.with_traefik = true if options[:with_traefik]
@@ -2,7 +2,6 @@ require 'erb'
2
2
  require_relative 'deploy/ffmpeg_services'
3
3
  require_relative 'deploy/compose'
4
4
  require_relative 'deploy/swarm'
5
- require_relative 'deploy/k8s'
6
5
  require_relative 'deploy/traefik'
7
6
 
8
7
  module CastCaster
@@ -1,3 +1,3 @@
1
1
  module CastCaster
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -42,8 +42,8 @@ rtmp {
42
42
  drop_idle_publisher 25s;
43
43
  hls on;
44
44
  hls_path <%= hls_dir %>/<%= ch['name'] %>;
45
- hls_fragment <%= ch.dig('hls', 'fragment') || 6 %>;
46
- hls_playlist_length <%= ch.dig('hls', 'playlist_length') || 60 %>;
45
+ hls_fragment <%= ch.dig('hls', 'fragment') || 6 %>s;
46
+ hls_playlist_length <%= ch.dig('hls', 'playlist_length') || 60 %>s;
47
47
  allow publish all;
48
48
  allow play all;
49
49
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: castcaster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lax
@@ -41,7 +41,6 @@ files:
41
41
  - lib/castcaster/deploy.rb
42
42
  - lib/castcaster/deploy/compose.rb
43
43
  - lib/castcaster/deploy/ffmpeg_services.rb
44
- - lib/castcaster/deploy/k8s.rb
45
44
  - lib/castcaster/deploy/swarm.rb
46
45
  - lib/castcaster/deploy/traefik.rb
47
46
  - lib/castcaster/engines.rb
@@ -53,16 +52,6 @@ files:
53
52
  - templates/deploy/docker-compose.yml.tera
54
53
  - templates/deploy/docker-stack.yml.erb
55
54
  - templates/deploy/docker-stack.yml.tera
56
- - templates/deploy/k8s/configmap.yaml.erb
57
- - templates/deploy/k8s/configmap.yaml.tera
58
- - templates/deploy/k8s/deployment.yaml.erb
59
- - templates/deploy/k8s/deployment.yaml.tera
60
- - templates/deploy/k8s/ingress.yaml.erb
61
- - templates/deploy/k8s/ingress.yaml.tera
62
- - templates/deploy/k8s/pvc.yaml.erb
63
- - templates/deploy/k8s/pvc.yaml.tera
64
- - templates/deploy/k8s/service.yaml.erb
65
- - templates/deploy/k8s/service.yaml.tera
66
55
  - templates/nginx-rtmp/nginx.conf.erb
67
56
  homepage: https://liulantao.com/castcaster
68
57
  licenses:
@@ -1,91 +0,0 @@
1
- module CastCaster
2
- module Deploy
3
- class K8s
4
- def initialize(engine, channels, cfg)
5
- @engine = engine
6
- @channels = channels
7
- @cfg = cfg
8
- @traefik = Deploy::Traefik.new(@cfg) if @cfg.fetch('enable_traefik', false)
9
- end
10
-
11
- def write
12
- FileUtils.mkdir_p(deploy_dir)
13
- write_file('deployment.yaml', render_deployment)
14
- write_file('service.yaml', render_service)
15
- write_file('configmap.yaml', render_configmap)
16
- write_file('pvc.yaml', render_pvc)
17
- write_file('ingress.yaml', render_ingress) if @traefik
18
- deploy_dir
19
- end
20
-
21
- def deploy_dir
22
- File.join(@cfg.fetch('project_dir', Dir.pwd), 'k8s')
23
- end
24
-
25
- private
26
-
27
- def write_file(name, content)
28
- path = File.join(deploy_dir, name)
29
- File.write(path, content)
30
- end
31
-
32
- def render_deployment
33
- tpl = File.read(File.expand_path('../../../templates/deploy/k8s/deployment.yaml.erb', __dir__))
34
- erb = ERB.new(tpl, trim_mode: '-')
35
- ctx = TemplateContext.new(
36
- app: 'castcaster',
37
- engine_image: CastCaster::IMAGES['nginx'],
38
- webui_image: CastCaster::IMAGES['webui'],
39
- ffmpeg_image: CastCaster::IMAGES['ffmpeg'],
40
- engine_name: @engine.name,
41
- channels_dir: File.join(@cfg.fetch('project_dir', Dir.pwd), 'channels'),
42
- hls_dir: @cfg.fetch('hls_dir', '/var/lib/castcaster/hls'),
43
- web_port: @cfg.fetch('web_port', 9527),
44
- webui_port: @cfg.fetch('webui_port', 9528)
45
- )
46
- erb.result(ctx.get_binding)
47
- end
48
-
49
- def render_service
50
- tpl = File.read(File.expand_path('../../../templates/deploy/k8s/service.yaml.erb', __dir__))
51
- erb = ERB.new(tpl, trim_mode: '-')
52
- ctx = TemplateContext.new(
53
- app: 'castcaster',
54
- web_port: @cfg.fetch('web_port', 9527),
55
- webui_port: @cfg.fetch('webui_port', 9528)
56
- )
57
- erb.result(ctx.get_binding)
58
- end
59
-
60
- def render_configmap
61
- tpl = File.read(File.expand_path('../../../templates/deploy/k8s/configmap.yaml.erb', __dir__))
62
- erb = ERB.new(tpl, trim_mode: '-')
63
- ctx = TemplateContext.new(
64
- app: 'castcaster',
65
- nginx_conf_path: File.join(@cfg.fetch('project_dir', Dir.pwd), 'nginx', 'nginx.conf'),
66
- channels_dir: File.join(@cfg.fetch('project_dir', Dir.pwd), 'channels')
67
- )
68
- erb.result(ctx.get_binding)
69
- end
70
-
71
- def render_pvc
72
- tpl = File.read(File.expand_path('../../../templates/deploy/k8s/pvc.yaml.erb', __dir__))
73
- erb = ERB.new(tpl, trim_mode: '-')
74
- ctx = TemplateContext.new(app: 'castcaster')
75
- erb.result(ctx.get_binding)
76
- end
77
-
78
- def render_ingress
79
- domain = @cfg.fetch('domain', 'stream.example.com')
80
- tpl = File.read(File.expand_path('../../../templates/deploy/k8s/ingress.yaml.erb', __dir__))
81
- erb = ERB.new(tpl, trim_mode: '-')
82
- ctx = TemplateContext.new(
83
- app: 'castcaster',
84
- domain: domain,
85
- acme_email: @cfg.fetch('acme_email', 'admin@example.com')
86
- )
87
- erb.result(ctx.get_binding)
88
- end
89
- end
90
- end
91
- end
@@ -1,6 +0,0 @@
1
- # Generated by castcaster (Kubernetes)
2
- # Apply nginx config: kubectl create configmap <%= app %>-config --from-file=nginx.conf=<%= nginx_conf_path %>
3
- #
4
- # Apply channel files: kubectl create configmap <%= app %>-channels --from-file=<%= channels_dir %>
5
- #
6
- # Then deploy: kubectl apply -f deployment.yaml
@@ -1,6 +0,0 @@
1
- # Generated by castcaster (Kubernetes)
2
- # Apply nginx config: kubectl create configmap {{ app }}-config --from-file=nginx.conf={{ nginx_conf_path }}
3
- #
4
- # Apply channel files: kubectl create configmap {{ app }}-channels --from-file={{ channels_dir }}
5
- #
6
- # Then deploy: kubectl apply -f deployment.yaml
@@ -1,81 +0,0 @@
1
- # Generated by castcaster (Kubernetes)
2
- apiVersion: apps/v1
3
- kind: Deployment
4
- metadata:
5
- name: <%= app %>-stream
6
- labels:
7
- app: <%= app %>
8
- component: stream
9
- spec:
10
- replicas: 1
11
- selector:
12
- matchLabels:
13
- app: <%= app %>
14
- component: stream
15
- template:
16
- metadata:
17
- labels:
18
- app: <%= app %>
19
- component: stream
20
- spec:
21
- containers:
22
- - name: stream
23
- image: <%= engine_image %>
24
- ports:
25
- - containerPort: 1935
26
- name: rtmp
27
- - containerPort: 8080
28
- name: http
29
- volumeMounts:
30
- - name: config
31
- mountPath: /conf
32
- - name: hls
33
- mountPath: <%= hls_dir %>
34
- volumes:
35
- - name: config
36
- configMap:
37
- name: <%= app %>-config
38
- - name: hls
39
- persistentVolumeClaim:
40
- claimName: <%= app %>-hls
41
- ---
42
- apiVersion: apps/v1
43
- kind: Deployment
44
- metadata:
45
- name: <%= app %>-webui
46
- labels:
47
- app: <%= app %>
48
- component: webui
49
- spec:
50
- replicas: 1
51
- selector:
52
- matchLabels:
53
- app: <%= app %>
54
- component: webui
55
- template:
56
- metadata:
57
- labels:
58
- app: <%= app %>
59
- component: webui
60
- spec:
61
- containers:
62
- - name: webui
63
- image: <%= webui_image %>
64
- ports:
65
- - containerPort: 8081
66
- env:
67
- - name: STREAM_ENGINE
68
- value: "<%= engine_name %>"
69
- - name: STREAM_ENGINE_URL
70
- value: "http://<%= app %>-stream:80"
71
- - name: HLS_DIR
72
- value: "<%= hls_dir || '/var/lib/castcaster/hls' %>"
73
- - name: CHANNELS_DIR
74
- value: "/channels"
75
- volumeMounts:
76
- - name: channels
77
- mountPath: /channels
78
- volumes:
79
- - name: channels
80
- configMap:
81
- name: <%= app %>-channels
@@ -1,81 +0,0 @@
1
- # Generated by castcaster (Kubernetes)
2
- apiVersion: apps/v1
3
- kind: Deployment
4
- metadata:
5
- name: {{ app }}-stream
6
- labels:
7
- app: {{ app }}
8
- component: stream
9
- spec:
10
- replicas: 1
11
- selector:
12
- matchLabels:
13
- app: {{ app }}
14
- component: stream
15
- template:
16
- metadata:
17
- labels:
18
- app: {{ app }}
19
- component: stream
20
- spec:
21
- containers:
22
- - name: stream
23
- image: {{ engine_image }}
24
- ports:
25
- - containerPort: 1935
26
- name: rtmp
27
- - containerPort: 8080
28
- name: http
29
- volumeMounts:
30
- - name: config
31
- mountPath: /conf
32
- - name: hls
33
- mountPath: {{ hls_dir }}
34
- volumes:
35
- - name: config
36
- configMap:
37
- name: {{ app }}-config
38
- - name: hls
39
- persistentVolumeClaim:
40
- claimName: {{ app }}-hls
41
- ---
42
- apiVersion: apps/v1
43
- kind: Deployment
44
- metadata:
45
- name: {{ app }}-webui
46
- labels:
47
- app: {{ app }}
48
- component: webui
49
- spec:
50
- replicas: 1
51
- selector:
52
- matchLabels:
53
- app: {{ app }}
54
- component: webui
55
- template:
56
- metadata:
57
- labels:
58
- app: {{ app }}
59
- component: webui
60
- spec:
61
- containers:
62
- - name: webui
63
- image: {{ webui_image }}
64
- ports:
65
- - containerPort: 8081
66
- env:
67
- - name: STREAM_ENGINE
68
- value: "{{ engine_name }}"
69
- - name: STREAM_ENGINE_URL
70
- value: "http://{{ app }}-stream:80"
71
- - name: HLS_DIR
72
- value: "{{ hls_dir | default(value="/var/lib/castcaster/hls") }}"
73
- - name: CHANNELS_DIR
74
- value: "/channels"
75
- volumeMounts:
76
- - name: channels
77
- mountPath: /channels
78
- volumes:
79
- - name: channels
80
- configMap:
81
- name: {{ app }}-channels
@@ -1,35 +0,0 @@
1
- # Generated by castcaster (Kubernetes + Traefik)
2
- apiVersion: networking.k8s.io/v1
3
- kind: Ingress
4
- metadata:
5
- name: <%= app %>-ingress
6
- annotations:
7
- kubernetes.io/ingress.class: traefik
8
- cert-manager.io/cluster-issuer: letsencrypt-prod
9
- spec:
10
- tls:
11
- - hosts:
12
- - <%= domain %>
13
- - manage.<%= domain %>
14
- secretName: <%= app %>-tls
15
- rules:
16
- - host: <%= domain %>
17
- http:
18
- paths:
19
- - pathType: Prefix
20
- path: "/"
21
- backend:
22
- service:
23
- name: <%= app %>-stream
24
- port:
25
- number: 80
26
- - host: manage.<%= domain %>
27
- http:
28
- paths:
29
- - pathType: Prefix
30
- path: "/"
31
- backend:
32
- service:
33
- name: <%= app %>-webui
34
- port:
35
- number: <%= webui_port %>
@@ -1,35 +0,0 @@
1
- # Generated by castcaster (Kubernetes + Traefik)
2
- apiVersion: networking.k8s.io/v1
3
- kind: Ingress
4
- metadata:
5
- name: {{ app }}-ingress
6
- annotations:
7
- kubernetes.io/ingress.class: traefik
8
- cert-manager.io/cluster-issuer: letsencrypt-prod
9
- spec:
10
- tls:
11
- - hosts:
12
- - {{ domain }}
13
- - manage.{{ domain }}
14
- secretName: {{ app }}-tls
15
- rules:
16
- - host: {{ domain }}
17
- http:
18
- paths:
19
- - pathType: Prefix
20
- path: "/"
21
- backend:
22
- service:
23
- name: {{ app }}-stream
24
- port:
25
- number: 80
26
- - host: manage.{{ domain }}
27
- http:
28
- paths:
29
- - pathType: Prefix
30
- path: "/"
31
- backend:
32
- service:
33
- name: {{ app }}-webui
34
- port:
35
- number: {{ webui_port }}
@@ -1,14 +0,0 @@
1
- # Generated by castcaster (Kubernetes)
2
- apiVersion: v1
3
- kind: PersistentVolumeClaim
4
- metadata:
5
- name: <%= app %>-hls
6
- labels:
7
- app: <%= app %>
8
- component: storage
9
- spec:
10
- accessModes:
11
- - ReadWriteOnce
12
- resources:
13
- requests:
14
- storage: 10Gi
@@ -1,14 +0,0 @@
1
- # Generated by castcaster (Kubernetes)
2
- apiVersion: v1
3
- kind: PersistentVolumeClaim
4
- metadata:
5
- name: {{ app }}-hls
6
- labels:
7
- app: {{ app }}
8
- component: storage
9
- spec:
10
- accessModes:
11
- - ReadWriteOnce
12
- resources:
13
- requests:
14
- storage: 10Gi
@@ -1,37 +0,0 @@
1
- # Generated by castcaster (Kubernetes)
2
- apiVersion: v1
3
- kind: Service
4
- metadata:
5
- name: <%= app %>-stream
6
- labels:
7
- app: <%= app %>
8
- component: stream
9
- spec:
10
- selector:
11
- app: <%= app %>
12
- component: stream
13
- ports:
14
- - port: 1935
15
- targetPort: 1935
16
- name: rtmp
17
- - port: <%= web_port %>
18
- targetPort: 8080
19
- name: http
20
- type: LoadBalancer
21
- ---
22
- apiVersion: v1
23
- kind: Service
24
- metadata:
25
- name: <%= app %>-webui
26
- labels:
27
- app: <%= app %>
28
- component: webui
29
- spec:
30
- selector:
31
- app: <%= app %>
32
- component: webui
33
- ports:
34
- - port: <%= webui_port %>
35
- targetPort: 8080
36
- name: web
37
- type: LoadBalancer
@@ -1,37 +0,0 @@
1
- # Generated by castcaster (Kubernetes)
2
- apiVersion: v1
3
- kind: Service
4
- metadata:
5
- name: {{ app }}-stream
6
- labels:
7
- app: {{ app }}
8
- component: stream
9
- spec:
10
- selector:
11
- app: {{ app }}
12
- component: stream
13
- ports:
14
- - port: 1935
15
- targetPort: 1935
16
- name: rtmp
17
- - port: {{ web_port }}
18
- targetPort: 8080
19
- name: http
20
- type: LoadBalancer
21
- ---
22
- apiVersion: v1
23
- kind: Service
24
- metadata:
25
- name: {{ app }}-webui
26
- labels:
27
- app: {{ app }}
28
- component: webui
29
- spec:
30
- selector:
31
- app: {{ app }}
32
- component: webui
33
- ports:
34
- - port: {{ webui_port }}
35
- targetPort: 8080
36
- name: web
37
- type: LoadBalancer