avatarMohit Sharma

Summary

The website content provides a step-by-step guide on how to expose and share a locally running application within Minikube with others using Kubernetes Services and the Minikube tunnel command.

Abstract

The article by M. Sharma explains the process of making a locally run application in Minikube accessible to others. It involves creating a Kubernetes Service with a type of either "LoadBalancer" or "NodePort" to expose the application within the cluster. The external IP address for the service can be obtained using the minikube service command, which can then be shared with others. If direct access to the external IP is restricted, the minikube tunnel command can be used to create a secure tunnel allowing external traffic to reach the service. The author emphasizes the importance of securing the application to prevent unauthorized access and notes that the Minikube tunnel command requires network access to the Minikube node, which may be different for local or remote setups.

Opinions

  • The author suggests that using Kubernetes Services to expose an application is a convenient method for testing and demonstration purposes.
  • The use of a "LoadBalancer" type Service is recommended for distributing traffic to the application outside the cluster.
  • A reminder is given that exposing an application publicly requires appropriate security measures to be in place.
  • The Minikube tunnel command is presented as a solution for accessing the application from outside the cluster when the external IP is not directly accessible.
  • The article implies that sharing a locally running application in Minikube is a practical alternative to deploying it to a remote environment for certain use cases.

How to share a locally running application in Minikube with others using Kubernetes Services and Minikube tunnel command | By M. Sharma

Photo by frank mckenna on Unsplash

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:

  1. 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
  1. Apply the Service YAML file: Use the “kubectl apply” command to apply the YAML file and create the Service in the Minikube cluster.
  2. 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
  1. Share the external IP address: Share the external IP address with others so they can access your application from outside the cluster.
  2. 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.

👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇

🚀Join FAUN Developer Community & Get Similar Stories in your Inbox Each Week

Minikube
Container
Tunnel
Medium
Trends
Recommended from ReadMedium