func (k *kubernetes) namespaceExists(name string) (bool, error) {
	if k.namespaces == nil {
		if logger.V(logger.DebugLevel, logger.DefaultLogger) {
			logger.Debugf("Populating namespace cache")
		}
		namespaceList := new(client.NamespaceList)
		resource := &client.Resource{Kind: "namespace", Value: namespaceList}
		if err := k.client.List(resource); err != nil {
			return false, err
		}
		if logger.V(logger.DebugLevel, logger.DefaultLogger) {
			logger.Debugf("Populated namespace cache successfully with %v items", len(namespaceList.Items))
		}
		k.namespaces = namespaceList.Items
	}
	for _, n := range k.namespaces {
		if n.Metadata.Name == name {
			return true, nil
		}
	}
	return false, nil
}
namespaceExists returns a boolean indicating if a namespace exists in the cache
package kubernetes
import (
	"strings"
	"github.com/micro/micro/v3/service/logger"
	"github.com/micro/micro/v3/service/runtime"
	"github.com/micro/micro/v3/service/runtime/kubernetes/client"
)
func (k *kubernetes) ensureNamepaceExists(ns string) error {
	namespace := client.Format(ns)
	if namespace == client.DefaultNamespace {
		return nil
	}
	exist, err := k.namespaceExists(namespace)
	if err == nil && exist {
		return nil
	}
	if err != nil {
		if logger.V(logger.WarnLevel, logger.DefaultLogger) {
			logger.Warnf("Error checking namespace %v exists: %v", namespace, err)
		}
		return err
	}
	if err := k.autoCreateNamespace(namespace); err != nil {
		if logger.V(logger.WarnLevel, logger.DefaultLogger) {
			logger.Warnf("Error creating namespace %v: %v", namespace, err)
		}
		return err
	}
	return nil
}