kubectl Basics
This guide covers the essential kubectl commands you’ll need to manage Flow-Like on Kubernetes. No prior Kubernetes experience required.
What is kubectl?
Section titled “What is kubectl?”kubectl (pronounced “kube-control” or “kube-cuddle”) is the command-line tool for interacting with Kubernetes clusters. Think of it as your remote control for the cluster.
Connecting to Your Cluster
Section titled “Connecting to Your Cluster”Check Connection
Section titled “Check Connection”# See which cluster you're connected tokubectl config current-context
# List all available clusterskubectl config get-contexts
# Switch to a different clusterkubectl config use-context <context-name>Verify Access
Section titled “Verify Access”# List all namespaces (should show 'flow-like')kubectl get namespaces
# If you don't see flow-like, you may need to install it firstWorking with Namespaces
Section titled “Working with Namespaces”Flow-Like runs in its own namespace called flow-like. Always specify -n flow-like or set it as your default.
# Set flow-like as your default namespacekubectl config set-context --current --namespace=flow-like
# Now you don't need -n flow-like every timekubectl get pods # Same as: kubectl get pods -n flow-likeViewing Resources
Section titled “Viewing Resources”List All Flow-Like Components
Section titled “List All Flow-Like Components”# All pods (running containers)kubectl get pods -n flow-like
# All services (network endpoints)kubectl get services -n flow-like
# All deployments (manages pods)kubectl get deployments -n flow-like
# Everything at oncekubectl get all -n flow-likeExample Output
Section titled “Example Output”NAME READY STATUS RESTARTS AGEpod/flow-like-api-7d4b8c9f5-abc12 1/1 Running 0 2hpod/flow-like-api-7d4b8c9f5-def34 1/1 Running 0 2hpod/flow-like-executor-pool-6ddf4bdc5-x1 1/1 Running 0 2hpod/flow-like-cockroachdb-0 1/1 Running 0 2hpod/flow-like-redis-master-0 1/1 Running 0 2h
NAME TYPE CLUSTER-IP PORT(S)service/flow-like-api ClusterIP 10.43.100.50 8080/TCPservice/flow-like-cockroachdb ClusterIP 10.43.100.51 26257/TCPservice/flow-like-redis ClusterIP 10.43.100.52 6379/TCPDetailed Information
Section titled “Detailed Information”# Describe a specific pod (shows events and config)kubectl describe pod <pod-name> -n flow-like
# Describe the API deploymentkubectl describe deployment flow-like-api -n flow-like
# See resource usage (CPU/memory)kubectl top pods -n flow-likeAccessing the API
Section titled “Accessing the API”Port Forwarding (Development)
Section titled “Port Forwarding (Development)”Port forwarding creates a tunnel from your local machine to a service in the cluster.
# Forward local port 8083 to the API service port 8080kubectl port-forward svc/flow-like-api 8083:8080 -n flow-like
# Now open another terminal and test:curl http://localhost:8083/api/v1/healthPort Forwarding Breakdown
Section titled “Port Forwarding Breakdown”kubectl port-forward svc/flow-like-api 8083:8080 -n flow-like │ │ │ │ │ │ │ └─ Namespace │ │ └─ Service port (inside cluster) │ └─ Your local port └─ Service nameOther Services You Might Access
Section titled “Other Services You Might Access”# CockroachDB Admin UI (port 8080)kubectl port-forward svc/flow-like-cockroachdb 8084:8080 -n flow-like# Open http://localhost:8084
# Redis (port 6379)kubectl port-forward svc/flow-like-redis-master 6379:6379 -n flow-likeViewing Logs
Section titled “Viewing Logs”Basic Log Commands
Section titled “Basic Log Commands”# Logs from the API (last 100 lines)kubectl logs deployment/flow-like-api -n flow-like --tail=100
# Follow logs in real-time (like tail -f)kubectl logs deployment/flow-like-api -n flow-like -f
# Logs from a specific podkubectl logs flow-like-api-7d4b8c9f5-abc12 -n flow-likeWhen There Are Multiple Containers
Section titled “When There Are Multiple Containers”# List containers in a podkubectl get pod <pod-name> -n flow-like -o jsonpath='{.spec.containers[*].name}'
# Logs from a specific containerkubectl logs <pod-name> -c <container-name> -n flow-likeView Previous Logs (after restart)
Section titled “View Previous Logs (after restart)”# Logs from the previous container instancekubectl logs deployment/flow-like-api -n flow-like --previousRestarting Services
Section titled “Restarting Services”Restart a Deployment
Section titled “Restart a Deployment”# Graceful restart (rolling)kubectl rollout restart deployment/flow-like-api -n flow-like
# Watch the restart progresskubectl rollout status deployment/flow-like-api -n flow-likeDelete a Pod (Kubernetes recreates it)
Section titled “Delete a Pod (Kubernetes recreates it)”# Force a specific pod to restartkubectl delete pod flow-like-api-7d4b8c9f5-abc12 -n flow-like
# Kubernetes automatically creates a new pod to replace itDebugging Problems
Section titled “Debugging Problems”Check Pod Status
Section titled “Check Pod Status”# Quick overviewkubectl get pods -n flow-like
# Common statuses:# Running - Everything is good# Pending - Waiting for resources# CrashLoopBackOff - Container keeps crashing# ImagePullBackOff - Can't download the container image# Error - Container exited with errorInvestigate a Failing Pod
Section titled “Investigate a Failing Pod”# See events and conditionskubectl describe pod <pod-name> -n flow-like
# Look at the end for "Events:" section# Common issues:# - FailedScheduling: Not enough CPU/memory# - ImagePullBackOff: Wrong image name or no access# - CrashLoopBackOff: Check logs for errorsShell Into a Running Container
Section titled “Shell Into a Running Container”# Open a shell inside the API containerkubectl exec -it deployment/flow-like-api -n flow-like -- /bin/sh
# Run a single commandkubectl exec deployment/flow-like-api -n flow-like -- cat /app/config.yamlTest from Inside the Cluster
Section titled “Test from Inside the Cluster”# Create a temporary debug podkubectl run debug --image=curlimages/curl -it --rm -n flow-like -- sh
# Inside the pod, test internal services:curl http://flow-like-api:8080/api/v1/healthcurl http://flow-like-cockroachdb:26257Configuration and Secrets
Section titled “Configuration and Secrets”View ConfigMaps
Section titled “View ConfigMaps”# List all configmapskubectl get configmaps -n flow-like
# View a specific configmapkubectl describe configmap flow-like-api -n flow-like
# Get the raw datakubectl get configmap flow-like-api -n flow-like -o yamlView Secrets (names only for security)
Section titled “View Secrets (names only for security)”# List secretskubectl get secrets -n flow-like
# View secret structure (values are base64 encoded)kubectl get secret flow-like-storage -n flow-like -o yamlDecode a Secret Value
Section titled “Decode a Secret Value”# Get and decode a specific valuekubectl get secret flow-like-storage -n flow-like \ -o jsonpath='{.data.access-key-id}' | base64 -dScaling
Section titled “Scaling”Manual Scaling
Section titled “Manual Scaling”# Scale API to 5 replicaskubectl scale deployment/flow-like-api --replicas=5 -n flow-like
# Scale down to 1 replicakubectl scale deployment/flow-like-api --replicas=1 -n flow-likeCheck Autoscaler
Section titled “Check Autoscaler”# View horizontal pod autoscalerkubectl get hpa -n flow-like
# Detailed autoscaler statuskubectl describe hpa flow-like-api -n flow-likeHelm Commands
Section titled “Helm Commands”Helm is used to install and upgrade Flow-Like.
# List installed releaseshelm list -n flow-like
# View current valueshelm get values flow-like -n flow-like
# Upgrade with new valueshelm upgrade flow-like ./helm -n flow-like -f values.yaml
# Rollback to previous versionhelm rollback flow-like -n flow-like
# Uninstallhelm uninstall flow-like -n flow-likeQuick Reference Card
Section titled “Quick Reference Card”| Task | Command |
|---|---|
| List pods | kubectl get pods -n flow-like |
| View logs | kubectl logs deploy/flow-like-api -n flow-like |
| Follow logs | kubectl logs deploy/flow-like-api -n flow-like -f |
| Port forward | kubectl port-forward svc/flow-like-api 8083:8080 -n flow-like |
| Restart | kubectl rollout restart deploy/flow-like-api -n flow-like |
| Describe | kubectl describe pod <name> -n flow-like |
| Shell access | kubectl exec -it deploy/flow-like-api -n flow-like -- sh |
| Scale | kubectl scale deploy/flow-like-api --replicas=3 -n flow-like |
Common Issues
Section titled “Common Issues””No resources found”
Section titled “”No resources found””- Check if you’re in the right namespace:
-n flow-like - Check if Flow-Like is installed:
helm list -n flow-like
”Connection refused”
Section titled “”Connection refused””- Pod might not be running:
kubectl get pods -n flow-like - Wrong port: Check
kubectl get svc -n flow-like
”Pod stuck in Pending”
Section titled “”Pod stuck in Pending””- Not enough resources:
kubectl describe pod <name> -n flow-like - Check cluster capacity:
kubectl top nodes
”CrashLoopBackOff”
Section titled “”CrashLoopBackOff””- Application is crashing. Check logs:
kubectl logs <pod> -n flow-like - Check previous logs:
kubectl logs <pod> -n flow-like --previous
Next Steps
Section titled “Next Steps”- API Reference — All available endpoints
- Configuration — Environment variables
- Local Development — Using k3d