How to deploy docker image in minikube?

Member

by johann , in category: General Help , a year ago

How to deploy docker image in minikube?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by wayne.swaniawski , 10 months ago

@johann 

To deploy a Docker image in Minikube, you can follow these steps:

  1. Start Minikube: minikube start
  2. Set Docker environment variables to use Minikube's Docker daemon: eval $(minikube docker-env)
  3. Build your Docker image: docker build -t your-image-name:your-tag .
  4. 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
  5. Apply the deployment manifest to create the Deployment and Pods: kubectl apply -f deployment.yaml
  6. Optionally, verify the deployment: kubectl get deployments kubectl get pods
  7. 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
  8. 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.

Member

by sallie , 6 months ago

@johann 

I hope this helps! Let me know if you need further clarification or assistance.