This is a simple node.js backend api and react frontend hello world application. It is designed to be used as a starting point for learning how to containerize and deploy applications on kubernetes. In this project, are dockerfiles and the kubernetes deployment and service yaml files needed to run the application on Docker Desktop Kubernetes.
- Docker Desktop with Kubernetes enabled
- Node.js and npm installed
- Run
npm installfrom the root of the repository - To run in development mode (automatic restart on code change):
npm start- When run from the root of the repository this concurrently runs both the backend API and the front end
- To run in production mode:
npm run build && npm run serve- When run from the root of the repository this builds the UI static bundle and the concurrently runs the API and a static web server for the UI.
To build and scan code add container images fore both the API and the UI, simply run:
npm run portageConfiguration for running portage against both the API and the UI projects can be found in the .portage folder.
- Start Docker Desktop and make sure kubernetes is enabled
- Start the hello-world-k8s-api
kubectl apply -f api/deployment-api.yaml
- Start the hello-world-k8s-ui
kubectl apply -f ui/deployment-ui.yaml
- Start the hello-world-k8s-ui-service
kubectl apply -f ui/service-ui.yaml
- Start the hello-world-k8s-api-service
kubectl apply -f api/service-api.yaml
- Open your browser and navigate to http://localhost
- You should see the react logo and the hello world api response
- The hello-world-k8s-api is deployed as a pod in the helloworld namespace
- The hello-world-k8s-ui is deployed as a pod in the helloworld namespace