---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: goldpinger
  labels:
    app: goldpinger
    version: "1.5.0"
spec:
  updateStrategy:
    type: RollingUpdate
  selector:
    matchLabels:
      app: goldpinger
      version: "1.5.0"
  template:
    metadata:
      labels:
        app: goldpinger
        version: "1.5.0"
    spec:
      # if you'd like to use a secret to inject a kubeconfig, you can do it like this
      volumes:
      - name: kubeconfig
        secret:
          secretName: goldpinger-kubeconfig
      containers:
        - name: goldpinger
          env:
            - name: HOST
              value: "0.0.0.0"
            - name: PORT
              value: "80"
            # kubeconfig needs to match the location of what's injected in the secret
            # if not specified goldpinger will default to using in-cluster config
            - name: KUBECONFIG
              value: "/.kube/config"
            # refresh interval (seconds) tells goldpinger to call every other instance with that frequency (set to 0 to disable)
            - name: REFRESH_INTERVAL
              value: "30"
            # injecting real hostname will make for easier to understand graphs/metrics
            - name: HOSTNAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            # podIP is used to select randomized subset of nodes to ping.
            - name: POD_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
          image: "docker.io/bloomberg/goldpinger:1.5.0"
          ports:
            - containerPort: 80
              name: http
          readinessProbe:
            httpGet:
              path: /healthz
              port: 80
            initialDelaySeconds: 20
            periodSeconds: 5
          livenessProbe:
            httpGet:
              path: /healthz
              port: 80
            initialDelaySeconds: 20
            periodSeconds: 5
          volumeMounts:
          - mountPath: /.kube/
            name: kubeconfig
            readOnly: true
---
apiVersion: v1
kind: Service
metadata:
  name: goldpinger
  labels:
    app: goldpinger
spec:
  type: NodePort
  ports:
    - port: 80
      nodePort: 30080
      name: http
  selector:
    app: goldpinger
