# Kubernetes tip 5: Handy scripts I use in AKS

Sometimes I just want quick visibility into what is running in a namespace, so here are a few scripts I use often.

**1. Get build numbers for pods in a namespace**

```bash
kubectl get pods -o custom-columns="Name:metadata.name,Build:metadata.annotations.azure-pipelines/build-number" -n test
```

**2. List container images in a namespace**

```bash
kubectl get pods -n test -o jsonpath="{.items[*].spec.containers[*].image}" | \
tr -s '[[:space:]]' '\n' | \
sort | \
uniq -c
```

**3. Check CPU and memory requests/limits**

```bash
kubectl get pods -o custom-columns="Name:metadata.name,CPU-limit:spec.containers[*].resources.limits.cpu,CPU-request:spec.containers[*].resources.requests.cpu,Memory-limit:spec.containers[*].resources.limits.memory,Memory-request:spec.containers[*].resources.requests.memory" -n test
```

You can turn any of these into a script, apply `chmod +x`, and save the output to a file with:

```bash
./script.sh > output.txt
```

![AKS resource overview terminal screenshot](https://images.koorevaar.com/linkedin-import/aks-handy-scripts-tip-5.jpg)

---

*Co-authored with Claude.*

If this was useful, [you can buy me a coffee](https://ko-fi.com/p47k0).

New articles: [follow via RSS](https://blog.koorevaar.com/feed.xml).
