   [k8s-obj]
   (get-in k8s-obj [:metadata :name]))
 
+(defn k8s-object->namespace
+  "Get the namespace from a ReplicaSet or Pod's metadata"
+  [k8s-obj]
+  (get-in k8s-obj [:metadata :namespace]))
+
 (defn k8s-object->resource-version
   "Get the resource version from a Kubernetes API response object.
    Valid on ReplicaSets, Pods, and watch-update objects."

                                  (assoc-in state [:pods-metadata :timestamp :watch] now)
                                  (assoc-in state [:pods-metadata :version :watch] version)))
                        (let [old-pod (get-in old-state [:service-id->pod-id->pod service-id pod-id])
                              [pod-fields pod-fields'] (data/diff old-pod pod)]
                          (scheduler/log "pod state update:" update-type version pod-fields "->" pod-fields')))))}
      (merge options))))

(defn global-rs-state-query

  (try
    (let [port0 (get-in pod [:spec :containers 0 :ports 0 :containerPort])
          restart-count (get-in pod [:status :containerStatuses 0 :restartCount])
          namespace (k8s-object->namespace pod)]
      (scheduler/make-ServiceInstance
        {:extra-ports (->> (get-in pod [:metadata :annotations :waiter/port-count])
                           Integer/parseInt range next (mapv #(+ port0 %)))
