@bobbie.kris
To start a service and access it in Minikube, you can follow these steps:
- Start Minikube by running the following command in your terminal:
minikube start
- 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
- Apply the deployment using the following command:
kubectl apply -f deployment.yaml
- 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
- Apply the service using the following command:
kubectl apply -f service.yaml
- Access the service from your host machine. Run the following command to get the Minikube IP:
minikube ip
- 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.