Skip to content

Commit

Permalink
add print pod
Browse files Browse the repository at this point in the history
  • Loading branch information
ngtuna committed Nov 27, 2017
1 parent 89d8b87 commit 9d3f702
Showing 1 changed file with 35 additions and 10 deletions.
45 changes: 35 additions & 10 deletions cmd/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,21 @@ func isGKE(disco discovery.DiscoveryInterface) (bool, error) {
func printOutput(c *kubernetes.Clientset) error {
fmt.Printf("\nKubeapps has been deployed successfully. \n" +
"It may takes few minutes for all components to be ready. \n\n")

err := printSvc(c)
nss := []string{KubeappsNS, KubelessNS, SystemNS}
err := printSvc(c, nss)
if err != nil {
return err
}
err = printDeployment(c)
err = printDeployment(c, nss)
if err != nil {
return err
}
err = printStS(c)
err = printStS(c, nss)
if err != nil {
return err
}

err = printPod(c, nss)
if err != nil {
return err
}
Expand All @@ -186,13 +191,35 @@ func printOutput(c *kubernetes.Clientset) error {
return nil
}

func printStS(c *kubernetes.Clientset) error {
func printPod(c *kubernetes.Clientset, nss []string) error {
table := uitable.New()
table.MaxColWidth = 50
table.Wrap = true
table.AddRow("NAMESPACE", "NAME", "STATUS")
pods := []v1.Pod{}
for _, ns := range nss {
p, err := c.CoreV1().Pods(ns).List(metav1.ListOptions{
LabelSelector: "created-by=kubeapps",
})
if err != nil {
return err
}
pods = append(pods, p.Items...)
}
for _, p := range pods {
table.AddRow(p.Namespace, fmt.Sprintf("pod/%s", p.Name), p.Status.Phase)
}
fmt.Println(table)
fmt.Println()
return nil
}

func printStS(c *kubernetes.Clientset, nss []string) error {
table := uitable.New()
table.MaxColWidth = 50
table.Wrap = true
table.AddRow("NAMESPACE", "NAME", "DESIRED", "CURRENT")
sts := []v1beta1.StatefulSet{}
nss := []string{KubeappsNS, KubelessNS, SystemNS}
for _, ns := range nss {
s, err := c.AppsV1beta1().StatefulSets(ns).List(metav1.ListOptions{
LabelSelector: "created-by=kubeapps",
Expand All @@ -210,13 +237,12 @@ func printStS(c *kubernetes.Clientset) error {
return nil
}

func printDeployment(c *kubernetes.Clientset) error {
func printDeployment(c *kubernetes.Clientset, nss []string) error {
table := uitable.New()
table.MaxColWidth = 50
table.Wrap = true
table.AddRow("NAMESPACE", "NAME", "DESIRED", "CURRENT", "UP-TO-DATE", "AVAILABLE")
deps := []v1beta1.Deployment{}
nss := []string{KubeappsNS, KubelessNS, SystemNS}
for _, ns := range nss {
dep, err := c.AppsV1beta1().Deployments(ns).List(metav1.ListOptions{
LabelSelector: "created-by=kubeapps",
Expand All @@ -235,13 +261,12 @@ func printDeployment(c *kubernetes.Clientset) error {
return nil
}

func printSvc(c *kubernetes.Clientset) error {
func printSvc(c *kubernetes.Clientset, nss []string) error {
table := uitable.New()
table.MaxColWidth = 50
table.Wrap = true
table.AddRow("NAMESPACE", "NAME", "CLUSTER-IP", "EXTERNAL-IP", "PORT(S)")
svcs := []v1.Service{}
nss := []string{KubeappsNS, KubelessNS, SystemNS}
for _, ns := range nss {
svc, err := c.CoreV1().Services(ns).List(metav1.ListOptions{
LabelSelector: "created-by=kubeapps",
Expand Down

0 comments on commit 9d3f702

Please sign in to comment.