A simple React and Express stack running on Kubernetes and Docker Compose
https://kubernetes.github.io/ingress-nginx/
ingress-nginx
namespacekubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.34.1/deploy/static/provider/cloud/deploy.yaml
The client was created with npx create-react-app client
. The .git
and node_module
folders were deleted. App
was modified to load a value from an Express endpoint on componentDidMount()
with Axios.
To build and push the client image to Docker Hub, run
docker build client -t neutonfoo/client
docker push neutonfoo/client
The server was created with only a bare package.json
file serving a single endpoint /api/value
.
To build and push the server image to Docker Hub, run
docker build server -t neutonfoo/server
docker push neutonfoo/server
To run this application with Docker Compose, simply run docker-compose up --build
and docker-compose down
when you’re done. With Docker Compose, an nginx server is used as a reverse proxy direct traffic to either the nginx server hosting the client, or the Express server API.
To run this application in Kubernetes, you will have to have NGINX Ingress Controller
installed (above). This nginx Ingress server is used instead of the nginx reverse proxy in the Docker Compose deployment.
kubectl apply -f k8s
kubectl delete -f k8s
kubectl delete namespace ingress-nginx