Skip to content

Instantly share code, notes, and snippets.

@thcipriani
Last active July 28, 2019 10:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thcipriani/1ec848d6c707b2e36d1b17825fc02996 to your computer and use it in GitHub Desktop.
Save thcipriani/1ec848d6c707b2e36d1b17825fc02996 to your computer and use it in GitHub Desktop.

Minikube raw notes

Make a docker container to run on minikube

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 .

Deploy newly built image on minikube

Create deployment

$ 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

Check deployment

$ kubectl get deployments
NAME           DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE                                                                                                               
thing-deploy   1         1         1            1           26m 

Check deployment pods

$ kubectl get pods -l run=thing-deploy
NAME                            READY     STATUS    RESTARTS   AGE                                                                                                            
thing-deploy-57549c74bc-l5wk9   1/1       Running   0          27m 

Expose a deployment via a service

$ 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment