Skip to content

Minikube deployment and service exposure

Minikube provides a local Kubernetes environment that allows users to deploy applications and test service exposure workflows.^[400-devops__06-Kubernetes__minikube.md]

Cluster Management

Minikube clusters are typically started using the minikube start command, which automatically configures kubectl to interact with the local cluster.^[400-devops__06-Kubernetes__minikube.md] The environment supports running multiple clusters or pausing clusters to preserve the state of deployed applications without consuming resources.^[400-devops__06-Kubernetes__minikube.md]

Deployment

Applications are deployed to the cluster using standard kubectl commands.^[400-devops__06-Kubernetes__minikube.md] For example, to create a deployment, one would run:

[kubectl](<./kubectl.md>) create deployment k8s02-minikube --image=docker.io/nginx:1.23

Following the creation of the deployment, it must be exposed to allow network access.^[400-devops__06-Kubernetes__minikube.md]

Service Exposure

To make a deployment accessible, it is exposed as a Kubernetes Service, often utilizing the NodePort type.^[400-devops__06-Kubernetes__minikube.md]

[kubectl](<./kubectl.md>) expose deployment k8s02-minikube --type=NodePort --port=80

You can verify the service status using kubectl get services.^[400-devops__06-Kubernetes__minikube.md]

Accessing Services

Minikube offers multiple methods to access the exposed service, providing flexibility for local development.^[400-devops__06-Kubernetes__minikube.md]

Direct Access

The simplest method is to use the minikube service command, which automatically configures the route and opens the application in a web browser.^[400-devops__06-Kubernetes__minikube.md]

[Minikube](<./minikube.md>) service k8s02-minikube

Port Forwarding

Alternatively, you can use kubectl to map a local port to the service port.^[400-devops__06-Kubernetes__minikube.md]

[kubectl port-forward](<./kubectl-port-forward.md>) service/k8s02-minikube 7080:80

This command makes the application available at http://localhost:7080/.^[400-devops__06-Kubernetes__minikube.md]

Sources

^[400-devops__06-Kubernetes__minikube.md]