Cloud Guru React-to-Kubernetes Deploy Method

Take any containerisable front-end application from local development through Docker image creation to a live Kubernetes cluster deployment, step by step.

// TL;DR

The Cloud Guru React-to-Kubernetes Deploy Method is a step-by-step process for taking a working React (or Node.js) application from local development, through Docker image creation, to a live Kubernetes cluster deployment. Use it when you have a functioning local app and need a repeatable, production-ready pipeline that validates at each stage — bare metal, local container, cloud registry, then Kubernetes. It emphasizes consistent image tagging, matching ports between the Dockerfile and service, environment variables for credentials, and NodePort exposure for first deployments. Ideal for developers deploying to managed Kubernetes services like IBM Cloud.

// When should you use the Cloud Guru React-to-Kubernetes Deploy Method?

Use this skill whenever you need to deploy a web application (particularly a React/Node.js app) using Docker containers and Kubernetes orchestration. Trigger it when you have a working local app and need a repeatable, production-ready deployment pipeline.

// What inputs do you need to deploy a React app to Kubernetes?

  • Application source coderequired
    A React (or similar Node.js) application with a package.json and a Dockerfile already present in the repo
  • Docker usernamerequired
    Your Docker Hub username, used to tag and push images consistently throughout the process
  • External API keyrequired
    Any third-party API key the application depends on (e.g. an OMDB-style key); must be inserted into the actions/config file before build
  • Kubernetes namespacerequired
    An existing namespace in your Kubernetes cluster (create one first if this is your first deployment)
  • Kubernetes cluster namerequired
    The name of your target cluster, needed to retrieve the public worker IP
  • Cloud regionrequired
    The region code for your cloud provider's container registry (e.g. 'ng' for US South, 'eu' for Europe)

// What principles make a React-to-Kubernetes deployment reliable?

Run Locally First

Always validate the application works on bare metal before introducing containers. Catching issues like a missing API key at the local stage prevents compounding failures later in the pipeline.

Consistent Image Tagging

Every image name must follow the pattern <docker-username>/<image-name>:latest and that exact name must be used consistently across the Docker build, the cloud registry build, and the Kubernetes deployment command. Any mismatch breaks the pipeline.

Port Contract Between Dockerfile and Service

The port declared inside the Dockerfile (the EXPOSE instruction) and the port passed to 'kubectl expose' must match exactly. This is a hard contract — mismatches produce a silently broken service.

Environment Variable for Credentials

Export sensitive or reusable values (Docker username, API keys) as environment variables at the start of a session. Reference the variable throughout subsequent commands rather than hard-coding values, reducing transcription errors.

NodePort Before LoadBalancer

For initial deployments, expose the service as a NodePort. It surfaces the app via <PublicIP>:<NodePort> with minimal configuration. LoadBalancer is reserved for more complex, production-grade cases once you understand the cluster topology.

Cloud Registry for Cloud Kubernetes

When deploying to a managed Kubernetes service (e.g. IBM Cloud Kubernetes), you must rebuild the Docker image inside that provider's container registry — not just push a local image. The cluster pulls from its own registry ecosystem.

// How do you deploy a React app to Kubernetes step by step?

  1. 1

    Gather prerequisites

    Confirm Node.js is installed. Obtain any required third-party API key (e.g. from an external movie/data API provider). Have your Docker username and cloud provider credentials ready. Export your Docker username as an environment variable immediately: 'export DOCKER_USERNAME=<your-username>'. Do this before any other step — it is referenced in every subsequent build command.

  2. 2

    Clone the repository and install dependencies

    Clone the target repo and navigate into its directory. Run 'npm install' (or 'yarn') to install all node modules. While modules install, insert your API key into the application's actions/config file — this is the only place it needs to go. Do not skip this; running without a valid key will appear to work locally but return errors from the API.

  3. 3

    Build CSS and start the application locally

    Run 'npm run build:css' first to compile any preprocessed styles (e.g. Sass to CSS), then 'npm run start'. Open localhost in a browser and perform a live query to confirm the app returns real data. If you see an 'invalid API key' error, stop and fix the key in the actions file before proceeding — do not carry a broken key into Docker.

  4. 4

    Build the Docker image locally

    Run: 'docker build -t $DOCKER_USERNAME/<image-name>:latest .' — choose an image name that matches your repo name for clarity and keep it consistent throughout. The build process mirrors an npm build but packages the entire application into a container image. Expect deprecation warnings from older npm modules; these are non-fatal. Verify success with 'docker images' and confirm the new image appears in the list.

  5. 5

    Run and verify the Docker container locally

    Run the container: 'docker run -p <host-port>:<container-port> $DOCKER_USERNAME/<image-name>:latest'. Navigate to localhost:<host-port> and re-run a test query. Confirming the app works inside a container before pushing to the cloud is mandatory — it isolates environment issues from deployment issues.

  6. 6

    Authenticate with your cloud provider and confirm your Kubernetes namespace

    Log in to your cloud CLI (e.g. 'bx login' for IBM Cloud). Specify your region. List existing namespaces to confirm yours is available. If no namespace exists, create one now. Record your namespace string exactly — it is used in every registry command.

  7. 7

    Build the Docker image inside the cloud container registry

    Run the cloud-specific build command targeting your provider's container registry, substituting your namespace and region code. Format: 'bx cr build -t registry.<region>.bluemix.net/<namespace>/<image-name>:latest .' — This is NOT a push of the local image; it is a fresh build inside the cloud ecosystem. This step is required because managed Kubernetes clusters pull from their provider's own registry, not Docker Hub.

  8. 8

    Create the Kubernetes deployment

    Run: 'kubectl run <deployment-name> --image=registry.<region>.bluemix.net/<namespace>/<image-name>:latest'. The deployment name should be descriptive and match the image name pattern for traceability. Confirm the deployment is created with 'kubectl get deployments'.

  9. 9

    Expose the deployment as a NodePort service

    Run: 'kubectl expose deployment <deployment-name> --type=NodePort --name=<service-name> --port=<port>'. The port value MUST match the port declared in the Dockerfile. Use NodePort for initial deployments. Confirm the service is created with 'kubectl get services'.

  10. 10

    Retrieve the cluster public IP and service NodePort

    Get worker public IP: 'bx cs workers <cluster-name>' — copy the Public IP from the output. Get the NodePort: 'kubectl describe service <service-name>' — find the 'NodePort' field in the output. These two values combine to form your public URL.

  11. 11

    Access and validate the live application

    Navigate to '<PublicIP>:<NodePort>' in a browser. Run a live query to confirm end-to-end functionality. The application is now running on Kubernetes. If the page does not load, check that the port in 'kubectl expose' matches the Dockerfile EXPOSE value and that the correct worker IP was used.

// What does the React-to-Kubernetes deploy method look like in practice?

A developer has a React + Redux data-lookup app that calls a third-party JSON API. It works locally with npm start but needs to be accessible publicly on a managed Kubernetes cluster.

Export DOCKER_USERNAME. Insert the API key into the Redux actions file. Build locally with npm install → npm run build:css → npm run start to verify. Build local Docker image tagged as $DOCKER_USERNAME/data-lookup-app:latest, run it on localhost to confirm container works. Log into the cloud CLI, verify namespace exists. Re-build the image inside the cloud container registry using the registry URL with namespace and region. Create a kubectl deployment pointing to that registry image. Expose as NodePort on the port matching the Dockerfile. Retrieve worker public IP and NodePort from kubectl describe, then access <PublicIP>:<NodePort> to confirm live deployment.

A team member is deploying for the first time and has no Kubernetes namespace yet.

Before Step 7, run the cloud CLI namespace creation command to register a new namespace. Record the exact namespace string. Proceed with the registry build command substituting that new namespace. All subsequent kubectl commands reference the same image path with that namespace. Use NodePort (not LoadBalancer) since this is a first-time deployment — it requires no additional cloud networking configuration.

// What mistakes should you avoid when deploying React to Kubernetes?

  • Running the app without inserting a valid API key — the app will silently appear to work but return only error responses from the external API. Always test with a real key locally before building the Docker image.
  • Inconsistent image naming across steps — if the name used in 'docker build', the cloud registry build, and 'kubectl run' do not match exactly, the deployment will fail to pull the image. Use the $DOCKER_USERNAME environment variable throughout to enforce consistency.
  • Port mismatch between Dockerfile and kubectl expose — the port passed to 'kubectl expose --port' must be identical to the port declared with EXPOSE in the Dockerfile. A mismatch produces a service that appears healthy but is unreachable.
  • Pushing a local Docker Hub image to a cloud-managed Kubernetes cluster — managed Kubernetes services (e.g. IBM Cloud Kubernetes) pull from their own container registry. You must rebuild inside the cloud registry, not just push from Docker Hub.
  • Skipping the 'run locally' and 'run in Docker locally' validation steps — skipping these means environment or configuration bugs will only surface after a full cloud deployment, making them much harder to diagnose.
  • Forgetting to export DOCKER_USERNAME before building — if the environment variable is not set, build commands will produce malformed image tags that cannot be referenced consistently later.
  • Using LoadBalancer instead of NodePort for a first deployment — LoadBalancer requires additional cloud networking configuration and is harder to debug; NodePort is sufficient to validate the deployment and should be used first.

// What key terms do you need to know for Docker and Kubernetes deployment?

Code Pattern
IBM's term for a reference implementation — a deployable, documented sample application that demonstrates a specific architectural approach, intended to be cloned and adapted.
Container Registry
The cloud provider's private image repository (e.g. IBM Cloud Container Registry). Managed Kubernetes clusters pull images from this registry rather than from public Docker Hub, requiring images to be built or pushed here before deployment.
NodePort
A Kubernetes service type that exposes a deployment on a static port on each worker node's public IP. Accessed via <PublicIP>:<NodePort>. Preferred for initial deployments due to simplicity; contrasted with LoadBalancer for more complex production cases.
LoadBalancer
A Kubernetes service type that provisions an external load balancer through the cloud provider. More complex to configure than NodePort; recommended only after understanding the cluster topology.
kubectl expose
The Kubernetes CLI command that creates a Service object to make a deployment network-accessible. Requires specifying type (NodePort or LoadBalancer), service name, and port — which must match the Dockerfile EXPOSE value.
kubectl run
The Kubernetes CLI command that creates a Deployment, specifying the image to pull from the container registry and the deployment name.
bx cs workers
IBM Cloud CLI command to list the worker nodes of a Kubernetes cluster, including their public IP addresses — required to construct the public access URL.
Namespace (Kubernetes/Registry)
A scoping identifier used in both the cloud container registry path and the Kubernetes cluster. Must be created before first use and referenced consistently in all registry build and kubectl commands.
Actions (Redux)
The layer in a React-Redux architecture where external API calls are made. The API key is inserted here. Actions dispatch start, success, and error states to enable loading and error handling in the UI.
Containers vs Components (React pattern)
Containers hold application logic, state mapping, and callbacks. Components are purely presentational with no internal logic, making them reusable across the application.

// FREQUENTLY ASKED QUESTIONS

What is the Cloud Guru React-to-Kubernetes Deploy Method?

It's a step-by-step method for deploying a React or Node.js app from local development to a live Kubernetes cluster. You validate the app on bare metal, build and test a Docker image locally, rebuild inside your cloud provider's container registry, then create a Kubernetes deployment and expose it via NodePort. Each stage is verified before moving on to isolate bugs early.

What do I need before deploying a React app to Kubernetes?

You need the application source code with a package.json and Dockerfile, your Docker Hub username, any external API key the app depends on, an existing Kubernetes namespace, your cluster name, and your cloud region code. Export your Docker username as an environment variable first, and insert the API key into the app's config or actions file before building.

How do I deploy a React app with Docker and Kubernetes?

Run the app locally to confirm it works, build a Docker image tagged as username/image:latest, and test the container locally. Then authenticate with your cloud provider, rebuild the image inside its container registry, create a Kubernetes deployment pointing to that registry image, expose it as a NodePort service on the Dockerfile's port, and access it via the worker's public IP and NodePort.

How do I make sure my Docker image works before deploying to Kubernetes?

Run the container locally with 'docker run -p host-port:container-port username/image:latest' and navigate to localhost on that port. Re-run a live query against your app's API to confirm it returns real data inside the container. This isolates environment issues from deployment issues, so any bug you catch here won't resurface after a full cloud deployment.

Why do I have to rebuild my Docker image in the cloud registry instead of pushing from Docker Hub?

Managed Kubernetes services pull images from their own provider's container registry, not from public Docker Hub. You must run a cloud-specific build command like 'bx cr build -t registry.region.bluemix.net/namespace/image:latest .' This is a fresh build inside the cloud ecosystem, not a push of your local image. Skipping it causes the cluster to fail pulling your image.

How does this method compare to just pushing to Docker Hub and deploying?

Unlike a Docker Hub-only workflow, this method rebuilds inside the cloud provider's registry because managed Kubernetes clusters pull from their own registry ecosystem. It also enforces staged validation — bare metal, local container, then cloud — rather than deploying blind. The result is fewer silent failures and easier debugging, since bugs are caught at the earliest stage they appear.

When should I use NodePort instead of LoadBalancer in Kubernetes?

Use NodePort for initial and first-time deployments. It exposes your app via PublicIP:NodePort with minimal configuration and no extra cloud networking setup, making it easy to validate. Reserve LoadBalancer for production-grade cases once you understand your cluster topology, since it requires provisioning an external load balancer and additional configuration that's harder to debug.

When should I use the React-to-Kubernetes deploy method?

Use it whenever you have a working local web application — particularly a React or Node.js app — and need a repeatable, production-ready deployment pipeline using Docker containers and Kubernetes orchestration. It's ideal the moment you move from local development toward public, cluster-hosted deployment on a managed Kubernetes service.

What results can I expect after following this deployment method?

You'll have a live React application running on a Kubernetes cluster, accessible publicly via your worker node's public IP and NodePort. Because the method validates at each stage, you'll have confidence the app works on bare metal, inside a container, and in the cloud. The pipeline is repeatable, so future deployments follow the same consistent, documented steps.

Why does my Kubernetes service appear healthy but the app is unreachable?

Most often it's a port mismatch between your Dockerfile's EXPOSE instruction and the port passed to 'kubectl expose --port'. These must match exactly — it's a hard contract. A mismatch produces a service that looks healthy in 'kubectl get services' but is silently unreachable. Verify both ports are identical and confirm you're using the correct worker public IP.

What happens if my API key isn't set before deploying?

The app will appear to work but return only error responses from the external API. An invalid or missing API key fails silently at runtime, so always insert a real key into the app's config or actions file and test a live query locally before building the Docker image. Catching this at the local stage prevents compounding failures later.

// GET THIS SKILL — FREE

Use this skill in your AI

Every skill on SkillForge is free. Drop your email and copy this skill straight into Claude, ChatGPT, or any LLM.

We'll email you when new skills drop. Unsubscribe anytime.