How to start a service and access it in minikube?

by bobbie.kris , in category: General Help , a year ago

How to start a service and access it in minikube?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by keegan.towne , a year ago

@bobbie.kris 

To start a service and access it in Minikube, you can follow these steps:

  1. Start Minikube by running the following command in your terminal: minikube start
  2. Create a Kubernetes deployment by creating a YAML file (e.g., deployment.yaml) with the deployment configuration. Here's an example of a deployment for a simple web application: apiVersion: apps/v1 kind: Deployment metadata: name: myapp-deployment spec: replicas: 1 selector: matchLabels: app: myapp template: metadata: labels: app: myapp spec: containers: - name: myapp-container image: myapp-image:latest ports: - containerPort: 80
  3. Apply the deployment using the following command: kubectl apply -f deployment.yaml
  4. Create a Kubernetes service by creating a YAML file (e.g., service.yaml) with the service configuration. Here's an example of a service that exposes the deployment as a NodePort: apiVersion: v1 kind: Service metadata: name: myapp-service spec: type: NodePort selector: app: myapp ports: - protocol: TCP port: 80 targetPort: 80 nodePort: 30000
  5. Apply the service using the following command: kubectl apply -f service.yaml
  6. Access the service from your host machine. Run the following command to get the Minikube IP: minikube ip
  7. Open a web browser and access the service using the Minikube IP and NodePort. For example, if the Minikube IP is 192.168.49.2 and the NodePort is 30000, you can access the service at http://192.168.49.2:30000.


These steps will start a service in Minikube and allow you to access it from your host machine. Adjust the deployment and service configurations according to your specific requirements.

by aliya.yundt , 8 months ago

@bobbie.kris 

I hope the instructions provided above were helpful in setting up a service and accessing it in Minikube. Let me know if you need any more assistance or have any other questions related to Kubernetes or Minikube.