Added support for different namespaces

Now we can deploy application in different namespaces using the "--namespace=<value>" flag with kompose up and kompose down. The --namepace flag will deploy the application in that particular "namespace" if exist."
This commit is contained in:
Abhishek
2017-04-12 18:40:32 +05:30
parent cba4c569a3
commit f41985a00e
5 changed files with 43 additions and 8 deletions
+15 -2
View File
@@ -640,11 +640,17 @@ func (k *Kubernetes) Deploy(komposeObject kobject.KomposeObject, opt kobject.Con
log.Info("We are going to create Kubernetes Deployments, Services" + pvcStr + "for your Dockerized application. " +
"If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead. \n")
client, namespace, err := k.GetKubernetesClient()
client, ns, err := k.GetKubernetesClient()
namespace := ns
if opt.IsNamespaceFlag {
namespace = opt.Namespace
}
if err != nil {
return err
}
log.Infof("Deploying application in %q namespace", namespace)
for _, v := range objects {
switch t := v.(type) {
case *extensions.Deployment:
@@ -700,12 +706,19 @@ func (k *Kubernetes) Undeploy(komposeObject kobject.KomposeObject, opt kobject.C
return errorList
}
client, namespace, err := k.GetKubernetesClient()
client, ns, err := k.GetKubernetesClient()
namespace := ns
if opt.IsNamespaceFlag {
namespace = opt.Namespace
}
if err != nil {
errorList = append(errorList, err)
return errorList
}
log.Infof("Deleting application in %q namespace", namespace)
for _, v := range objects {
label := labels.SelectorFromSet(labels.Set(map[string]string{transformer.Selector: v.(meta.Object).GetName()}))
options := api.ListOptions{LabelSelector: label}