func listNamespaces(labelKey, labelValue string) (*v1.NamespaceList, error) {
	selector := labels.Set{labelKey: labelValue}.AsSelector()
	listOptions := api.ListOptions{FieldSelector: fields.Everything(), LabelSelector: selector}
	list, err := client.Namespaces().List(listOptions)
	if err != nil {
		log.Println("[listServices] Error listing namespaces", err)
		return nil, err
	}
	if len(list.Items) == 0 {
		log.Println("[listServices] No namespaces could be found: labelKey: ", labelKey, " labelValue: ", labelValue)
	}
	return list, nil
}
listNamespaces by label
package main
import (
	"encoding/json"
	"log"
	"net/http"
	"k8s.io/client-go/1.4/pkg/api"
	"k8s.io/client-go/1.4/pkg/api/v1"
	"k8s.io/client-go/1.4/pkg/fields"
	"k8s.io/client-go/1.4/pkg/labels"
)
func createNamespace(name string) error {
	m := make(map[string]string)
	m["deployedBy"] = "emmie"
	ns := &v1.Namespace{
		ObjectMeta: v1.ObjectMeta{Name: name, Labels: m},
	}
	_, err := client.Core().Namespaces().Create(ns)
	if err != nil {
		log.Println("[createNamespace] Error creating namespace", err)
		return err
	}
	return err
}