How to deploy an application to Minikube?

0263

To deploy an application to Minikube, follow these steps:

  1. Start Minikube: First, ensure that Minikube is installed and start it with the following command:

    minikube start
    
  2. Create a Directory for Manifests: Create a directory to store your Kubernetes manifests:

    mkdir -p ~/project/k8s-manifests
    cd ~/project/k8s-manifests
    
  3. Create a Deployment YAML File: Create a new YAML file for your application deployment. For example, for an NGINX web server:

    nano nginx-deployment.yaml
    

    Add the following configuration to the file:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx-deployment
      labels:
        app: nginx
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx:latest
            ports:
            - containerPort: 80
    
  4. Apply the Deployment: Use the kubectl command to apply the deployment:

    kubectl apply -f nginx-deployment.yaml
    
  5. Expose the Deployment: To access the application, expose it as a service:

    kubectl expose deployment nginx-deployment --type=NodePort --port=80
    
  6. Access the Application: Get the URL to access your application:

    minikube service nginx-deployment --url
    

    This command will provide you with a URL that you can open in your web browser to access the deployed application.

By following these steps, you can successfully deploy an application to Minikube.

0 Comments

no data
Be the first to share your comment!