Skip to content

kubectl Basics

This guide assumes the Helm release and namespace are both named flow-like. Replace either name if your installation uses different values; chart resource names are derived from the Helm release.

Terminal window
kubectl config current-context
kubectl config get-contexts
kubectl cluster-info
kubectl get namespace flow-like

Set the namespace on the current context if you do not want to repeat -n flow-like:

Terminal window
kubectl config set-context --current --namespace=flow-like

This changes your local kubeconfig context, not the cluster resources.

Terminal window
kubectl get deployment,statefulset,job,cronjob,pod,service,pvc,hpa -n flow-like
kubectl get events -n flow-like --sort-by=.lastTimestamp

With default chart values, expect:

ResourceDefault form
APIDeployment and ClusterIP Service
Web appDeployment and ClusterIP Service
Executor poolDeployment and ClusterIP Service
RedisSingle-replica Deployment, Service named flow-like-redis-master, and optional PVC
Internal CockroachDBSingle-replica StatefulSet plus headless and public Services
Database migrationJob
CompilerDisabled unless configured
HPAsAbsent unless autoscaling is enabled

Use labels when Pod names include generated hashes:

Terminal window
kubectl get pods -n flow-like \
-l app.kubernetes.io/component=api \
-o wide

For details and recent events:

Terminal window
kubectl describe deployment flow-like-api -n flow-like
kubectl describe pod <pod-name> -n flow-like

kubectl top pods -n flow-like requires the cluster metrics API, commonly provided by Metrics Server.

Terminal window
kubectl port-forward service/flow-like-api 8083:8080 -n flow-like

In another terminal:

Terminal window
curl -fsS http://localhost:8083/health/ready
curl -fsS http://localhost:8083/api/v1/health

The command parts are:

PartMeaning
service/flow-like-apiKubernetes resource receiving the forwarded connection
first 8083Local port
second 8080Service port inside the cluster
-n flow-likeNamespace containing the Service

The port forward lasts only while the command is running.

Forward the internal CockroachDB Admin UI to localhost:

Terminal window
kubectl port-forward service/flow-like-cockroachdb-public 8084:8080 -n flow-like

Open http://localhost:8084. Keep database and metrics interfaces bound to localhost; do not publish them through an unauthenticated Ingress.

Terminal window
# Recent API logs
kubectl logs deployment/flow-like-api -n flow-like --tail=100
# Follow API logs
kubectl logs deployment/flow-like-api -n flow-like --follow
# Logs from a specific Pod and container
kubectl logs <pod-name> -c <container-name> -n flow-like
# Previous container instance after a restart
kubectl logs <pod-name> -c <container-name> -n flow-like --previous

List container names before selecting one:

Terminal window
kubectl get pod <pod-name> -n flow-like \
-o jsonpath='{.spec.containers[*].name}'
Terminal window
kubectl rollout restart deployment/flow-like-api -n flow-like
kubectl rollout status deployment/flow-like-api -n flow-like
kubectl rollout history deployment/flow-like-api -n flow-like

A rollout restart changes live cluster state and briefly replaces Pods. Check readiness and logs after it completes.

Terminal window
kubectl get pods -n flow-like
kubectl describe pod <pod-name> -n flow-like
kubectl logs <pod-name> -n flow-like --tail=200
kubectl logs <pod-name> -n flow-like --previous --tail=200
StatusFirst checks
PendingScheduling events, resource requests, PVC binding, node selectors
ImagePullBackOffImage name/tag, pull policy, registry credentials
CrashLoopBackOffCurrent and previous logs, environment references, probes
Running but not readyReadiness probe, dependencies, Service endpoints

Check which Pods back the API Service:

Terminal window
kubectl get endpointslice -n flow-like \
-l kubernetes.io/service-name=flow-like-api
Terminal window
kubectl run flow-like-debug \
--image=curlimages/curl \
--restart=Never \
--rm -it \
-n flow-like \
-- sh

Inside the temporary Pod:

Terminal window
curl -fsS http://flow-like-api:8080/health/ready
curl -fsS http://flow-like-api:8080/api/v1/health/db

The Pod is deleted when the interactive session exits.

List names and metadata:

Terminal window
kubectl get configmap,secret -n flow-like
kubectl describe configmap flow-like-sink-config -n flow-like
kubectl describe secret flow-like-storage -n flow-like

kubectl describe secret shows key names and sizes without printing secret values. Avoid -o yaml, JSONPath decoding, shell tracing, or screenshots when handling production Secrets.

Check which environment sources the API Pod references without resolving their values:

Terminal window
kubectl get deployment flow-like-api -n flow-like \
-o jsonpath='{.spec.template.spec.containers[0].envFrom[*].secretRef.name}'

When api.autoscaling.enabled=false:

Terminal window
kubectl scale deployment/flow-like-api --replicas=3 -n flow-like
kubectl rollout status deployment/flow-like-api -n flow-like

Manual scale changes can be overwritten by a later Helm upgrade. Record the intended count in api.replicaCount.

When autoscaling is enabled:

Terminal window
kubectl get hpa flow-like-api -n flow-like
kubectl describe hpa flow-like-api -n flow-like

Let the HPA own the replica count and adjust the chart’s autoscaling values instead of repeatedly using kubectl scale.

From the repository root:

Terminal window
# Inspect the installed release
helm status flow-like -n flow-like
helm get values flow-like -n flow-like
helm history flow-like -n flow-like
# Apply checked-in chart changes and your private values
helm upgrade --install flow-like apps/backend/kubernetes/helm \
-n flow-like \
--create-namespace \
-f values.yaml
# Roll back to a known revision
helm rollback flow-like <revision> -n flow-like

Keep credentials in an existing Secret or an ignored secrets-values file. Review rendered changes before applying them to a production cluster.

TaskCommand
List workloadskubectl get deploy,sts,job,cronjob,pod -n flow-like
Recent eventskubectl get events -n flow-like --sort-by=.lastTimestamp
API logskubectl logs deploy/flow-like-api -n flow-like --tail=100
API port forwardkubectl port-forward svc/flow-like-api 8083:8080 -n flow-like
API rolloutkubectl rollout status deploy/flow-like-api -n flow-like
Describe a Podkubectl describe pod <pod-name> -n flow-like
List Service backendskubectl get endpointslice -n flow-like