Frequently Asked Questions About Cloud Guru React-to-Kubernetes Deploy Method
23 answers covering everything from basics to advanced usage.
// Basics
What is a container registry and why does Kubernetes need one?
A container registry is a private image repository hosted by your cloud provider, like IBM Cloud Container Registry. Managed Kubernetes clusters pull images from this registry rather than public Docker Hub. That's why you rebuild your image inside the registry using a cloud-specific build command before creating a deployment — the cluster can only access images within its own registry ecosystem.
What is NodePort in Kubernetes?
NodePort is a Kubernetes service type that exposes your deployment on a static port across every worker node's public IP. You access the app via PublicIP:NodePort. It's preferred for initial deployments because it requires minimal configuration and no extra cloud networking setup, unlike LoadBalancer which provisions an external load balancer.
What is the difference between kubectl run and kubectl expose?
'kubectl run' creates a Deployment by specifying the image to pull from the container registry and the deployment name. 'kubectl expose' creates a Service that makes that deployment network-accessible, requiring a type (NodePort or LoadBalancer), a service name, and a port that must match the Dockerfile's EXPOSE value. You run first, then expose.
What are Redux actions and why does the API key go there?
In a React-Redux architecture, actions are the layer where external API calls are made and where they dispatch start, success, and error states for loading and error handling. Your third-party API key is inserted into the actions or config file because that's the single place the app reads it when making requests to the external API.
// How To
How do I export my Docker username as an environment variable?
Run 'export DOCKER_USERNAME=your-username' at the start of your session, before any build commands. Then reference $DOCKER_USERNAME in your docker build, run, and tagging commands instead of hard-coding the value. This enforces consistent image naming across every step and reduces transcription errors that would otherwise break the pipeline.
How do I build and test my Docker image locally?
Run 'docker build -t $DOCKER_USERNAME/image-name:latest .' using an image name that matches your repo. Verify with 'docker images' that it appears in the list. Then run 'docker run -p host-port:container-port $DOCKER_USERNAME/image-name:latest', open localhost on that port, and run a live query to confirm the app works inside the container before touching the cloud.
How do I find the public URL of my deployed app?
Get the worker's public IP with 'bx cs workers cluster-name' and copy the Public IP from the output. Get the NodePort with 'kubectl describe service service-name' and find the NodePort field. Combine them as PublicIP:NodePort and navigate there in a browser. Run a live query to confirm end-to-end functionality.
How do I create a Kubernetes namespace for a first deployment?
If you have no namespace yet, run your cloud CLI's namespace creation command before the registry build step. Record the exact namespace string, because it's used in every registry build command and every kubectl image path. After creating it, proceed with the registry build, substituting that namespace into the registry URL.
How do I build the Docker image inside the cloud container registry?
Run a cloud-specific build command like 'bx cr build -t registry.region.bluemix.net/namespace/image-name:latest .', substituting your region code and namespace. This is a fresh build inside the cloud registry, not a push of your local image. After it completes, your deployment can reference this registry path so the cluster pulls the image successfully.
// Troubleshooting
My Docker build shows deprecation warnings — is that a problem?
No. Deprecation warnings from older npm modules during the Docker build are non-fatal and expected. The build mirrors an npm build while packaging the full app into an image. Confirm success by checking that the new image appears in 'docker images'. Only treat the build as failed if it errors out, not merely warns.
My app works locally but returns errors after deployment — what's wrong?
The most common cause is a missing or invalid API key that wasn't inserted into the config or actions file before building. The app appears functional but returns only error responses from the external API. Fix the key locally, verify a live query returns real data, then rebuild the Docker image. Never carry a broken key into the pipeline.
My Kubernetes deployment can't pull the image — how do I fix it?
Check for inconsistent image naming across steps. The name in 'docker build', the cloud registry build, and 'kubectl run' must match exactly. Also confirm you rebuilt inside the cloud registry rather than relying on a Docker Hub image, since managed clusters pull from their own registry. Using $DOCKER_USERNAME throughout helps enforce consistency and prevent mismatches.
The service shows as created but the page won't load — what should I check?
First verify the port in 'kubectl expose --port' matches the Dockerfile's EXPOSE value exactly; a mismatch creates a healthy-looking but unreachable service. Then confirm you used the correct worker public IP from 'bx cs workers' and the right NodePort from 'kubectl describe service'. Both values must be accurate to form the working URL.
Why did my build commands produce malformed image tags?
You likely forgot to export DOCKER_USERNAME before building. If the environment variable isn't set, commands that reference $DOCKER_USERNAME produce malformed tags that can't be referenced consistently later. Export it first with 'export DOCKER_USERNAME=your-username', then re-run your build commands so the tags resolve correctly.
// Comparisons
How does NodePort compare to LoadBalancer for exposing a service?
NodePort exposes the app on a static port across worker nodes' public IPs with minimal setup, ideal for first deployments and validation. LoadBalancer provisions an external cloud load balancer, offering production-grade traffic distribution but requiring extra networking configuration that's harder to debug. Start with NodePort, then move to LoadBalancer once you understand your cluster topology.
How does this staged method compare to deploying straight to the cluster?
This method validates at four stages — bare metal, local container, cloud registry, and Kubernetes — rather than deploying blind. A straight-to-cluster approach defers all debugging to after deployment, where environment and config bugs are hardest to diagnose. Staged validation catches issues like missing API keys or port mismatches at the earliest point, saving significant troubleshooting time.
Is this method specific to IBM Cloud or does it work with other providers?
The principles are provider-agnostic, though the example commands use IBM Cloud CLI tools like 'bx cr build' and 'bx cs workers'. The core ideas — rebuild inside the provider's registry, match ports, use NodePort first, and validate at each stage — apply to any managed Kubernetes service. You'd swap in the equivalent registry build and worker-listing commands for your provider.
How does building in the cloud registry differ from a docker push?
A docker push uploads a pre-built local image to a registry. The cloud registry build command, like 'bx cr build', performs a fresh build inside the provider's registry ecosystem from your source. For managed Kubernetes, the registry build is required because the cluster pulls from its own registry and expects the image to exist there, not on Docker Hub.
// Advanced
How do I keep image names consistent across a complex pipeline?
Adopt the pattern docker-username/image-name:latest and use the $DOCKER_USERNAME environment variable everywhere. Choose an image name that matches your repo for clarity, and make your Kubernetes deployment name match that pattern too for traceability. Consistency across docker build, the registry build, and kubectl run is what prevents image-pull failures across the pipeline.
What is the port contract and why is it a hard requirement?
The port contract means the EXPOSE port in your Dockerfile and the port passed to 'kubectl expose --port' must be identical. It's a hard requirement because a mismatch produces a service that reports healthy but routes traffic to the wrong port, silently breaking reachability. Always confirm both values match before exposing the deployment.
How should I manage credentials when deploying to Kubernetes?
Export sensitive and reusable values like your Docker username and API keys as environment variables at the start of a session, then reference the variable rather than hard-coding values. This reduces transcription errors and keeps secrets out of repeated commands. For production, graduate to Kubernetes Secrets, but environment variables suffice for establishing a reliable initial pipeline.
What is a Code Pattern and how does it relate to this method?
A Code Pattern is IBM's term for a reference implementation — a deployable, documented sample app demonstrating a specific architectural approach, meant to be cloned and adapted. This method often starts from such a pattern: you clone the repo, insert your API key, and follow the Docker-to-Kubernetes pipeline to deploy your own adapted version.
When should I graduate from NodePort to a production-grade setup?
Move beyond NodePort once your deployment is validated and you understand your cluster topology. For production, adopt a LoadBalancer or Ingress for proper traffic routing and TLS, use Kubernetes Secrets for credentials, and define deployments declaratively in YAML rather than imperative kubectl commands. NodePort remains perfect for initial validation and learning the pipeline end to end.