    - it has restarted too many times (reached the restart-expiry-threshold threshold)
    - the primary container (waiter-apps) has not transitioned to running state in container-running-grace-secs seconds
    - the pod has the waiter/pod-expired=true annotation."
-  [{:keys [container-running-grace-secs restart-expiry-threshold watch-state]}
+  [{:keys [container-running-grace-secs restart-expiry-threshold watch-state] :as scheduler-config}
    service-id instance-id restart-count {:keys [waiter/pod-expired waiter/revision-timestamp]}
    primary-container-status pod-started-at]
   (let [rs-revision-timestamp-path [:service-id->service service-id :k8s/replicaset-annotations :waiter/revision-timestamp]

          auth-renewer (when authentication
                         (start-auth-renewer authentication))
          retrieve-auth-token-state-fn (or (:query-state-fn auth-renewer) (constantly nil))
          scheduler (->KubernetesScheduler url
                                           authorizer
                                           cluster-name
                                           container-running-grace-secs
                                           custom-options
                                           daemon-state
                                           fileserver
                                           http-client
                                           leader?-fn
                                           log-bucket-url
                                           max-patch-retries
                                           max-name-length
                                           pdb-api-version
                                           pdb-spec-builder-fn
                                           pod-base-port
                                           pod-sigkill-delay-secs
                                           pod-suffix-length
                                           replicaset-api-version
                                           replicaset-spec-builder-fn
                                           restart-expiry-threshold
                                           restart-kill-threshold
                                           retrieve-auth-token-state-fn
                                           retrieve-syncer-state-fn
                                           reverse-proxy
                                           service-id->failed-instances-transient-store
                                           service-id->password-fn
                                           service-id->service-description-fn
                                           scheduler-name
                                           watch-state)
          pod-watch-thread (start-pods-watch! scheduler watch-options)
          rs-watch-thread (start-replicasets-watch! scheduler watch-options)]
      (reset! daemon-state {:pod-watch-daemon pod-watch-thread

          instance (scheduler/make-ServiceInstance
                     (cond-> {:extra-ports (->> pod-annotations :waiter/port-count Integer/parseInt range next (mapv #(+ port0 %)))
                              :flags (cond-> #{}
                                       (check-expired scheduler-config service-id instance-id pod-restart-count pod-annotations primary-container-status pod-started-at)
                                       (conj :expired))
                              :healthy? (and (true? (get primary-container-status :ready))
                                             ;; Note that when exceeded-restart-kill-threshold? becomes true, the container *just* restarted and is non-ready,
