Kubernetes Commands You’ll Use Most in a VCF Job

This is a cheat sheet for basic k8s commands that vSphere Tanzu / VCF Automation admins can use daily.

Core Pod & Cluster Visibility

CommandDescription
kubectl get pods -AList all pods across all namespaces
kubectl get pods --all-namespacesSame as above; alternative syntax.
kubectl get pods -n <ansible-awx>Show pods within a namespace
kubectl get nodesView all nodes in the cluster.
kubectl describe pod <pod>View container state, logs

Debugging & Troubleshooting

CommandDescription
kubectl describe pod <pod>View container state, logs
kubectl exec -it <pod> -- /bin/bashOpen an interactive shell inside the pod
kubectl top podsView live CPU/memory usage per pod.
kubectl top nodesView resource usage across nodes.
kubectl logs <pod_name> -n <namespace_name>
View logs for a specific pod.
kubectl logs <pod_name> -n <namespace_name> -f Stream logs live.
kubectl delete pod <pod_name> -n <namespace_name>
Delete a pod

Deployment & Access

CommandDescription
kubectl apply -f <file>.yamlCreate or update resources from a YAML file
kubectl port-forward <pod> 8080:80Forward local port 8080 to pod port 80.
kubectl get svc -AView all services across namespaces
kubectl get ingress -AView all ingress rules (VCF often uses NSX ALB)

Namespace & Resource Management

CommandDescription
kubectl get nsList all namespaces.
kubectl get all -n <namespace>Show all resources in a namespace.
kubectl delete -f <file>.yamlDelete resources defined in a YAML file

Minikube Status (Quick Checks)

CommandDescription
minikube statusShow cluster, kubelet, apiserver, and host status
minikube dashboardLaunch the Kubernetes dashboard
minikube start --driver=dockerStart Minikube using Docker driver
minikube ipGet the Minikube node IP.
minikube dashboardLaunch the Kubernetes dashboard
minikube stopStop the cluster.
minikube deleteRemove the cluster completely.

MiniKube Status

awk@ansible:~$ minikube status
minikube
type: Control Plane
host: Stopped
kubelet: Stopped
apiserver: Stopped
kubeconfig: Stopped

Start Minikube

awk@ansible:~$ minikube start
* minikube v1.38.0 on Ubuntu 24.04
* Using the docker driver based on existing profile
* Starting "minikube" primary control-plane node in "minikube" cluster
* Pulling base image v0.0.49 ...
* Restarting existing docker container for "minikube" ...
! Failing to connect to https://registry.k8s.io/ from both inside the minikube container and host machine
* To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/
* Preparing Kubernetes v1.35.0 on Docker 29.2.0 ...
* Verifying Kubernetes components...
  - Using image registry.k8s.io/metrics-server/metrics-server:v0.8.0
  - Using image registry.k8s.io/ingress-nginx/controller:v1.14.1
  - Using image gcr.io/k8s-minikube/storage-provisioner:v5
  - Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v1.6.5
  - Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v1.6.5
* Verifying ingress addon...
* Enabled addons: storage-provisioner, metrics-server, default-storageclass, ingress

kubectl get pods -A

awk@ansible:~$ kubectl get pods -A
NAMESPACE       NAME                                              READY   STATUS      RESTARTS      AGE
ansible-awx     awx-operator-controller-manager-85d7499f5-rlmj5   2/2     Running     2 (16h ago)   24h
ansible-awx     awx-ubuntu-migration-24.6.0-kl4cp                 0/1     Completed   0             23h
ansible-awx     awx-ubuntu-postgres-15-0                          1/1     Running     1 (16h ago)   24h
ansible-awx     awx-ubuntu-task-6f5b675f6c-wd7n6                  4/4     Running     4 (16h ago)   23h
ansible-awx     awx-ubuntu-web-7569fb7b67-n8nnh                   3/3     Running     3 (16h ago)   23h
default         ee-shell-full                                     1/1     Running     0             4h14m
ingress-nginx   ingress-nginx-admission-create-25b7b              0/1     Completed   0             24h
ingress-nginx   ingress-nginx-admission-patch-2nvm6               0/1     Completed   0             24h
ingress-nginx   ingress-nginx-controller-8675c6b56f-r7qkd         1/1     Running     1 (16h ago)   24h
kube-system     coredns-7d764666f9-fl5t4                          1/1     Running     2 (16h ago)   24h
kube-system     etcd-minikube                                     1/1     Running     2 (16h ago)   24h
kube-system     kube-apiserver-minikube                           1/1     Running     2 (16h ago)   24h
kube-system     kube-controller-manager-minikube                  1/1     Running     2 (16h ago)   24h
kube-system     kube-proxy-tf29n                                  1/1     Running     2 (16h ago)   24h
kube-system     kube-scheduler-minikube                           1/1     Running     2 (16h ago)   24h
kube-system     metrics-server-5778bb4788-kpnr5                   1/1     Running     0             3h41m
kube-system     storage-provisioner                               1/1     Running     5 (16h ago)   24h


Check Ansible namespace

kubectl get pods -n ansible-awx

awk@ansible:~$ kubectl get pods -n ansible-awx
NAME                                              READY   STATUS      RESTARTS      AGE
awx-operator-controller-manager-85d7499f5-rlmj5   2/2     Running     2 (16h ago)   24h
awx-ubuntu-migration-24.6.0-kl4cp                 0/1     Completed   0             23h
awx-ubuntu-postgres-15-0                          1/1     Running     1 (16h ago)   24h
awx-ubuntu-task-6f5b675f6c-wd7n6                  4/4     Running     4 (16h ago)   23h
awx-ubuntu-web-7569fb7b67-n8nnh                   3/3     Running     3 (16h ago)   23h
awk@ansible:~$

Stream logs from a running container

wk@ansible:~$ kubectl describe pod ee-shell
Name:             ee-shell-full
Namespace:        default
Priority:         0
Service Account:  default
Node:             minikube/192.168.49.2
Start Time:       Fri, 31 Jan 2026 11:05:30 +0000
Labels:           <none>
Annotations:      <none>
Status:           Running
IP:               10.244.0.65
IPs:
  IP:  10.244.0.65
Containers:
  ee-shell-full:
    Container ID:  docker://8881a93b237e33bf50318f386ec8cfe9a1565445b4e392cfb2d3cbbeeed36249
    Image:         ubuntu:24.04
    Image ID:      docker-pullable://ubuntu@sha256:cd1dba651b3080c3686ecf4e3c4220f026b521fb76978881737d24f200828b2b
    Port:          <none>
    Host Port:     <none>
    Command:
      /bin/bash
      -c

Create a new project directory for AWX

In AWX, yaml files needs to created under this /var/lib/awx/projects and this needs to be done for both the task and web pods

kubectl exec awx-ubuntu-web-XXXX -n ansible-awx -- mkdir -p /var/lib/awx/projects/htop
kubectl exec awx-ubuntu-task-XXXX -n ansible-awx -- mkdir -p /var/lib/awx/projects/htop

Copy playbooks

kubectl cp htop.yaml ansible-awx/awx-ubuntu-web-7569fb7b67-n8nnh:/var/lib/awx/projects/nginxproject/nginx.yaml/
kubectl cp htop.yaml ansible-awx/awx-ubuntu-task-6f5b675f6c-wd7n6:/var/lib/awx/projects/nginxproject/nginx.yaml

Start a shell session inside the pod

kubectl exec -it awx-ubuntu-task-6f5b675f6c-wd7n6 -n ansible-awx -- /bin/bash
kubectl exec -it awx-ubuntu-web-7569fb7b67-n8nnh -n ansible-awx -- /bin/bash

See files in pod


kubectl exec awx-ubuntu-web-7569fb7b67-n8nnh -n ansible-awx -- ls -l /var/lib/awx/projects/htop
kubectl exec awx-ubuntu-task-6f5b675f6c-wd7n6 -n ansible-awx -- ls -l /var/lib/awx/projects/htop

remove files

kubectl exec awx-ubuntu-web-7569fb7b67-n8nnh -n ansible-awx -- rm /var/lib/awx/projects/nginxproject/nginx.yaml
kubectl exec awx-ubuntu-task-6f5b675f6c-wd7n6 -n ansible-awx -- rm /var/lib/awx/projects/nginxproject/nginx.yaml

Installing htop package over yaml in the usual way

ssh awk@172.16.11.122 "apt install htop; exit"
ssh awk@172.16.11.122 "apt list --installed | grep htop; exit"

Installing htop package over yaml via ansible

Define Playbook: Install htop.yml

awk@ansible:~/playbooks$ cat htop.yaml
---
- hosts: all
  become: yes
  become_user: root

  tasks:
    - name: Update apt cache
      ansible.builtin.apt:
        update_cache: true

    - name: Install htop
      ansible.builtin.apt:
        name: htop
        state: present
awk@ansible:~/playbooks$

Apply Changes, Scale, and Roll Back

View Live CPU and Memory Usage with kubectl top

# View resource usage for nodes
kubectl top node

awk@ansible:~$ kubectl top node
NAME       CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%
minikube   338m         16%    2869Mi          28%
awk@ansible:~$

View usage for pods in a namespace


awk@ansible:~$ kubectl top node -n ansible-awx
NAME       CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%
minikube   361m         18%    2868Mi          28%

(Visited 4 times, 1 visits today)

By Ash Thomas

Ash Thomas is a seasoned IT professional with extensive experience as a technical expert, complemented by a keen interest in blockchain technology.