-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial commit * remove testing * more cleanup * Update ingress/Chart.yaml Co-authored-by: David Zhao <[email protected]> * Update ingress/Chart.yaml Co-authored-by: David Zhao <[email protected]> * add kubectl commands for LB ip/ports in notes, update terminationGracePeriod to 3h * make k8s service type configurable Co-authored-by: David Zhao <[email protected]>
- Loading branch information
Showing
12 changed files
with
426 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
set -euxo pipefail | ||
|
||
rm -rf build | ||
mkdir -p build | ||
helm package ingress --destination build | ||
cd build | ||
AWS_REGION=us-east-1 helm s3 push --relative ./ingress*.tgz livekit | ||
|
||
aws cloudfront create-invalidation --distribution-id E2MJ94T12TAUZU --paths "/*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
replicaCount: 1 | ||
|
||
# Suggested value for gracefully terminate the pod: 3 hours | ||
terminationGracePeriodSeconds: 10800 | ||
|
||
ingress: | ||
api_key: "server-api-key" | ||
api_secret: "server-api-secret" | ||
ws_url: "ws://livekit-host:<port>" | ||
log_level: info | ||
health_port: 7888 | ||
prometheus_port: 7889 | ||
http_relay_port: 9090 | ||
rtmp_port: 1935 | ||
|
||
redis: | ||
address: <redis_host:port> | ||
# db: 0 | ||
# username: | ||
# password: | ||
# use_tls: false | ||
|
||
cpu_cost: | ||
rtmp_cpu_cost: 2.0 | ||
# set the Kubernetes serviceType for the ingress service. By default it sets it to "LoadBalancer" | ||
# See kubernetes serviceTypes on official documentation: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types | ||
serviceType: "LoadBalancer" | ||
|
||
# autoscaling requires resources to be defined | ||
autoscaling: | ||
# set to true to enable autoscaling. when set, ignores replicaCount | ||
enabled: false | ||
minReplicas: 1 | ||
maxReplicas: 5 | ||
targetCPUUtilizationPercentage: 60 | ||
# targetMemoryUtilizationPercentage: 60 | ||
# for use with prometheus adapter - the ingress service outputs a prometheus metric called livekit_ingress_available | ||
# this can be used to ensure a certain number or percentage of instances are available | ||
# custom: | ||
# metricName: my_metric_name | ||
# targetAverageValue: 70 | ||
|
||
# if ingress should run only on specific nodes | ||
# this can be used to isolate designated nodes | ||
nodeSelector: {} | ||
# node.kubernetes.io/instance-type: c5.2xlarge | ||
|
||
resources: {} | ||
# requests: | ||
# cpu: 5000m | ||
# memory: 1024Mi | ||
# limits: | ||
# cpu: 8000m | ||
# memory: 2048Mi | ||
|
||
serviceAccount: | ||
# Specifies whether a service account should be created | ||
create: false | ||
# Annotations to add to the service account | ||
annotations: {} | ||
# The name of the service account to use. | ||
# If not set and create is true, a name is generated using the fullname template | ||
name: "" | ||
|
||
podAnnotations: | ||
sidecar.istio.io/inject: "false" | ||
linkerd.io/inject: disabled | ||
|
||
podSecurityContext: {} | ||
# fsGroup: 2000 | ||
|
||
securityContext: {} | ||
# capabilities: | ||
# drop: | ||
# - ALL | ||
# readOnlyRootFilesystem: true | ||
# runAsNonRoot: true | ||
# runAsUser: 1000 | ||
|
||
tolerations: [] | ||
|
||
affinity: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v2 | ||
name: ingress | ||
description: Ingress is used by LiveKit to ingest streams produced by external workflows | ||
type: application | ||
version: 0.0.1 | ||
appVersion: "v0.0.1" | ||
|
||
sources: | ||
- https://github.com/livekit/ingress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
------------------------------------------------------------------------------- | ||
|
||
LiveKit Ingress {{ .Values.image.tag | default .Chart.AppVersion }} has been deployed! | ||
|
||
To get LoadBalancer details: | ||
NOTE: It may take a few minutes for the LoadBalancer IP to be available. | ||
Watch the status with: 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "ingress.fullname" . }}' | ||
|
||
kubectl get svc --namespace {{ .Release.Namespace }} {{ template "ingress.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}' | ||
kubectl get svc --namespace {{ .Release.Namespace }} {{ template "ingress.fullname" . }} -o jsonpath='{.spec.ports}' | ||
|
||
------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "ingress.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 "ingress.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 "ingress.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "ingress.labels" -}} | ||
helm.sh/chart: {{ include "ingress.chart" . }} | ||
{{ include "ingress.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "ingress.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "ingress.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "ingress.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create }} | ||
{{- default (include "ingress.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "ingress.fullname" . }} | ||
data: | ||
config.yaml: | | ||
{{ toYaml .Values.ingress | indent 4 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ include "ingress.fullname" . }} | ||
labels: | ||
{{- include "ingress.labels" . | nindent 4 }} | ||
spec: | ||
{{- if not .Values.autoscaling.enabled }} | ||
replicas: {{ .Values.replicaCount }} | ||
{{- end }} | ||
selector: | ||
matchLabels: | ||
{{- include "ingress.selectorLabels" . | nindent 6 }} | ||
template: | ||
metadata: | ||
{{- with .Values.podAnnotations }} | ||
annotations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} | ||
labels: | ||
{{- include "ingress.selectorLabels" . | nindent 8 }} | ||
spec: | ||
serviceAccountName: {{ include "ingress.serviceAccountName" . }} | ||
securityContext: | ||
{{- toYaml .Values.podSecurityContext | nindent 8 }} | ||
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} | ||
containers: | ||
- name: {{ .Chart.Name }} | ||
securityContext: | ||
{{- toYaml .Values.securityContext | nindent 12 }} | ||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
env: | ||
- name: INGRESS_CONFIG_BODY | ||
valueFrom: | ||
configMapKeyRef: | ||
name: {{ include "ingress.fullname" . }} | ||
key: config.yaml | ||
ports: | ||
{{- if .Values.ingress.health_port }} | ||
- name: health | ||
containerPort: {{ .Values.ingress.health_port }} | ||
protocol: TCP | ||
{{- end }} | ||
{{- if .Values.ingress.http_relay_port }} | ||
- name: http-relay | ||
containerPort: {{ .Values.ingress.http_relay_port }} | ||
protocol: TCP | ||
{{- end }} | ||
{{- if .Values.ingress.rtmp_port }} | ||
- name: rtmp-port | ||
containerPort: {{ .Values.ingress.rtmp_port }} | ||
protocol: TCP | ||
{{- end }} | ||
{{- if .Values.ingress.prometheus_port }} | ||
- name: metrics | ||
containerPort: {{ .Values.ingress.prometheus_port }} | ||
protocol: TCP | ||
{{- end }} | ||
livenessProbe: | ||
httpGet: | ||
path: / | ||
port: health | ||
readinessProbe: | ||
httpGet: | ||
path: / | ||
port: health | ||
resources: | ||
{{- toYaml .Values.resources | nindent 12 }} | ||
{{- with .Values.nodeSelector }} | ||
nodeSelector: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.affinity }} | ||
affinity: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.tolerations }} | ||
tolerations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{{- if .Values.autoscaling.enabled }} | ||
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }} | ||
apiVersion: autoscaling/v2 | ||
{{- else }} | ||
apiVersion: autoscaling/v2beta1 | ||
{{- end }} | ||
kind: HorizontalPodAutoscaler | ||
metadata: | ||
name: {{ include "ingress.fullname" . }} | ||
labels: | ||
{{- include "ingress.labels" . | nindent 4 }} | ||
spec: | ||
scaleTargetRef: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
name: {{ include "ingress.fullname" . }} | ||
minReplicas: {{ .Values.autoscaling.minReplicas }} | ||
maxReplicas: {{ .Values.autoscaling.maxReplicas }} | ||
metrics: | ||
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }} | ||
- type: Resource | ||
resource: | ||
name: cpu | ||
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }} | ||
target: | ||
type: Utilization | ||
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} | ||
{{- else }} | ||
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} | ||
{{- end }} | ||
{{- end }} | ||
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} | ||
- type: Resource | ||
resource: | ||
name: memory | ||
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }} | ||
target: | ||
type: Utilization | ||
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} | ||
{{- else }} | ||
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} | ||
{{- end }} | ||
{{- end }} | ||
{{- if .Values.autoscaling.custom }} | ||
- type: Pods | ||
pods: | ||
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }} | ||
metric: | ||
name: {{ .Values.autoscaling.custom.metricName }} | ||
target: | ||
type: AverageValue | ||
averageValue: {{ .Values.autoscaling.custom.targetAverageValue }} | ||
{{- else }} | ||
metricName: {{ .Values.autoscaling.custom.metricName }} | ||
targetAverageValue: {{ .Values.autoscaling.custom.targetAverageValue }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ include "ingress.fullname" . }} | ||
labels: {{- include "ingress.labels" . | nindent 4 }} | ||
spec: | ||
type: {{ default "LoadBalancer" .Values.ingress.serviceType }} | ||
ports: | ||
- port: {{ .Values.loadBalancer.servicePort }} | ||
protocol: TCP | ||
name: ws | ||
- port: {{ .Values.ingress.rtmp_port }} | ||
protocol: TCP | ||
name: rtmp | ||
selector: | ||
{{- include "ingress.selectorLabels" . | nindent 4 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{- if .Values.serviceAccount.create -}} | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ include "ingress.serviceAccountName" . }} | ||
labels: | ||
{{- include "ingress.labels" . | nindent 4 }} | ||
{{- with .Values.serviceAccount.annotations }} | ||
annotations: | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- end }} |
Oops, something went wrong.