<p>I have a Kubernetes cluster and have a running container (X). From this container i want to create a new namespace, deploy a pod in this name space and spawn container(Y). I know kubernetes provides REST APIs. however, i am exploring goClient to do the same and not sure how to use namespace creation api.</p>

<pre><code>import (
    "github.com/golang/glog"
    "k8s.io/client-go/kubernetes"
    "k8s.io/kubernetes/pkg/api/v1"
    metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

clientConfig, err := config.createClientConfigFromFile()
if err != nil {
        glog.Fatalf("Failed to create a ClientConfig: %v. Exiting.", err)
}

clientset, err := clientset.NewForConfig(clientConfig)
if err != nil {
        glog.Fatalf("Failed to create a ClientSet: %v. Exiting.", err)
}

nsSpec := &amp;v1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: ns}}

_, err := clientset.Core().Namespaces().Create(nsSpec)
}
</code></pre>
