Ensure that you are using the minikube docker context:
$ eval $(minikube docker-env)
Now you can build an image via docker and it will build in the minikube context:
$ docker build -t thing -f Dockerfile.thing .
$ kubectl run --image-pull-policy=Never --image=thing thing-deploy --port=8080
The --image-pull-policy=Never
is important, otherwise it will try
(and fail) to pull the thing
image and you’ll see ErrImagePull
when you do kubectl get pods -l run=thing
$ kubectl get deployments
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
thing-deploy 1 1 1 1 26m
$ kubectl get pods -l run=thing-deploy
NAME READY STATUS RESTARTS AGE
thing-deploy-57549c74bc-l5wk9 1/1 Running 0 27m
$ kubectl expose deployment thing-deploy --type=LoadBalancer
service "thing" exposed
$ kubectl get services
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes 10.96.0.1 <none> 443/TCP 16h
mathoid 10.102.202.109 <pending> 10044:31364/TCP 11s
Now the service is available through
$ minikube service thing --url
Logs are available for each pod through
$ kubectl get pods -l run=thing
NAME READY STATUS RESTARTS AGE
thing-57549c74bc-l5wk9 1/1 Running 0 27m
$ kubectl log -f thing-57549c74bc-l5wk9