Kubernetes: print namespace in helm status output

9/24/2019

In the output of helm status mychart, it show NAMESPACE in which chart is deployed that is NAMESPACE: default.

#=> helm status mychart
LAST DEPLOYED: Tue Sep 24 21:32:45 2019
NAMESPACE: default
STATUS: DEPLOYED
==> v1/Pod(related)
NAME                                     READY  STATUS   RESTARTS  AGE
nginx-web-stg-55f55958-v2cxm             0/1    Pending  0         28m
tomcat-api-stg-6d54498fdd-cqctr          1/1    Running  0         28m

and if I run kubectl get all -A, It show NAMESPACE along with resouces name-

#=> kubectl get all -A
NAMESPACE           NAME                             READY    STATUS  RESTARTS  AGE
nginx         pod/nginx-web-stg-55f55958-v2cxm        0/1     Pending    0      20m
tomcat        pod/tomcat-api-stg-6d54498fdd-cqctr     1/1     Running    0      20m

In the Kubectl output, column for NAMESPACE is included in output but not in helm status mychart. I wish to print resources along with NAMESPACE in helm status mychart output.

-- Ashish Kumar
kubernetes
kubernetes-helm

2 Answers

10/1/2019

Helm helps you manage Kubernetes applications — Helm Charts help you define, install, and upgrade even the most complex Kubernetes application.

The Kubernetes command-line tool, kubectl, allows you to run commands against Kubernetes clusters. You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs.

According to issue simply execute:

$ kubectl api-resources -o name | xargs -n 1 kubectl get --show-kind --ignore-not-found -l release=your-chart-name --all-namespaces

Sample output:

user@home:~$ kubectl api-resources  -o name   | xargs -n 1 kubectl get --show-kind --ignore-not-found -l release=terrific-ferret --all-namespaces

NAME                                 STATUS    MESSAGE              ERROR
componentstatus/scheduler            Healthy   ok
componentstatus/etcd-0               Healthy   {"health": "true"}
componentstatus/etcd-1               Healthy   {"health": "true"}
componentstatus/controller-manager   Healthy   ok
NAMESPACE   NAME                                   DATA   AGE
default     configmap/terrific-ferret-mysql-test   1      12m
NAMESPACE   NAME                              ENDPOINTS          AGE
default     endpoints/terrific-ferret-mysql   aa.bb.cc.dd:port   12m
NAMESPACE   NAME                                          STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
default     persistentvolumeclaim/terrific-ferret-mysql   Bound    pvc-896382d2   8Gi        RWO            standard       12m
NAMESPACE   NAME                                         READY   STATUS    RESTARTS   AGE
default     pod/terrific-ferret-mysql-86588b4646   1/1     Running   0          2m55s
NAMESPACE   NAME                           TYPE     DATA   AGE
default     secret/terrific-ferret-mysql   Opaque   2      13m
NAMESPACE   NAME                            TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
default     service/terrific-ferret-mysql   ClusterIP   xx.yy.zz.ww   <none>        3306/TCP   13m
NAMESPACE   NAME                                    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
default     deployment.apps/terrific-ferret-mysql   1         1         1            1           13m
NAMESPACE   NAME                                               DESIRED   CURRENT   READY   AGE
default     replicaset.apps/terrific-ferret-mysql-86  1         1         1       13m

We are using kubectl api-resources to list all supported resource types along with their shortnames.

Useful information you can find here: api-resources.

Useful blog: kubectlcheatsheet.

-- MaggieO
Source: StackOverflow

9/24/2019

The output formats of kubectl and helm are completely unrelated. I'm not aware that you can modify the output of helm status in any way to make it display the namespace with each resource.

-- weibeld
Source: StackOverflow