{{/*
Target the very simple case where
fluentd is deployed with the default values
If the fluentd config is overriden and the metrics server removed
this will fail.
*/}}
{{ if empty .Values.service.ports }}
apiVersion: v1
kind: Pod
metadata:
  name: "{{ include "fluentd.fullname" . }}-test-connection"
  labels:
    {{- include "fluentd.labels" . | nindent 4 }}
  annotations:
    "helm.sh/hook": test-success
spec:
  containers:
    - name: wget
      image: busybox
      command:
        - sh
        - -c
        - |
          set -e
          # Give fluentd some time to start up
          while :; do nc -vz {{ include "fluentd.fullname" . }}:24231 && break; sleep 1; done
          wget '{{ include "fluentd.fullname" . }}:24231/metrics'
  restartPolicy: Never
{{ end }}