commit 35c0bcec3f6f8d11d96f014b721940bffacc2a64 Author: MTRNord <mtrnord1@gmail.com> Date: Fri, 1 Mar 2024 15:47:50 +0100 Initial commit Diffstat:
| A | .gitignore | | | 6 | ++++++ |
| A | .helmignore | | | 23 | +++++++++++++++++++++++ |
| A | Chart.lock | | | 6 | ++++++ |
| A | Chart.yaml | | | 13 | +++++++++++++ |
| A | templates/NOTES.txt | | | 22 | ++++++++++++++++++++++ |
| A | templates/_helpers.tpl | | | 78 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | templates/deployment.yaml | | | 109 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | templates/deployment_livekit_mgmt_service.yaml | | | 82 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | templates/ingress.yaml | | | 60 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | templates/service.yaml | | | 32 | ++++++++++++++++++++++++++++++++ |
| A | templates/tests/test-connection.yaml | | | 15 | +++++++++++++++ |
| A | values.yaml | | | 162 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
12 files changed, 608 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore @@ -0,0 +1,6 @@ +charts +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/.helmignore b/.helmignore @@ -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/ diff --git a/Chart.lock b/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: livekit-server + repository: https://helm.livekit.io + version: 1.5.3 +digest: sha256:341a04fb941a386e49a006b094769c6867c6856dde1acf544f9e36ac12f3b520 +generated: "2024-03-01T15:41:11.024712244+01:00" diff --git a/Chart.yaml b/Chart.yaml @@ -0,0 +1,12 @@ +apiVersion: v2 +name: element-call +description: A Helm chart for element_call +type: application +version: 0.1.0 +appVersion: "v0.5.15" + +dependencies: +- name: livekit-server + version: "1.5.3" + repository: "https://helm.livekit.io" + condition: livekit-server.enabled +\ No newline at end of file diff --git a/templates/NOTES.txt b/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.element_call.ingress.enabled }} +{{- range $host := .Values.element_call.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.element_call.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.element_call.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "element_call.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.element_call.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "element_call.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "element_call.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:8080 +{{- else if contains "ClusterIP" .Values.element_call.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "element_call.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:8080 +{{- end }} diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl @@ -0,0 +1,77 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "element_call.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 "element_call.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 a default LiveKit Management Service name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "element_call.livekit_mgmt_name" -}} +{{- printf "%s-%s" .Release.Name "livekit-mgmt-svc" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "element_call.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "element_call.labels" -}} +helm.sh/chart: {{ include "element_call.chart" . }} +{{ include "element_call.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{- define "element_call.livekit_mgmt.labels" -}} +helm.sh/chart: {{ include "element_call.chart" . }} +{{ include "element_call.livekit_mgmt.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "element_call.selectorLabels" -}} +app.kubernetes.io/name: {{ include "element_call.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Selector Labels for livekit mgmt +*/}} +{{- define "element_call.livekit_mgmt.selectorLabels" -}} +app.kubernetes.io/name: {{ include "element_call.livekit_mgmt_name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end}} +\ No newline at end of file diff --git a/templates/deployment.yaml b/templates/deployment.yaml @@ -0,0 +1,109 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "element_call.fullname" . }} + labels: + {{- include "element_call.labels" . | nindent 4 }} +spec: + {{- if not .Values.element_call.autoscaling.enabled }} + replicas: {{ .Values.element_call.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "element_call.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.element_call.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "element_call.labels" . | nindent 8 }} + {{- with .Values.element_call.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.element_call.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.element_call.securityContext | nindent 12 }} + image: "{{ .Values.element_call.image.repository }}:{{ .Values.element_call.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.element_call.image.pullPolicy }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: 8080 + initialDelaySeconds: 3 + periodSeconds: 3 + readinessProbe: + httpGet: + path: / + port: 8080 + initialDelaySeconds: 3 + periodSeconds: 3 + resources: + {{- toYaml .Values.element_call.resources | nindent 12 }} + {{- with .Values.element_call.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.element_call.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.element_call.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.element_call.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.element_call.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} +{{- if .Values.element_call.autoscaling.enabled }} +--- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "element_call.fullname" . }} + labels: + {{- include "element_call.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "element_call.fullname" . }} + minReplicas: {{ .Values.element_call.autoscaling.minReplicas }} + maxReplicas: {{ .Values.element_call.autoscaling.maxReplicas }} + metrics: + {{- if .Values.element_call.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.element_call.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.element_call.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.element_call.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/templates/deployment_livekit_mgmt_service.yaml b/templates/deployment_livekit_mgmt_service.yaml @@ -0,0 +1,82 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "element_call.livekit_mgmt_name" . }} + labels: + {{- include "element_call.livekit_mgmt.labels" . | nindent 4 }} +spec: + {{- if not .Values.livekit_mgmt.autoscaling.enabled }} + replicas: {{ .Values.livekit_mgmt.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "element_call.livekit_mgmt.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.livekit_mgmt.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "element_call.livekit_mgmt.labels" . | nindent 8 }} + {{- with .Values.livekit_mgmt.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.livekit_mgmt.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.livekit_mgmt.securityContext | nindent 12 }} + image: "{{ .Values.livekit_mgmt.image.repository }}:{{ .Values.livekit_mgmt.image.tag }}" + imagePullPolicy: {{ .Values.livekit_mgmt.image.pullPolicy }} + env: + - name: LIVEKIT_URL + value: ws://{{ index .Values "livekit-server" "livekit" "port" }}:7800 + - name: LIVEKIT_KEY + value: {{ .Values.livekit_key }} + - name: LIVEKIT_SECRET + value: {{ .Values.livekit_secret }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: 8080 + initialDelaySeconds: 3 + periodSeconds: 3 + readinessProbe: + httpGet: + path: / + port: 8080 + initialDelaySeconds: 3 + periodSeconds: 3 + resources: + {{- toYaml .Values.livekit_mgmt.resources | nindent 12 }} + {{- with .Values.livekit_mgmt.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.livekit_mgmt.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.livekit_mgmt.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.livekit_mgmt.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.livekit_mgmt.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/templates/ingress.yaml b/templates/ingress.yaml @@ -0,0 +1,60 @@ +{{- if .Values.element_call.ingress.enabled -}} +{{- $fullName := include "element_call.fullname" . -}} +{{- if and .Values.element_call.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.element_call.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.element_call.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "element_call.labels" . | nindent 4 }} + {{- with .Values.element_call.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.element_call.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.element_call.ingress.className }} + {{- end }} + {{- if .Values.element_call.ingress.tls }} + tls: + {{- range .Values.element_call.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.element_call.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: 8080 + {{- else }} + serviceName: {{ $fullName }} + servicePort: 8080 + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/templates/service.yaml b/templates/service.yaml @@ -0,0 +1,32 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "element_call.fullname" . }} + labels: + {{- include "element_call.labels" . | nindent 4 }} +spec: + type: {{ .Values.element_call.service.type }} + ports: + - port: 8080 + targetPort: http + protocol: TCP + name: http + selector: + {{- include "element_call.selectorLabels" . | nindent 4 }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "element_call.livekit_mgmt_name" . }} + labels: + {{- include "element_call.livekit_mgmt.labels" . | nindent 4 }} +spec: + type: {{ .Values.livekit_mgmt.service.type }} + ports: + - port: 8080 + targetPort: http + protocol: TCP + name: http + selector: + {{- include "element_call.livekit_mgmt.selectorLabels" . | nindent 4 }} diff --git a/templates/tests/test-connection.yaml b/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "element_call.fullname" . }}-test-connection" + labels: + {{- include "element_call.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "element_call.fullname" . }}:8080'] + restartPolicy: Never diff --git a/values.yaml b/values.yaml @@ -0,0 +1,161 @@ +# Default values for element_call. + +imagePullSecrets: [] + +# Livekit specific global settings + +## THESE MUST BE CHANGED! +## THESE ALSO MUST BE DEFINED AT `.livekit-server.livekit.keys`! +livekit_key: devkey +livekit_secret: secret + +element_call: + replicaCount: 1 + + image: + repository: ghcr.io/element-hq/element-call + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + nameOverride: "" + fullnameOverride: "" + + podAnnotations: {} + podLabels: {} + + podSecurityContext: {} + # fsGroup: 2000 + + securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + service: + type: ClusterIP + + ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + + resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + + # Additional volumes on the output Deployment definition. + volumes: [] + # - name: foo + # secret: + # secretName: mysecret + # optional: false + + # Additional volumeMounts on the output Deployment definition. + volumeMounts: [] + # - name: foo + # mountPath: "/etc/foo" + # readOnly: true + + nodeSelector: {} + + tolerations: [] + + affinity: {} + +livekit_mgmt: + replicaCount: 1 + + image: + repository: ghcr.io/element-hq/lk-jwt-service + pullPolicy: IfNotPresent + tag: "latest-ci" + nameOverride: "" + fullnameOverride: "" + + podAnnotations: {} + podLabels: {} + + podSecurityContext: {} + # fsGroup: 2000 + + securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + service: + type: ClusterIP + + resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + + # Additional volumes on the output Deployment definition. + volumes: [] + # - name: foo + # secret: + # secretName: mysecret + # optional: false + + # Additional volumeMounts on the output Deployment definition. + volumeMounts: [] + # - name: foo + # mountPath: "/etc/foo" + # readOnly: true + + nodeSelector: {} + + tolerations: [] + + affinity: {} + +livekit-server: + enabled: true + # See https://github.com/livekit/livekit-helm/blob/master/livekit-server/values.yaml for values +\ No newline at end of file