Deploy Your Programs in Minikube with Docker and Helm

 


Minikube is the perfect tool for learning how to make deployments in Kubernetes. All you need is a Docker (or similar) container or Virtual Machine environment, and you can have Kubernetes up and running with a single command: minikube start. 

Docker daemon in minikube doesn’t know about the Docker daemon on the Windows/Linux/macOS host. But there’s a simple solution for that - we can share the context using this command:

& minikube -p minikube docker-env --shell powershell | Invoke-Expression

Next, build your image:

docker build -t example-netcore-k8s .

In order to create a k8s deployment, we need a yaml file which specifies what should be deployed in minikube.

Now let's create the deployment using kubectl:

kubectl create -f deployment.yaml

Check if the deployment has suceeded:

kubectl get deployments

Check the pods:

kubectl get pods

In k8s and minikube as well, you must create a service to expose the application to a public IP/Port. If you're running your application in a managed k8s environment at your cloud provider of choice, the type of the service to expose your application is likely to be a LoadBalancer. When using minikube, the only service type available is nodePort.

The command to expose your application using a nodePort, is this:

kubectl expose deployment example-netcore-k8s --type=NodePort

To find at which IP and Port the application is exposed in minikube you must use this command:

minikube service example-netcore-k8s --url


Reacties

Populaire posts