How kgeorga/hello-minikube-ruby works
Main Components
• Ruby Application: Represented by the file helloworld.rb. This is the core web service that listens (in this case on port 8080) and returns a “Hello world” message with the pod’s IP.
• Docker Container: Created from the helloworld.dockerfile. This image encapsulates your Ruby application and ensures it runs in an isolated, portable environment.
• Kubernetes Deployment: Defined in helloworld-deployment.yaml. This describes the deployment of the Ruby app as 2 replica pods, ensuring the service is scalable and highly available.
• Kubernetes Service: Configured with helloworld-service.yaml. It load balances the incoming traffic across the pods and exposes the service on a specified external port (31000) on the Kubernetes node.
• Kubernetes Cluster (Minikube): The deployment runs within a local Minikube cluster, representing the underlying infrastructure that manages pods, services, and networking.
Relationships and Interactions
– The local Docker setup (adjusted using “eval $(minikube docker-env)”) builds the container image which is then consumed by the Kubernetes Deployment.
– The Deployment creates two pods running instances of your Ruby app.
– The Kubernetes Service acts as the front-facing component, receiving incoming network traffic (requests on port 31000) and forwarding them to the pods (internally, to port 8080 or port 80 as defined in the service YAML).
– External traffic (from a browser or curl command) is directed to the Minikube node IP at port 31000 and then load balanced across the pods.
Architectural Patterns and Design Principles
– Containerization: The use of Docker to package the application ensures consistency across environments.
– Declarative Infrastructure: Kubernetes YAML files (for deployment and service) facilitate repeatable, declarative deployments.
– Load Balancing: Kubernetes service abstracts the individual pods behind a single endpoint while managing the load distribution.
– Separation of Concerns: The application logic (Ruby code) is separated from deployment concerns (Docker and Kubernetes configurations).