{{ if .Values.collector.enabled -}}
---
apiVersion: policy.linkerd.io/v1beta3
kind: Server
metadata:
  namespace: {{ .Release.Namespace }}
  name: collector-otlp
  labels:
    linkerd.io/extension: jaeger
    component: collector
    {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
  annotations:
    {{ include "partials.annotations.created-by" . }}
spec:
  podSelector:
    matchLabels:
      component: collector
  port: 4317
  proxyProtocol: gRPC
---
apiVersion: policy.linkerd.io/v1beta3
kind: Server
metadata:
  namespace: {{ .Release.Namespace }}
  name: collector-otlp-http
  labels:
    linkerd.io/extension: jaeger
    component: collector
  annotations:
    {{ include "partials.annotations.created-by" . }}
spec:
  podSelector:
    matchLabels:
      component: collector
  port: 4318
  proxyProtocol: HTTP/1
---
apiVersion: policy.linkerd.io/v1beta3
kind: Server
metadata:
  namespace: {{ .Release.Namespace }}
  name: collector-opencensus
  labels:
    linkerd.io/extension: jaeger
    component: collector
    {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
  annotations:
    {{ include "partials.annotations.created-by" . }}
spec:
  podSelector:
    matchLabels:
      component: collector
  port: 55678
  proxyProtocol: gRPC
---
apiVersion: policy.linkerd.io/v1beta3
kind: Server
metadata:
  namespace: {{ .Release.Namespace }}
  name: collector-zipkin
  labels:
    linkerd.io/extension: jaeger
    component: collector
    {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
  annotations:
    {{ include "partials.annotations.created-by" . }}
spec:
  podSelector:
    matchLabels:
      component: collector
  port: 9411
---
apiVersion: policy.linkerd.io/v1beta3
kind: Server
metadata:
  namespace: {{ .Release.Namespace }}
  name: collector-jaeger-thrift
  labels:
    linkerd.io/extension: jaeger
    component: collector
    {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
  annotations:
    {{ include "partials.annotations.created-by" . }}
spec:
  podSelector:
    matchLabels:
      component: collector
  port: 14268
---
apiVersion: policy.linkerd.io/v1beta3
kind: Server
metadata:
  namespace: {{ .Release.Namespace }}
  name: collector-jaeger-grpc
  labels:
    linkerd.io/extension: jaeger
    component: collector
    {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
  annotations:
    {{ include "partials.annotations.created-by" . }}
spec:
  podSelector:
    matchLabels:
      component: collector
  port: 14250
---
apiVersion: policy.linkerd.io/v1beta3
kind: Server
metadata:
  namespace: {{ .Release.Namespace }}
  name: collector-admin
  labels:
    linkerd.io/extension: jaeger
    component: collector
    {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
  annotations:
    {{ include "partials.annotations.created-by" . }}
spec:
  podSelector:
    matchLabels:
      component: collector
  port: 13133
  proxyProtocol: HTTP/1
---
apiVersion: policy.linkerd.io/v1alpha1
kind: AuthorizationPolicy
metadata:
  namespace: {{ .Release.Namespace }}
  name: collector-otlp
  labels:
    linkerd.io/extension: jaeger
    component: collector
    {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
  annotations:
    {{ include "partials.annotations.created-by" . }}
spec:
  targetRef:
    group: policy.linkerd.io
    kind: Server
    name: collector-otlp
  # allow connections from any pod (meshed or not) sending trace data
  requiredAuthenticationRefs: []
---
apiVersion: policy.linkerd.io/v1alpha1
kind: AuthorizationPolicy
metadata:
  namespace: {{ .Release.Namespace }}
  name: collector-otlp-http
  labels:
    linkerd.io/extension: jaeger
    component: collector
    {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
  annotations:
    {{ include "partials.annotations.created-by" . }}
spec:
  targetRef:
    group: policy.linkerd.io
    kind: Server
    name: collector-otlp-http
  # allow connections from any pod (meshed or not) sending trace data
  requiredAuthenticationRefs: []
---
apiVersion: policy.linkerd.io/v1alpha1
kind: AuthorizationPolicy
metadata:
  namespace: {{ .Release.Namespace }}
  name: collector-opencensus
  labels:
    linkerd.io/extension: jaeger
    component: collector
    {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
  annotations:
    {{ include "partials.annotations.created-by" . }}
spec:
  targetRef:
    group: policy.linkerd.io
    kind: Server
    name: collector-opencensus
  # allow connections from any pod (meshed or not) sending trace data
  requiredAuthenticationRefs: []
---
apiVersion: policy.linkerd.io/v1alpha1
kind: AuthorizationPolicy
metadata:
  namespace: {{ .Release.Namespace }}
  name: collector-zipkin
  labels:
    linkerd.io/extension: jaeger
    component: collector
    {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
  annotations:
    {{ include "partials.annotations.created-by" . }}
spec:
  targetRef:
    group: policy.linkerd.io
    kind: Server
    name: collector-zipkin
  # allow connections from any pod (meshed or not) sending trace data
  requiredAuthenticationRefs: []
---
apiVersion: policy.linkerd.io/v1alpha1
kind: AuthorizationPolicy
metadata:
  namespace: {{ .Release.Namespace }}
  name: collector-jaeger-thrift
  labels:
    linkerd.io/extension: jaeger
    component: collector
    {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
  annotations:
    {{ include "partials.annotations.created-by" . }}
spec:
  targetRef:
    group: policy.linkerd.io
    kind: Server
    name: collector-jaeger-thrift
  # allow connections from any pod (meshed or not) sending trace data
  requiredAuthenticationRefs: []
---
apiVersion: policy.linkerd.io/v1alpha1
kind: AuthorizationPolicy
metadata:
  namespace: {{ .Release.Namespace }}
  name: collector-jaeger-grpc
  labels:
    linkerd.io/extension: jaeger
    component: collector
    {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
  annotations:
    {{ include "partials.annotations.created-by" . }}
spec:
  targetRef:
    group: policy.linkerd.io
    kind: Server
    name: collector-jaeger-grpc
  # allow connections from any pod (meshed or not) sending trace data
  requiredAuthenticationRefs: []
---
apiVersion: policy.linkerd.io/v1beta3
kind: Server
metadata:
  namespace: {{ .Release.Namespace }}
  name: jaeger-grpc
  labels:
    linkerd.io/extension: jaeger
    component: jaeger
    {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
  annotations:
    {{ include "partials.annotations.created-by" . }}
spec:
  podSelector:
    matchLabels:
      component: jaeger
  port: grpc
  proxyProtocol: gRPC
---
apiVersion: policy.linkerd.io/v1alpha1
kind: AuthorizationPolicy
metadata:
  namespace: {{ .Release.Namespace }}
  name: jaeger-grpc
  labels:
    linkerd.io/extension: jaeger
    component: jaeger
    {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
  annotations:
    {{ include "partials.annotations.created-by" . }}
spec:
  targetRef:
    group: policy.linkerd.io
    kind: Server
    name: jaeger-grpc
  requiredAuthenticationRefs:
    - kind: ServiceAccount
      name: collector
      namespace: {{.Release.Namespace}}
---
apiVersion: policy.linkerd.io/v1beta3
kind: Server
metadata:
  namespace: {{ .Release.Namespace }}
  name: jaeger-admin
  labels:
    linkerd.io/extension: jaeger
    component: jaeger
    {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
  annotations:
    {{ include "partials.annotations.created-by" . }}
spec:
  podSelector:
    matchLabels:
      component: jaeger
  port: admin
  proxyProtocol: HTTP/1
---
apiVersion: policy.linkerd.io/v1alpha1
kind: AuthorizationPolicy
metadata:
  namespace: {{ .Release.Namespace }}
  name: jaeger-admin
  labels:
    linkerd.io/extension: jaeger
    component: jaeger
    {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
  annotations:
    {{ include "partials.annotations.created-by" . }}
spec:
  targetRef:
    group: policy.linkerd.io
    kind: Server
    name: jaeger-admin
  requiredAuthenticationRefs:
    # if not using linkerd-viz' prometheus, replace its SA here
    - kind: ServiceAccount
      name: prometheus
      namespace: linkerd-viz
---
apiVersion: policy.linkerd.io/v1beta3
kind: Server
metadata:
  namespace: {{ .Release.Namespace }}
  name: jaeger-ui
  labels:
    linkerd.io/extension: jaeger
    component: jaeger
    {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
  annotations:
    {{ include "partials.annotations.created-by" . }}
spec:
  podSelector:
    matchLabels:
      component: jaeger
  port: ui
  proxyProtocol: HTTP/1
---
apiVersion: policy.linkerd.io/v1alpha1
kind: AuthorizationPolicy
metadata:
  namespace: {{ .Release.Namespace }}
  name: jaeger-ui
  labels:
    linkerd.io/extension: jaeger
    component: jaeger
    {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
  annotations:
    {{ include "partials.annotations.created-by" . }}
spec:
  targetRef:
    group: policy.linkerd.io
    kind: Server
    name: jaeger-ui
  requiredAuthenticationRefs:
    # for the optional dashboard integration
    - kind: ServiceAccount
      name: web
      namespace: linkerd-viz
{{ end -}}
