diff --git a/charts/element-call/Chart.yaml b/charts/element-call/Chart.yaml new file mode 100644 index 0000000..1608e43 --- /dev/null +++ b/charts/element-call/Chart.yaml @@ -0,0 +1,11 @@ +apiVersion: v2 +name: element-call +description: Matrix video conference and call server +icon: https://avatars.githubusercontent.com/u/13446337?s=48&v=4 +appVersion: v0.5.15 + +type: application +version: 0.1.8 +maintainers: +- name: Tommy Skaug + email: tommy@skaug.me diff --git a/charts/element-call/templates/NOTES.txt b/charts/element-call/templates/NOTES.txt new file mode 100644 index 0000000..3982b1c --- /dev/null +++ b/charts/element-call/templates/NOTES.txt @@ -0,0 +1,16 @@ +1. Get the application URL by running these commands: +{{- if contains "NodePort" .Values.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.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:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.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:$CONTAINER_PORT +{{- end }} diff --git a/charts/element-call/templates/_helpers.tpl b/charts/element-call/templates/_helpers.tpl new file mode 100644 index 0000000..c4cebd9 --- /dev/null +++ b/charts/element-call/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +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 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 }} + +{{/* +Selector labels +*/}} +{{- define "element-call.selectorLabels" -}} +app.kubernetes.io/name: {{ include "element-call.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "element-call.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "element-call.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/element-call/templates/config-template.yaml b/charts/element-call/templates/config-template.yaml new file mode 100644 index 0000000..af1f229 --- /dev/null +++ b/charts/element-call/templates/config-template.yaml @@ -0,0 +1,25 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-configmap +data: + config.json: | + { + "default_server_config": { + "m.homeserver": { + "base_url": "{{ .Values.config.homeserver.base_url }}", + "server_name": "{{ .Values.config.homeserver.server_name }}" + } + }, + "livekit": { + "livekit_service_url": "{{ .Values.config.livekit.livekit_service_url }}" + }, + "posthog": { + "api_key": "{{ .Values.config.posthog.api_key }}", + "api_host": "{{ .Values.config.posthog.api_host }}" + }, + "rageshake": { + "submit_url": "{{ .Values.config.rageshake.submit_url }}" + }, + "eula": "{{ .Values.config.eula_url }}" + } diff --git a/charts/element-call/templates/deployment.yaml b/charts/element-call/templates/deployment.yaml new file mode 100644 index 0000000..96b707b --- /dev/null +++ b/charts/element-call/templates/deployment.yaml @@ -0,0 +1,69 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "element-call.fullname" . }} + labels: + {{- include "element-call.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "element-call.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "element-call.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "element-call.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + volumes: + - name: config-volume + configMap: + name: {{ .Release.Name }}-configmap + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + volumeMounts: + - name: config-volume + mountPath: /app/config.json + subPath: config.json + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + 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 }} diff --git a/charts/element-call/templates/hpa.yaml b/charts/element-call/templates/hpa.yaml new file mode 100644 index 0000000..55faa30 --- /dev/null +++ b/charts/element-call/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.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.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/element-call/templates/service.yaml b/charts/element-call/templates/service.yaml new file mode 100644 index 0000000..0c0ca72 --- /dev/null +++ b/charts/element-call/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "element-call.fullname" . }} + labels: + {{- include "element-call.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "element-call.selectorLabels" . | nindent 4 }} diff --git a/charts/element-call/templates/serviceaccount.yaml b/charts/element-call/templates/serviceaccount.yaml new file mode 100644 index 0000000..3b79d02 --- /dev/null +++ b/charts/element-call/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "element-call.serviceAccountName" . }} + labels: + {{- include "element-call.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/element-call/templates/tests/test-connection.yaml b/charts/element-call/templates/tests/test-connection.yaml new file mode 100644 index 0000000..6593ab2 --- /dev/null +++ b/charts/element-call/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" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/element-call/tests/service_test.yaml b/charts/element-call/tests/service_test.yaml new file mode 100644 index 0000000..0da8261 --- /dev/null +++ b/charts/element-call/tests/service_test.yaml @@ -0,0 +1,26 @@ +suite: test service +templates: + - templates/service.yaml +tests: + - it: should pass + release: + name: element-call + set: + service: + type: ClusterIP + asserts: + - contains: + path: spec.ports + content: + name: http + port: 8080 + protocol: TCP + targetPort: http + - equal: + path: spec.type + value: ClusterIP + - equal: + path: spec.selector + value: + app.kubernetes.io/name: element-call + app.kubernetes.io/instance: element-call diff --git a/charts/element-call/values.yaml b/charts/element-call/values.yaml new file mode 100644 index 0000000..8ac4e41 --- /dev/null +++ b/charts/element-call/values.yaml @@ -0,0 +1,79 @@ +# Default values for element-call. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ghcr.io/element-hq/element-call + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # 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: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 8080 + +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 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +config: + homeserver: + base_url: http://localhost:8008 + server_name: localhost + livekit: + livekit_service_url: https://localhost/ + posthog: + api_key: + api_host: https://localhost + rageshake: + submit_url: + eula_url: