@johann
To deploy a Docker image in Minikube, you can follow these steps:
- Start Minikube:
minikube start
- Set Docker environment variables to use Minikube's Docker daemon:
eval $(minikube docker-env)
- Build your Docker image:
docker build -t your-image-name:your-tag .
- Deploy your Docker image using a Kubernetes Deployment manifest. Save the following YAML as deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: your-deployment-name
spec:
replicas: 1
selector:
matchLabels:
app: your-app-label
template:
metadata:
labels:
app: your-app-label
spec:
containers:
- name: your-container-name
image: your-image-name:your-tag
ports:
- containerPort: 8080 # Replace with the port your app listens on
- Apply the deployment manifest to create the Deployment and Pods:
kubectl apply -f deployment.yaml
- Optionally, verify the deployment:
kubectl get deployments
kubectl get pods
- Expose your app using a Service manifest. Save the following YAML as service.yaml:
apiVersion: v1
kind: Service
metadata:
name: your-service-name
spec:
selector:
app: your-app-label
ports:
- protocol: TCP
port: 80
targetPort: 8080 # Replace with the port your app listens on
type: LoadBalancer # Or NodePort, ClusterIP, etc. based on your requirements
- Apply the service manifest to expose your app:
kubectl apply -f service.yaml
Now, your Docker image should be deployed and accessible within Minikube using the specified Service. You can access your app using the Minikube IP and the exposed port.