apiVersion: kwok.x-k8s.io/v1alpha1
kind: Stage
metadata:
  annotations:
  name: pod-unhealthy
spec:
  next:
    statusSubresource: status
    statusTemplate: |
      {{ $now := Now }}

      conditions:
      - lastTransitionTime: {{ $now | Quote }}
        status: "True"
        type: Initialized
      - lastTransitionTime: {{ $now | Quote }}
        status: "False"
        type: Ready
      - lastTransitionTime: {{ $now | Quote }}
        status: "True"
        type: ContainersReady
      {{ range .spec.readinessGates }}
      - lastTransitionTime: {{ $now | Quote }}
        status: "True"
        type: {{ .conditionType | Quote }}
      {{ end }}

      containerStatuses:
      {{ range .spec.containers }}
      - image: {{ .image | Quote }}
        name: {{ .name | Quote }}
        ready: true
        restartCount: 0
        state:
          running:
            startedAt: {{ $now | Quote }}
      {{ end }}

      initContainerStatuses:
      {{ range .spec.initContainers }}
      - image: {{ .image | Quote }}
        name: {{ .name | Quote }}
        ready: true
        restartCount: 0
        state:
          terminated:
            exitCode: 0
            finishedAt: {{ $now | Quote }}
            reason: Completed
            startedAt: {{ $now | Quote }}
      {{ end }}

      hostIP: {{ NodeIPWith .spec.nodeName | Quote }}
      podIP: {{ PodIPWith .spec.nodeName ( or .spec.hostNetwork false ) ( or .metadata.uid "" ) ( or .metadata.name "" ) ( or .metadata.namespace "" ) | Quote }}
      phase: Unknown
      startTime: {{ $now | Quote }}
  resourceRef:
    apiGroup: v1
    kind: Pod
  selector:
    matchLabels:
      kwok.x-k8s.io/stage: unhealthy
    matchExpressions:
    - key: .metadata.deletionTimestamp
      operator: DoesNotExist
    - key: .status.podIP
      operator: DoesNotExist
  weight: 100