1. List and Count Namespaces
You can view all namespaces in your cluster using:| Command | Description |
|---|---|
kubectl get namespaces | List all namespaces (full form) |
kubectl get ns | List all namespaces (short form) |
You can add
-o wide or use -o jsonpath to customize the output format.2. Count Pods in the research Namespace
To see how many pods are running in research:
3. Create a Pod in the finance Namespace
Deploy a Redis pod into finance:
4. Locate the blue Pod Across All Namespaces
To identify which namespace hosts the blue pod:
blue in marketing:
5. Service DNS Within the Same Namespace
Services in the same namespace can be reached by<service-name>:<port>. In marketing:
blue app connects to db-service on:
- Host:
db-service - Port:
6379

6. Service DNS Across Namespaces
Accessing a service in a different namespace (e.g.,dev) requires the full DNS name:
Always use the full DNS (
<svc>.<namespace>.svc.cluster.local) when connecting across namespaces to avoid resolution errors.