# Information about the service # For documentation on these properties, see: # kubernetes.io/docs/concepts/services-networking/service/#defining-a-service

apiVersion: v1 kind: Service metadata:

# References the "<%= Tpt::Rails.app_name %>.fullname" property defined in _helpers.tpl
name: {{ template "<%= Tpt::Rails.app_name %>.fullname" . }}
labels:
  app: {{ template "<%= Tpt::Rails.app_name %>.fullname" . }}
  # References system properties from Helm
  chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
  release: "{{ .Release.Name }}"
  heritage: "{{ .Release.Service }}"
  tpt/project: "{{ .Chart.Name }}"
  tpt/owner: {{ .Values.annotations.owner }}
  tpt/creator: {{ .Values.annotations.creator | default "UNKNOWN" | quote }}
  tpt/release: "{{ .Release.Name }}"
  tpt/costEnv: {{ .Values.annotations.costEnv | quote }}
  tpt/costCategory: {{ .Values.annotations.costCategory | quote }}
annotations:
  getambassador.io/config: |
    apiVersion: ambassador/v1
    kind: Mapping
    name: {{ template "<%= Tpt::Rails.app_name %>.fullname" . }}_{{ .Release.Namespace }}_mapping
    prefix: /
    host: {{ template "<%= Tpt::Rails.app_name %>.fullname" . }}.ode.tptpm.info
    service: {{ template "<%= Tpt::Rails.app_name %>.fullname" . }}.{{ .Release.Namespace }}:{{ .Values.service.port }}
    # retry_policy:
    #   retry_on: "5xx"
    #   num_retries: 5
    #   per_try_timeout: "3s"
    labels:
      ambassador:
        - request_label:
          - frontend

{{- if eq .Values.service.type “LoadBalancer” }}

external-dns.alpha.kubernetes.io/hostname: {{ .Values.hostname }}
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: "http"
service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: "true"
service.beta.kubernetes.io/aws-load-balancer-internal: "0.0.0.0/0"

{{- end }} spec:

# References the service.type property from values.yaml
type: {{ .Values.service.type }}
ports:
- name: http
  # The incoming port
  port: {{ .Values.service.port }}
  protocol: TCP
  # Port to map to. This is where the application is listening
  targetPort: {{ .Values.environment.APP_PORT }}
selector:
  app: {{ template "<%= Tpt::Rails.app_name %>.fullname" . }}