Skip to content

Commit

Permalink
Merge pull request #107 from ethernetdan/localkube-nodeports
Browse files Browse the repository at this point in the history
display NodePorts while deploying with localkube
  • Loading branch information
ethernetdan committed Mar 20, 2016
2 parents 3c6e813 + 885e014 commit 6a0b54a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions cli/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
21 changes: 15 additions & 6 deletions pkg/deploy/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -60,8 +61,9 @@ func NewKubeClusterFromContext(name string) (*KubeCluster, error) {
}

return &KubeCluster{
client: client,
context: name,
client: client,
context: name,
localkube: name == "localkube",
}, nil
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6a0b54a

Please sign in to comment.