Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 172 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
name: Release Helm Charts

# Do not change this
concurrency: release-helm

on:
workflow_dispatch:
push:

jobs:
release:
runs-on: ubuntu-latest
outputs:
changed-charts: ${{ steps.get-changed-charts.outputs.changed-charts }}
steps:

- name: Checkout
uses: actions/checkout@v4
with:
path: 'src'
fetch-depth: 0

- name: Checkout
uses: actions/checkout@v4
with:
path: 'dest'
ref: 'gh-pages'
fetch-depth: 0

- name: Install Helm
uses: azure/setup-helm@v1

- name: Set version to -prerelease on non-major branches
if: github.ref != 'refs/heads/main'
shell: bash
run: |
for chart in $(find . -type f -name 'Chart.yaml'); do
yq e '.version |= (. + "-prerelease")' ${chart} > tmp-Chart.yaml
mv tmp-Chart.yaml ${chart}
done

- name: Sync README.md
if: github.ref == 'refs/heads/main'
shell: bash
run: |
cp src/README.md dest/README.md

- name: debug stuff
shell: bash
run: |
find .
jq --version

- name: Package Helm Charts
shell: bash
run: |
find . -type f -name 'Chart.yaml' | sed -r 's|/[^/]+$||' | sort | uniq | xargs -L 1 helm dep up
for d in `find ./src/* -type d -maxdepth 0 -not -name examples` ; do
echo "$d"
helm package "$d" -u -d dest
done

- name: Push New Files
shell: bash
working-directory: dest
run: |
helm repo index . --url https://raw.githubusercontent.com/laerdallabs/livekit-helm/gh-pages/
git config user.name "Helm Updater"
git config user.email "actions@users.noreply.github.com"
git add .
git commit -m "Updated from ref: $GITHUB_SHA"
git push

- name: Identify Updated Charts
id: get-changed-charts
if: github.ref == 'refs/heads/main'
shell: bash
working-directory: src
run: |
changed_charts="$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep "Chart.yaml" | jq -R . | jq -sc .)"
echo "changed-charts=${changed_charts}"
echo "changed-charts=${changed_charts}" >> $GITHUB_OUTPUT

create-releases:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && needs.release.outputs.changed-charts != '[]'
needs: release
strategy:
matrix:
chart: ${{fromJson(needs.release.outputs.changed-charts)}}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Checkout
uses: actions/checkout@v4
with:
path: 'gh-pages'
ref: 'gh-pages'
fetch-depth: 0

- name: Set Release Vars
id: set-vars
run: |
chart_name="$(yq e '.name' ${{ matrix.chart }})"
chart_version="$(yq e '.version' ${{ matrix.chart }})"
chart_description="$(yq e '.description' ${{ matrix.chart }})"
release_tag="${chart_name}-${chart_version}"

echo "chart_name=${chart_name}"
echo "chart_version=${chart_version}"
echo "chart_description=${chart_description}"
echo "release_tag=${release_tag}"

echo "chart_name=${chart_name}" >> $GITHUB_OUTPUT
echo "chart_version=${chart_version}" >> $GITHUB_OUTPUT
echo "chart_description=${chart_description}" >> $GITHUB_OUTPUT
echo "release_tag=${release_tag}" >> $GITHUB_OUTPUT

- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |

# Define the JSON payload
JSON_PAYLOAD=$(jq -n \
--arg tag_name "${{ steps.set-vars.outputs.release_tag }}" \
--arg body "${{ steps.set-vars.outputs.chart_description }}" \
--arg name "${{ steps.set-vars.outputs.release_tag }}" \
'{
tag_name: $tag_name,
name: $name,
body: $body,
draft: false,
prerelease: false
}')

# Make the API request
RESPONSE=$(curl -XPOST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $GITHUB_TOKEN" \
--data "$JSON_PAYLOAD" \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/releases")

# Output the response (optional)
echo "$RESPONSE"

- name: Upload Release Asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ASSET_PATH="gh-pages/${{ steps.set-vars.outputs.release_tag }}.tgz"
ASSET_NAME="$(basename ${ASSET_PATH})"

# Retrieve the ID of the created release
RELEASE_ID="$(
curl -sH "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${{ steps.set-vars.outputs.release_tag }}" \
| jq -r '.id'
)"

# Get the correct upload URL for the asset
UPLOAD_URL="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=$(basename $ASSET_PATH)"

# Upload the asset
curl -XPOST \
--data-binary @"$ASSET_PATH" \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
"$UPLOAD_URL"
7 changes: 6 additions & 1 deletion egress/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@ metadata:
name: {{ include "egress.fullname" . }}
data:
config.yaml: |
{{ toYaml .Values.egress | indent 4 }}
{{- $config := deepCopy .Values.egress }}
{{- if .Values.apiSecretRef }}
{{- $config = unset $config "api_key" }}
{{- $config = unset $config "api_secret" }}
{{- end }}
{{ toYaml $config | indent 4 }}
19 changes: 19 additions & 0 deletions egress/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ spec:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
labels:
{{- include "egress.selectorLabels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "egress.serviceAccountName" . }}
securityContext:
Expand All @@ -37,6 +40,22 @@ spec:
configMapKeyRef:
name: {{ include "egress.fullname" . }}
key: config.yaml
{{- if .Values.apiSecretRef }}
- name: LIVEKIT_API_KEY
valueFrom:
secretKeyRef:
name: {{ .Values.apiSecretRef }}
key: livekit-api-key
- name: LIVEKIT_API_SECRET
valueFrom:
secretKeyRef:
name: {{ .Values.apiSecretRef }}
key: livekit-api-secret
{{- end }}
{{- if .Values.egress.gst_debug }}
- name: GST_DEBUG
value: "{{ .Values.egress.gst_debug }}"
{{- end }}
ports:
{{- if .Values.egress.health_port }}
- name: health
Expand Down
38 changes: 38 additions & 0 deletions egress/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,43 @@ spec:
{{- end }}
{{- end }}
{{- if .Values.autoscaling.custom }}
{{- $customType := default "Pods" .Values.autoscaling.custom.type }}
{{- $describedObject := default (dict) .Values.autoscaling.custom.describedObject }}
{{- if eq $customType "Object" }}
- type: Object
object:
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }}
describedObject:
apiVersion: {{ default "v1" (get $describedObject "apiVersion") }}
kind: {{ default "Namespace" (get $describedObject "kind") }}
name: {{ default .Release.Namespace (get $describedObject "name") }}
metric:
name: {{ .Values.autoscaling.custom.metricName }}
target:
type: Value
value: {{ .Values.autoscaling.custom.targetValue }}
{{- else }}
target:
apiVersion: {{ default "v1" (get $describedObject "apiVersion") }}
kind: {{ default "Namespace" (get $describedObject "kind") }}
name: {{ default .Release.Namespace (get $describedObject "name") }}
metricName: {{ .Values.autoscaling.custom.metricName }}
targetValue: {{ .Values.autoscaling.custom.targetValue }}
{{- end }}
{{- else if eq $customType "External" }}
- type: External
external:
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }}
metric:
name: {{ .Values.autoscaling.custom.metricName }}
target:
type: Value
value: {{ .Values.autoscaling.custom.targetValue }}
{{- else }}
metricName: {{ .Values.autoscaling.custom.metricName }}
targetValue: {{ .Values.autoscaling.custom.targetValue }}
{{- end }}
{{- else }}
- type: Pods
pods:
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }}
Expand All @@ -55,4 +92,5 @@ spec:
targetAverageValue: {{ .Values.autoscaling.custom.targetAverageValue }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
3 changes: 3 additions & 0 deletions livekit-server/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ spec:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
labels:
{{- include "livekit-server.selectorLabels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand Down
5 changes: 5 additions & 0 deletions livekit-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ podAnnotations:
sidecar.istio.io/inject: "false"
linkerd.io/inject: disabled

podLabels:
{}
# environment: production
# tier: frontend

podSecurityContext:
{}
# fsGroup: 2000
Expand Down
Loading