How to expose service in Minikube?


by brock , in category: General Help , a month ago

How to expose service in Minikube?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by alysson_lynch , a month ago


To expose a service in Minikube, you can follow these steps:

  1. Start Minikube: minikube start
  2. Create a deployment and service: Deploy your application by creating a Deployment object in Kubernetes, and expose it by creating a Service object. For example, if you have a YAML file deployment.yaml that describes your deployment, and service.yaml that describes your service, you can create them using the kubectl command: kubectl create -f deployment.yaml kubectl create -f service.yaml Alternatively, you can create the deployment and service by running the following commands: kubectl create deployment my-app --image=my-app-image kubectl expose deployment my-app --type=NodePort --port=8080
  3. Get the URL to access your service: Minikube assigns a unique IP and port to each exposed service. To get the URL to access your service, run the following command: minikube service my-app --url This will display the URL in the console output.
  4. Access your service: Use the URL obtained from the previous step to access your service in a browser or through other HTTP clients.

Note: If you are working with a specific ingress controller or network load balancer, the steps to expose the service may vary. Make sure to check the documentation for the specific ingress controller or cloud provider you are using with Minikube.