Skip to content

Step-by-step tutorial on how to Dockerize a React web app and deploy it to a Kubernetes cluster managed by Oracle Cloud

Notifications You must be signed in to change notification settings

ironspur5/kubernetes-oci-react-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deploying a Dockerized React App to Kubernetes Cluster managed by Oracle Container Engine for Kubernetes (OKE)

Prerequisites

Step 1: Dockerize app

Build Docker image

$ cd ~/kubernetes-oci-react-app
$ docker build -t <your_name>/ocikubernetesapp .

Run image locally to make sure it works

$ docker run -d -p 3000:3000 <your_name>/ocikubernetesapp:latest

Open localhost:3000 to see running, then stop the container

$ docker ps
$ docker stop <CONTAINER ID>

Push image to Docker Hub

$ docker images
$ docker push <REPOSITORY>

Clean up local machine images and containers

$ docker rm $(docker ps -a -q)
$ docker rmi $(docker images -q)

Step 2: Create Kubernetes Cluster in OCI

Log into OCI dashboard and add following policy to your compartment

Allow service OKE to manage all-resources in tenancy

Go to Developer Services > Container Clusters (OKE) to create Kubernetes cluster

You can choose Quick Create or Custom Create; the only difference is that Custom assumes you have an existing network

Open cluster and click "Getting started" on the bottom left of the page to view instructions on how to connect to the cluster from your computer using kubectl

  • On you personal computer install Kubernetes Client (kubectl) CLI: $ brew install kubectl

Step 3: Deploy app to Kubernetes Cluster

Build a config file for the deployment of the image onto the cluster

$ kubectl create -f k8deployment.yaml --save-config

View Kubernetes deployments to see if the app was deployed to your cluster and see status

$ kubectl get deployments

View Kubernetes pods to verify pods/replicas are running

$ kubectl get pods

Verify logs in pod to see if the server for React app started

$ kubectl logs POD NAME

Expose cluster to the internet

$ kubectl expose deployment SERVICE NAME --type="LoadBalancer"

View your web app on the service by visiting http://EXTERNAL-IP:PORT

Closing Remarks

About

Step-by-step tutorial on how to Dockerize a React web app and deploy it to a Kubernetes cluster managed by Oracle Cloud

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published