Kubernetes rest api to check if namespace is created and active
<p>I call the below rest api with post body to create a namespace in kubernetes</p>

<p><a href="http://kuberneteshot/api/v1/namespaces/" rel="nofollow">http://kuberneteshot/api/v1/namespaces/</a></p>

<pre><code>{
    "apiVersion": "v1",
    "kind": "Namespace",
    "metadata": {
        "name": "testnamespace"
    }
}
</code></pre>

<p>In response i get the http status 201 created and the below json response</p>

<pre><code>{
    "kind": "Namespace",
    "apiVersion": "v1",
    "metadata": {
        "name": "testnamespace",
        "selfLink": "/api/v1/namespaces/testnamespace",
        "uid": "701ff75e-5781-11e6-a48a-74dbd1a0fb73",
        "resourceVersion": "57825525",
        "creationTimestamp": "2016-08-01T00:46:52Z",
    },
    "spec": {
        "finalizers": [
            "kubernetes"
        ]
    },
    "status": {
        "phase": "Active"
    }
}
</code></pre>

<p>Does the status in response with phase as Active mean the namespace is successfully created and active ?</p>

<p>Is there any other rest api to check if the namespace exists and is active ?</p>

<p>The reason i would like to know if the namespace is created is because i get an error message if i fire create pod before the namespace is actually created:</p>

<blockquote>
  <p>Error from server: error when creating "./pod.json": pods "my-pod" is
  forbidden: service account username/default was not found, retry after
  the service account is created</p>
</blockquote>

<p>The below works fine if i give a sleep of 5 seconds between create namespace and create pod command</p>

<blockquote>
  <p>kubectl delete namespace testnamepsace;kubectl create namespace
  testnamepsace;sleep 5;kubectl create -f ./pod.json
  --namespace=testnamepsace</p>
</blockquote>

<p>If i don't give the sleep of 5 seconds i see the error message mentioned above</p>