{{- if not .Values.rbac.only }}
apiVersion: v1
kind: Service
metadata:
  name: {{ include "traffic-manager.name" . }}
  namespace: {{ include "traffic-manager.namespace" . }}
  labels:
    {{- include "telepresence.labels" . | nindent 4 }}
spec:
  type: {{ .Values.service.type }}
  clusterIP: None
  ports:
  - name: api
    port: {{ .Values.apiPort }}
    targetPort: api
  {{- with .Values.tracing }}
  {{- if .grpcPort }}
  - name: grpc-trace
    port: {{ .grpcPort }}
    targetPort: "grpc-trace"
  {{- end }}
  {{- end }}

  selector:
    {{- include "telepresence.selectorLabels" . | nindent 4 }}
---
apiVersion: v1
kind: Service
metadata:
  name: {{ .Values.agentInjector.name }}
  namespace: {{ include "traffic-manager.namespace" . }}
  labels:
    {{- include "telepresence.labels" . | nindent 4 }}
spec:
  type: {{ .Values.service.type }}
  ports:
  - name: https
    port: {{ .Values.agentInjector.webhook.port }}
    targetPort: https
  selector:
    {{- include "telepresence.selectorLabels" . | nindent 4 }}
{{- if .Values.prometheus.port }} # 0 is false
---
apiVersion: v1
kind: Service
metadata:
  name: telepresence-prometheus
  namespace: {{ include "traffic-manager.namespace" . }}
  labels:
    name: telepresence-prometheus
spec:
  type: {{ .Values.service.type }}
  ports:
  - name: telepresence-prometheus
    port: 80
    targetPort: prometheus
  selector:
    {{- include "telepresence.selectorLabels" . | nindent 4 }}
{{- end }}
{{- end }}
