kubectl Verified current stable Not installed? Kubernetes

Kubectl / Get Other Resources

Get Other Resources

Use kubectl to list various Kubernetes resources like PVCs and Secrets in your namespace.

$
Terminal
kubectl get <persistentvolumeclaims|secret|...>

When To Use

To audit resources in a namespace during security assessments.

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
NAME              STATUS   VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS   AGE
my-pvc           Bound    my-pv    10Gi       RWO            standard      5d

NAME              TYPE      DATA   AGE
my-secret        Opaque    1      5d

Power User Variants

Optimized versions

kubectl get persistentvolumeclaims

List all persistent volume claims in the current namespace.

kubectl get secrets

List all secrets in the current namespace.

Unix Pipeline

Shell combinations

kubectl get persistentvolumeclaims -n my-namespace

List PVCs in a specific namespace.

kubectl get secrets -o wide

List secrets with additional details.

Troubleshooting

Common pitfalls

Error from server (NotFound): persistentvolumeclaims "my-pvc" not found

Solution: Ensure the PVC name is correct and exists in the specified namespace.

Error from server (Forbidden): secrets is forbidden: User "system:serviceaccount:default:default" cannot list resource "secrets"

Solution: Check your permissions and ensure the user has access to list secrets.

Command Breakdown

What each part is doing

kubectl
Base Command
The executable that performs this operation. Here it runs Kubectl before the shell applies any redirect operators.
<persistentvolumeclaims|secret|...>
persistentvolumeclaims|secret|...
The value supplied for persistentvolumeclaims|secret|....

How To Run

Execution path

  1. Step 1

    Run `kubectl get persistentvolumeclaims` to list PVCs.

  2. Step 2

    Run `kubectl get secrets` to list Secrets in the namespace.

  3. Step 3

    Use `kubectl get <resource>` for other resource types.

Alternative Approaches

Comparable commands in other tools

Alternative kubernetes tools for the same job.