Skip to content

Instantly share code, notes, and snippets.

@xmlking
Last active September 19, 2020 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xmlking/58050cc1835914e43767518c3a7b8b36 to your computer and use it in GitHub Desktop.
Save xmlking/58050cc1835914e43767518c3a7b8b36 to your computer and use it in GitHub Desktop.

Minikube

Setup

brew install hyperkit # not required if docker4mac is installed
brew install minikube
# To make hyperkit the default driver:
minikube config set vm-driver hyperkit
# Increasing memory allocation
minikube config set memory 8192
minikube config set cpus 4
minikube config set disk-size 4
minikube config set disk-size 30g
minikube config set iso-url https://raw.githubusercontent.com/cilium/minikube-iso/master/minikube.iso
# strat
minikube start
# with memory
#minikube start --memory=8192 --cpus=4
# with cri-o
minikube start --container-runtime=cri-o
# enabling feature gates
minikube start --feature-gates=EphemeralContainers=true
# stop
minikube stop
# if this command returns an error: `machine does not exist`
# you You need to clear minikube’s local state:
minikube delete

Reset minikube

minikube stop
minikube delete
minikube start --vm-driver=hyperkit --memory 8192 --cpus=4 --disk-size=20g --container-runtime=cri-o --feature-gates=EphemeralContainers=true

Start With Proxy

set HTTP_PROXY=http://<proxy hostname:port>
set HTTPS_PROXY=https://<proxy hostname:port>
set NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.99.0/24,192.168.39.0/24

minikube start
# with proxy
#minikube start --docker-env HTTP_PROXY=$YOUR_HTTP_PROXY HTTPS_PROXY=$YOUR_HTTPS_PROXY
#if your Virtual Machine address is 192.168.99.100, then chances are your proxy settings will prevent kubectl from directly reaching it. To by-pass proxy configuration for this IP address, you should modify your no_proxy settings. You can do so with:
export no_proxy=$no_proxy,$(minikube ip)

Addons

# list addons
minikube addons list
# disable addon
minikube addons disable registry
# How to use a private registry(GCR/ECR/Docker) within minikube
# https://minikube.sigs.k8s.io/docs/tasks/registry/private/
minikube addons configure registry-creds
minikube addons enable registry-creds

Env

# set minikube as context
kubectl config use-context minikube
# Run this command to configure your shell: to re-use the Docker daemon inside the Minikube instance.
eval $(minikube docker-env)

#with minikube`s docker, if you have to push images to Docker Hub, do this
docker push docker.io/xmlking/mymicro:v1.0.1

# To undo above docker setting in the current shell, run 
eval "$(docker-machine env -u)"

Maintenance

minikube config view

Ingress

I don't like tunnel

# Services of type LoadBalancer can be exposed via the minikube tunnel command. It will run until Ctrl-C is hit.
minikube tunnel
# Sometimes minikube does not clean up the tunnel network properly. To force a proper cleanup:
minikube tunnel --cleanup
# To access a service exposed via a node port, run this command in a shell after starting Minikube to get the address:
minikube service [-n NAMESPACE] [--url] NAME
# e.g., minikube service proxysrv
# to patch LoadBalancer externalIP
kubectl patch svc proxysrv -p '{"spec": {"type": "LoadBalancer", "externalIPs":["192.168.2.243"]}}'
# To access a private container registry, follow the steps

FAQ

By re-using the Docker registry inside Minikube, this becomes:

  • Build the Docker image using Minikube's Docker instance. This pushes the image to Minikube's Docker registry.
  • Set up your deployment in minikube to use the image.

Ref

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment