diff --git a/changelog.d/0-release-notes/coturn-labels b/changelog.d/0-release-notes/coturn-labels new file mode 100644 index 0000000000..043dfd539f --- /dev/null +++ b/changelog.d/0-release-notes/coturn-labels @@ -0,0 +1,6 @@ +For users of the (currently alpha) coturn Helm chart, **manual action is +required** when upgrading to this version. The labels applied to the Kubernetes +manifests in this chart have changed, in order to match the conventions used +in the wire-server charts. However, this may mean that upgrading with Helm can +fail, due to changes to the `StatefulSet` included in this chart -- in this +case, the `StatefulSet` must be deleted before the chart is upgraded. diff --git a/changelog.d/2-features/coturn-metrics b/changelog.d/2-features/coturn-metrics new file mode 100644 index 0000000000..717a9c795a --- /dev/null +++ b/changelog.d/2-features/coturn-metrics @@ -0,0 +1,2 @@ +The coturn chart now has support for exposing its metric endpoint with a +ServiceMonitor, which can be ingested by third-party metrics collection tools. diff --git a/changelog.d/5-internal/coturn-labels b/changelog.d/5-internal/coturn-labels new file mode 100644 index 0000000000..33c3a3f5b0 --- /dev/null +++ b/changelog.d/5-internal/coturn-labels @@ -0,0 +1,2 @@ +The labels applied to resources in the coturn chart have been changed to +reflect the conventions in the wire-server charts. diff --git a/charts/coturn/templates/_helpers.yaml b/charts/coturn/templates/_helpers.yaml deleted file mode 100644 index 32fea22520..0000000000 --- a/charts/coturn/templates/_helpers.yaml +++ /dev/null @@ -1,45 +0,0 @@ -{{- define "coturn.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "coturn.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Common labels -*/}} -{{- define "coturn.labels" -}} -helm.sh/chart: {{ include "coturn.chart" . }} -{{ include "coturn.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Values.image.tag | default .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- 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 "coturn.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 }} - -{{- define "coturn.selectorLabels" -}} -app.kubernetes.io/name: {{ include "coturn.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} diff --git a/charts/coturn/templates/configmap-coturn-conf-template.yaml b/charts/coturn/templates/configmap-coturn-conf-template.yaml index 76e0f95605..4a2a4c4c06 100644 --- a/charts/coturn/templates/configmap-coturn-conf-template.yaml +++ b/charts/coturn/templates/configmap-coturn-conf-template.yaml @@ -1,9 +1,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ include "coturn.fullname" . }} - labels: - {{- include "coturn.selectorLabels" . | nindent 4 }} + name: coturn data: coturn.conf.template: | diff --git a/charts/coturn/templates/secret.yaml b/charts/coturn/templates/secret.yaml index af6a8563cf..6dd5521206 100644 --- a/charts/coturn/templates/secret.yaml +++ b/charts/coturn/templates/secret.yaml @@ -8,9 +8,10 @@ kind: Secret metadata: name: coturn labels: + app: coturn chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} - release: "{{ .Release.Name }}" - heritage: "{{ .Release.Service }}" + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} type: Opaque stringData: zrest_secret.txt: | diff --git a/charts/coturn/templates/service-account.yaml b/charts/coturn/templates/service-account.yaml index 1bea5d5908..ce2803840f 100644 --- a/charts/coturn/templates/service-account.yaml +++ b/charts/coturn/templates/service-account.yaml @@ -2,16 +2,22 @@ apiVersion: v1 kind: ServiceAccount metadata: - name: {{ include "coturn.fullname" . }} + name: coturn labels: - {{- include "coturn.labels" . | nindent 4 }} + app: coturn + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - name: {{ include "coturn.fullname" . }} + name: coturn labels: - {{- include "coturn.labels" . | nindent 4 }} + app: coturn + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} rules: - apiGroups: [""] resources: [nodes] @@ -20,14 +26,17 @@ rules: apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: - name: {{ include "coturn.fullname" . }} + name: coturn labels: - {{- include "coturn.labels" . | nindent 4 }} + app: coturn + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} roleRef: kind: ClusterRole apiGroup: rbac.authorization.k8s.io - name: {{ include "coturn.fullname" . }} + name: coturn subjects: - kind: ServiceAccount - name: {{ include "coturn.fullname" . }} + name: coturn namespace: {{ .Release.Namespace }} diff --git a/charts/coturn/templates/service.yaml b/charts/coturn/templates/service.yaml index a5f8f15bd5..f1420c44d6 100644 --- a/charts/coturn/templates/service.yaml +++ b/charts/coturn/templates/service.yaml @@ -2,9 +2,12 @@ apiVersion: v1 kind: Service metadata: - name: {{ include "coturn.fullname" . }} + name: coturn labels: - {{- include "coturn.labels" . | nindent 4 }} + app: coturn + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} spec: # Needs to be headless # See: https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/ @@ -22,5 +25,9 @@ spec: port: {{ .Values.coturnTurnTlsListenPort }} targetPort: coturn-tls {{- end }} + - name: status-http + port: {{ .Values.coturnMetricsListenPort }} + targetPort: status-http selector: - {{- include "coturn.selectorLabels" . | nindent 4 }} + app: coturn + release: {{ .Release.Name }} diff --git a/charts/coturn/templates/servicemonitor.yaml b/charts/coturn/templates/servicemonitor.yaml new file mode 100644 index 0000000000..a21f0faea4 --- /dev/null +++ b/charts/coturn/templates/servicemonitor.yaml @@ -0,0 +1,19 @@ +{{- if .Values.metrics.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: coturn + labels: + app: coturn + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + endpoints: + - port: status-http + path: /metrics + selector: + matchLabels: + app: coturn + release: {{ .Release.Name }} +{{- end }} diff --git a/charts/coturn/templates/statefulset.yaml b/charts/coturn/templates/statefulset.yaml index daf90ace40..8ab28192b5 100644 --- a/charts/coturn/templates/statefulset.yaml +++ b/charts/coturn/templates/statefulset.yaml @@ -1,9 +1,12 @@ apiVersion: apps/v1 kind: StatefulSet metadata: - name: {{ include "coturn.fullname" . }} + name: coturn labels: - {{- include "coturn.labels" . | nindent 4 }} + app: coturn + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} spec: replicas: {{ .Values.replicaCount }} @@ -12,10 +15,10 @@ spec: # affect upgrades. podManagementPolicy: Parallel - serviceName: {{ include "coturn.fullname" . }} + serviceName: coturn selector: matchLabels: - {{- include "coturn.selectorLabels" . | nindent 6 }} + app: coturn template: metadata: {{- with .Values.podAnnotations }} @@ -24,7 +27,8 @@ spec: {{- end }} labels: - {{- include "coturn.selectorLabels" . | nindent 8 }} + app: coturn + release: {{ .Release.Name }} spec: securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} @@ -33,7 +37,7 @@ spec: shareProcessNamespace: true {{- end }} hostNetwork: true - serviceAccountName: {{ include "coturn.fullname" . }} + serviceAccountName: coturn volumes: - name: external-ip emptyDir: {} @@ -41,7 +45,7 @@ spec: emptyDir: {} - name: coturn-config-template configMap: - name: {{ include "coturn.fullname" . }} + name: coturn - name: secrets secret: secretName: coturn diff --git a/charts/coturn/values.yaml b/charts/coturn/values.yaml index 1504bbcdca..eede1626be 100644 --- a/charts/coturn/values.yaml +++ b/charts/coturn/values.yaml @@ -36,6 +36,10 @@ tls: pullPolicy: IfNotPresent tag: 1aa6cbbf2ce3a5182ec47e3579bbcb8f47e22fdc +metrics: + serviceMonitor: + enabled: false + # This chart optionally supports waiting for traffic to drain from coturn # before pods are terminated. Warning: coturn does not have any way to steer # incoming client traffic away from itself on its own, so this functionality