{{- if .Values.meshName }}
apiVersion: appmesh.k8s.aws/v1beta1
kind: VirtualNode
metadata:
  name: {{ include "loadtester.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ include "loadtester.name" . }}
    helm.sh/chart: {{ include "loadtester.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
  meshName: {{ .Values.meshName }}
  listeners:
    - portMapping:
        port: 444
        protocol: http
  serviceDiscovery:
    dns:
      hostName: {{ include "loadtester.fullname" . }}.{{ .Release.Namespace }}
  {{- if .Values.backends }}
  backends:
    {{- range .Values.backends }}
    - virtualService:
        virtualServiceName: {{ . }}
    {{- end }}
  {{- end }}
{{- end }}
