To deploy an application to Minikube, follow these steps:
Start Minikube: First, ensure that Minikube is installed and start it with the following command:
minikube startCreate a Directory for Manifests: Create a directory to store your Kubernetes manifests:
mkdir -p ~/project/k8s-manifests cd ~/project/k8s-manifestsCreate a Deployment YAML File: Create a new YAML file for your application deployment. For example, for an NGINX web server:
nano nginx-deployment.yamlAdd 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: 80Apply the Deployment: Use the
kubectlcommand to apply the deployment:kubectl apply -f nginx-deployment.yamlExpose the Deployment: To access the application, expose it as a service:
kubectl expose deployment nginx-deployment --type=NodePort --port=80Access the Application: Get the URL to access your application:
minikube service nginx-deployment --urlThis 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.
