This README outlines the steps to build, run, and deploy a simple "Hello World" web application using Docker and Kubernetes.
- Docker Desktop with Kubernetes enabled
- kubectl command-line tool (comes with Docker Desktop)
Navigate to the project directory and build your Docker image:
cd path/to/your/project
docker build -t hello-kubernetes .
Run your Docker image as a container, mapping the container's port to a port on your host:
docker run -p 4000:5000 hello-kubernetes
Access your application by navigating to http://localhost:4000 in your web browser.
When deploying to Kubernetes, it's best to use a new terminal window to keep your Docker container running.
Deploy your application to Kubernetes using the deployment configuration:
kubectl apply -f deployment.yaml
Expose your application outside of Kubernetes using the service configuration:
kubectl apply -f service.yaml
Since LoadBalancer might not work as expected on Docker Desktop, use port forwarding:
kubectl port-forward service/hello-kubernetes-service 8000:80
Access your application by navigating to http://localhost:8000 in your web browser.
When you are finished, delete the deployment:
kubectl delete deployment hello-kubernetes