ossrs / srs-helm

Helm Charts for SRS media server and Oryx media solution.
http://helm.ossrs.io
MIT License
10 stars 6 forks source link

The service supports custom annotations. #3

Open jugggao opened 7 months ago

jugggao commented 7 months ago

As the subject indicates.

TRANS_BY_GPT4

jugggao commented 7 months ago

example:

apiVersion: v1
kind: Service
metadata:
  name: {{ include "srs.fullname" . }}
  labels:
    {{- include "srs.labels" . | nindent 4 }}
  {{- with .Values.service.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  {{- if (or (eq .Values.service.type "ClusterIP" "") (empty .Values.service.type)) }}
  type: {{ .Values.service.type }}
  {{- if not (empty .Values.service.clusterIP) }}
  clusterIP: {{ .Values.service.clusterIP }}
  {{- end }}
  {{- else if eq .Values.service.type "LoadBalancer" }}
  type: {{ .Values.service.type }}
  loadBalancerIP: {{ default "" .Values.service.loadBalancerIP }}
  {{- else }}
  type: {{ .Values.service.type }}
  {{- end }}
jugggao commented 7 months ago

Ingress requires some modifications to function properly with the SRS player for WHEP playback.

ingress.yaml:

spec:
  {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
  ingressClassName: {{ .Values.ingress.className }}
  {{- end }}
  {{- if .Values.ingress.tls }}
  tls:
    {{- range .Values.ingress.tls }}
    - hosts:
        {{- range .hosts }}
        - {{ . | quote }}
        {{- end }}
      secretName: {{ .secretName }}
    {{- end }}
  {{- end }}
  rules:
    {{- range .Values.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: {{ .svcPort }}
              {{- else }}
              serviceName: {{ $fullName }}
              servicePort: {{ .svcPort }}
              {{- end }}
          {{- end }}
    {{- end }}
{{- end }}

values-custom.yaml:

ingress:
  enabled: true
  className: "nginx-common"
  annotations: {}
  hosts:
  - host: nonprod-srs.example.cn
    paths:
    - path: /
      pathType: ImplementationSpecific
      svcPort: 8080
    - path: /api
      pathType: ImplementationSpecific
      svcPort: 1985
    - path: /rtc
      pathType: ImplementationSpecific
      svcPort: 1985
  tls:
  - hosts:
    - nonprod-srs.example.cn
    secretName: example-tls

TRANS_BY_GPT4

jugggao commented 7 months ago

I am just an operations staff member and not very clear about the software logic. The above is just a suggestion. Perhaps you have a better method to proxy the API and HTTP.

TRANS_BY_GPT4