diff --git a/cli/cluster.go b/cli/cluster.go index 1418d98..fcf614f 100644 --- a/cli/cluster.go +++ b/cli/cluster.go @@ -83,6 +83,7 @@ func (s SpreadCli) startLocalkube(c *cli.Context) { s.fatalf("Failed to start container: %v", err) } s.startLocalkube(c) + return } s.fatalf("Failed to create localkube container: %v", err) diff --git a/pkg/deploy/cluster.go b/pkg/deploy/cluster.go index 86aa166..0383367 100644 --- a/pkg/deploy/cluster.go +++ b/pkg/deploy/cluster.go @@ -22,8 +22,9 @@ const DefaultContext = "" // KubeCluster is able to deploy to Kubernetes clusters. This is a very simple implementation with no error recovery. type KubeCluster struct { - client *kubecli.Client - context string + client *kubecli.Client + context string + localkube bool } // NewKubeClusterFromContext creates a KubeCluster using a Kubernetes client with the configuration of the given context. @@ -60,8 +61,9 @@ func NewKubeClusterFromContext(name string) (*KubeCluster, error) { } return &KubeCluster{ - client: client, - context: name, + client: client, + context: name, + localkube: name == "localkube", }, nil } @@ -106,7 +108,7 @@ func (c *KubeCluster) Deploy(dep *Deployment, update, deleteModifiedPods bool) e } } - printLoadBalancers(c.client, dep.services) + printLoadBalancers(c.client, dep.services, c.localkube) // deployed successfully return nil @@ -332,7 +334,7 @@ func copyImmutables(src, dst KubeObject) { } } -func printLoadBalancers(client *kubecli.Client, services []*kube.Service) { +func printLoadBalancers(client *kubecli.Client, services []*kube.Service, localkube bool) { if len(services) == 0 { return } @@ -367,6 +369,13 @@ func printLoadBalancers(client *kubecli.Client, services []*kube.Service) { fmt.Printf("Error getting service `%s`: %v\n", s.Name, err) } + if localkube { + completed[s.Name] = true + for _, port := range clusterVers.Spec.Ports { + fmt.Printf("'%s/%s' - %s available on localkube host port:\t %d\n", s.Namespace, s.Name, port.Name, port.NodePort) + } + } + loadBalancers := clusterVers.Status.LoadBalancer.Ingress if len(loadBalancers) == 1 { completed[s.Name] = true