This repository demonstrates a sample Kubernetes setup using Deployment, Service, Pod, and Ingress configurations. It provides various configurations to illustrate Kubernetes object management and networking.
- k8s-service-deployment: Contains a Deployment and Service configuration.
- k8s-service-deployment-pods: Adds a standalone Pod configuration in addition to Deployment and Service.
- k8s-service-deployment-pods-ingress: Extends previous configurations by adding Ingress to enable external HTTP/HTTPS access.
Each folder contains a README.md file with detailed explanations for each Kubernetes object and commands to apply and manage them.
Minikube is a tool that lets you run Kubernetes locally. Follow these steps to set up Minikube and deploy the sample application.
Follow the Minikube installation guide to install Minikube on your local machine.
Run the following command to start a local Kubernetes cluster:
minikube startThis command sets up a Kubernetes environment on your local machine.
In each configuration folder, apply the Deployment and Service configurations to deploy your application.
kubectl apply -f deployment.yaml
kubectl apply -f service.yamlUse the following commands to check the status of your deployments, pods, and services:
kubectl get deployments
kubectl get pods
kubectl get servicesIf you are using a LoadBalancer service type, Minikube provides an easy way to access your service:
minikube service <service-name>Replace <service-name> with the name of your service (e.g., sample-node-service). This command will open the service in your default web browser or provide a URL for manual access.
If you want to access the service on localhost instead, use port forwarding:
kubectl port-forward service/<service-name> 3000:80Now you can open http://localhost:3000 in your browser to access the application.
- Install Minikube and start the cluster.
- Navigate to the specific configuration folder (
k8s-service-deployment,k8s-service-deployment-pods,k8s-service-deployment-pods-ingress) as per your needs.
-
Apply Deployment and Service configurations:
kubectl apply -f deployment.yaml kubectl apply -f service.yaml
-
Check the Deployment Status:
kubectl get deployments kubectl get pods kubectl get services
If using LoadBalancer, access it through Minikube’s service command:
minikube service sample-node-serviceThis opens the application in your browser or provides a URL to check your application.
Expected Output:
You should see a message like:
Hello from Kubernetes Node App!
This confirms that your application is running successfully on Kubernetes.
To test the service on localhost, use:
kubectl port-forward service/sample-node-service 3000:80Then open http://localhost:3000 in your browser.
Let us know if you encounter any issues or need further customization!