How to share a locally running application in Minikube with others using Kubernetes Services and Minikube tunnel command | By M. Sharma
To share your local running application in Minikube with others, you can expose your application using a Kubernetes Service and then use the Minikube tunnel command to make it accessible from outside the cluster. Here are the steps to follow:
- Create a Kubernetes Service: Use a Kubernetes Service to expose your application to the cluster. You can create a Service using a YAML file that specifies the Service type as “LoadBalancer” or “NodePort”.
For example, here’s a sample YAML file for a Service of type LoadBalancer:
apiVersion: v1
kind: Service
metadata:
name: my-app-service
spec:
type: LoadBalancer
selector:
app: my-app
ports:
- name: http
port: 80
targetPort: 8080- Apply the Service YAML file: Use the “kubectl apply” command to apply the YAML file and create the Service in the Minikube cluster.
- Get the external IP address: Use the “minikube service” command to get the external IP address of the Service. This command will open a browser window to the Service and display the external IP address in the terminal.
For example, to get the external IP address of the “my-app-service” Service, you can run the following command:
minikube service my-app-service- Share the external IP address: Share the external IP address with others so they can access your application from outside the cluster.
- Use the Minikube tunnel command: If the external IP address is not accessible from outside the cluster, you can use the “minikube tunnel” command to create a tunnel that allows external traffic to reach the Service.
For example, to create a tunnel for the “my-app-service” Service, you can run the following command:
minikube tunnel
After the tunnel is created, you can share the external IP address with others so they can access your application. Once they have the external IP address, they can access your application in a web browser by entering the IP address in the address bar.
Note: Keep in mind that exposing your application in this way makes it accessible to anyone with an external IP address. Be sure to secure your application appropriately to prevent unauthorized access.
Sharing a locally running application in Minikube with others can be useful for testing and demonstrating your application without having to deploy it to a remote environment. By using Kubernetes Services to expose your application, you can make it accessible from within the Minikube cluster. However, to access the application from outside the cluster, you’ll need to use the Minikube tunnel command to create a tunnel that allows external traffic to reach the Service.
The “LoadBalancer” type Service is commonly used to expose an application outside the cluster. This type of Service creates a cloud provider-specific load balancer to distribute traffic to the Service. When running in Minikube, a LoadBalancer Service creates a NodePort on the Minikube node that maps to the Service. The Minikube tunnel command creates a secure tunnel to the Minikube node, allowing external traffic to reach the NodePort and the Service.
Keep in mind that the Minikube tunnel command requires a network connection to the Minikube node. If you’re running Minikube on a local machine, you should be able to use the tunnel command without any issues. However, if you’re running Minikube on a remote machine, you’ll need to ensure that the machine is accessible from the network and that the necessary ports are open.
In summary, sharing a locally running application in Minikube with others using Kubernetes Services and the Minikube tunnel command is a convenient way to test and demonstrate your application without deploying it to a remote environment. However, it’s important to secure your application appropriately to prevent unauthorized access, and to ensure that the Minikube node is accessible from the network if using the tunnel command.







