Skip to content

Commit

Permalink
first init
Browse files Browse the repository at this point in the history
  • Loading branch information
luongngocminh committed Jan 12, 2024
0 parents commit a8564ab
Show file tree
Hide file tree
Showing 17 changed files with 598 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: atm0s-media-stack
description: Atm0s Media Stack Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: 0.1.0
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Atm0s Media Server Stack

Atm0s Media Stack Helm chart for Kubernetes

## Introduction
Atm0s Media Stack installs the following
- Atm0s pods: Gateway, Connector, Webrtc, RTMP, SIP
- Nats pod

## Prerequisites
- **Kubernetes >= 1.23** (You must have a Kubernetes cluster installed and be able to access it with kubectl.)
- **Helm v3** (https://helm.sh/docs/intro/install/)

## Installing the Chart
Add the 8xFF repository to Helm:
```shell script
helm repo add atm0s https://8xff.github.io/helm
helm repo update
helm install atm0s-media-stack 8xff/atm0s-media-stack --set gateway.host={host}.{example.com} --namespace atm0s-media --create-namespace
```

## Uninstalling the Chart
```sh
helm delete atm0s-media-stack -n atm0s-media
```

## Example Usage
```
helm install atm0s-media-stack 8xff/atm0s-media-stack --set gateway.host=gateway.example.com --namespace atm0s-media --create-namespace
```
Binary file added atm0s-media-stack-0.1.0.tgz
Binary file not shown.
14 changes: 14 additions & 0 deletions index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
entries:
atm0s-media-stack:
- apiVersion: v2
appVersion: 0.1.0
created: "2024-01-12T16:27:29.129045+07:00"
description: Atm0s Media Stack Helm chart for Kubernetes
digest: fcf8f2ce27c1078de202b4ce0c442a77b505fd73508c81ef45ae1038d71fe084
name: atm0s-media-stack
type: application
urls:
- https://8xff.github.io/helm/atm0s-media-stack-0.1.0.tgz
version: 0.1.0
generated: "2024-01-12T16:27:29.128157+07:00"
7 changes: 7 additions & 0 deletions package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -x
rm $(pwd)/atm0s-media-stack-*.tgz
sed -i -e "s/^version.*/version: $(cat VERSION)/" -e "s/^appVersion.*/appVersion: $(cat VERSION)/" $(pwd)/Chart.yaml
sed -i "s/tag:.*/tag: $(cat VERSION)/" "$(pwd)"/values.yaml
helm package "$(pwd)"/.
helm repo index --url https://8xff.github.io/helm/ --merge index.yaml .
14 changes: 14 additions & 0 deletions templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Thank you for installing {{ .Chart.Name }}

You will see that currently the stack only contains NATS and a Gateway server.
To continue, you need to run curl into the gateway server to get our initial seed address.

curl http://<YOUR_SERVER_IP>:<YOUR_GATEWAY_HTTP_PORT>/node-info/

This will resulted in a JSON response, which will contain the seed address in the property "address".
Or you can check the log produced by the gateway to get the address.
The address will look something like this: 0@/ip4/192.168.65.3/udp/3001/ip4/192.168.65.3/tcp/3001

This seed address are necessary to initialize the Atm0s stack/cluster.

Now you can update the default values.yaml, enable your favorite server to get up an running.
62 changes: 62 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "atm0s-media-stack.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "atm0s-media-stack.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "atm0s-media-stack.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "atm0s-media-stack.labels" -}}
helm.sh/chart: {{ include "atm0s-media-stack.chart" . }}
{{ include "atm0s-media-stack.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "atm0s-media-stack.selectorLabels" -}}
app.kubernetes.io/name: {{ include "atm0s-media-stack.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "atm0s-media-stack.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "atm0s-media-stack.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
45 changes: 45 additions & 0 deletions templates/atm0s-k8s-connector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{- if .Values.seedAddr }}
{{- if .Values.connector.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: atm0s-media-connector
spec:
replicas: 1
selector:
matchLabels:
app: atm0s-media-connector
template:
metadata:
labels:
app: atm0s-media-connector
spec:
hostNetwork: true
containers:
- name: atm0s-media-connector
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args: ["--http-port={{ .Values.connector.service.httpPort }}", "--sdn-port={{ .Values.connector.service.sdnPort }}", "--node-id={{ .Values.connector.nodeId }}", "--seeds={{ .Values.seedAddr }}", "connector", "--mq-uri={{ .Values.connector.mqUri }}"]
env:
- name: RUST_LOG
value: {{ .Values.connector.logLevel }}

ports:
- name: http
containerPort: {{ .Values.connector.service.httpPort }}
protocol: TCP
- name: sdn
containerPort: {{ .Values.connector.service.sdnPort }}
protocol: TCP
# livenessProbe:
# httpGet:
# path: /node-info/
# port: http
# initialDelaySeconds: 10
# periodSeconds: 5
resources:
requests:
cpu: {{ .Values.connector.cpuRequest }}
memory: {{ .Values.connector.memoryRequest }}
{{- end }}
{{- end }}
55 changes: 55 additions & 0 deletions templates/atm0s-k8s-gateway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

kind: Service
apiVersion: v1
metadata:
name: gateway
spec:
selector:
app: atm0s-media-gateway
ports:
- protocol: TCP
port: 3000
targetPort: http
name: http
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: atm0s-media-gateway
spec:
replicas: 1
selector:
matchLabels:
app: atm0s-media-gateway
template:
metadata:
labels:
app: atm0s-media-gateway
spec:
hostNetwork: true
containers:
- name: atm0s-media-gateway
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args: ["--http-port={{ .Values.gateway.service.httpPort }}", "--sdn-port={{ .Values.gateway.service.sdnPort }}", "--node-id={{ .Values.gateway.nodeId }}", "gateway"]
env:
- name: RUST_LOG
value: {{ .Values.gateway.logLevel }}
ports:
- name: http
containerPort: {{ .Values.gateway.service.httpPort }}
protocol: TCP
- name: sdn
containerPort: {{ .Values.gateway.service.sdnPort }}
protocol: TCP
# livenessProbe:
# httpGet:
# path: /node-info/
# port: http
# initialDelaySeconds: 10
# periodSeconds: 5
resources:
requests:
cpu: {{ .Values.gateway.cpuRequest }}
memory: {{ .Values.gateway.memoryRequest }}

17 changes: 17 additions & 0 deletions templates/atm0s-k8s-ingress-gateway.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: gateway
spec:
ingressClassName: nginx
rules:
- host: {{ .Values.gateway.host }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: gateway
port:
name: http
42 changes: 42 additions & 0 deletions templates/atm0s-k8s-nats.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- if .Values.connector.innerNats.enabled}}
kind: Service
apiVersion: v1
metadata:
name: nats
spec:
selector:
app: nats
ports:
- protocol: TCP
port: 4222
targetPort: 4222
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nats
spec:
replicas: 1
selector:
matchLabels:
app: nats
template:
metadata:
labels:
app: nats
spec:
containers:
- name: nats
image: nats:2.10
ports:
- name: tcp
containerPort: 4222
protocol: TCP
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
{{- end}}
45 changes: 45 additions & 0 deletions templates/atm0s-k8s-rtmp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{- if .Values.seedAddr }}
{{- if .Values.rtmp.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: atm0s-media-rtmp
spec:
replicas: 1
selector:
matchLabels:
app: atm0s-media-rtmp
template:
metadata:
labels:
app: atm0s-media-rtmp
spec:
hostNetwork: true
containers:
- name: atm0s-media-rtmp
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args: ["--http-port={{ .Values.rtmp.service.httpPort }}", "--sdn-port={{ .Values.rtmp.service.sdnPort }}", "--node-id={{ .Values.rtmp.nodeId }}", "--seeds={{ .Values.seedAddr }}", "rtmp"]
env:
- name: RUST_LOG
value: {{ .Values.rtmp.logLevel }}

ports:
- name: http
containerPort: {{ .Values.rtmp.service.httpPort }}
protocol: TCP
- name: sdn
containerPort: {{ .Values.rtmp.service.sdnPort }}
protocol: TCP
# livenessProbe:
# httpGet:
# path: /node-info/
# port: http
# initialDelaySeconds: 10
# periodSeconds: 5
resources:
requests:
cpu: {{ .Values.rtmp.cpuRequest }}
memory: {{ .Values.rtmp.memoryRequest }}
{{- end}}
{{- end}}
Loading

0 comments on commit a8564ab

Please sign in to comment.