This guide assumes the following:
docker
orpodman
installed and running.minikube
installed.
Throughout this guide, for any command x
, replace it with either docker
or podman
.
If using Podman and after installing all tooling from _macos/Brewfile
:
- Create VM in Podman desktop by completing the setup wizard.
- Install Minikube extension in Podman desktop (see here) by installing
ghcr.io/containers/podman-desktop-extension-minikube
from OCI image.
For full details, see
Using minikube
and targeting either Docker or Podman:
- Docker:
minikube start --driver=docker
- Podman:
minikube start --driver=podman --container-runtime=cri-o
Adding additional registries (required for e.g. linkerd if using Podman):
- Run
minikube ssh
to enter the Minikube VM. - Run
sudo vi /etc/containers/registries.conf
and add the following, which will help resolve short-name resolution issues (e.g.ImageInspectError
problems).
unqualified-search-registries = ["docker.io", "quay.io"]
minikube status
kubectl config current-context
cat ~/.minikube/machines/minikube/config.json
cat ~/.kube/config
Run cd templates/minikube
for the below commands to work.
- Build image with
x build -t gohello:latest .
- Tag image for deployment:
x tag gohello:latest docker.io/fredrikaverpil/gohello:0.0.1
.
There are several ways to push images to the Minikube cluster, see the official docs.
The easiest approach is to make docker build
or podman build
build images directly into the cluster. Run the following to set a series of environment variables which will tell Docker/Podman to build into the cluster:
eval $(minikube docker-env)
eval $(minikube podman-env)
- Go into Podman Desktop -> Images.
- Click the
:
button next to the image you want to push and choose "Push image to Minikube cluster".
This can be done on the commandline too, but is more involved. See details here.
- Log into docker.io:
x login docker.io
. - Push image to dockerhub:
x push docker.io/fredrikaverpil/gohello:0.0.1
.
Note: to push a multi-architecture container, it's easier to use docker's buildx:
docker buildx create --name mybuilder --use
docker buildx build --platform linux/amd64,linux/arm64 -t docker.io/fredrikaverpil/gohello:0.0.1 --push .
Using helm
:
- Install chart with
helm install gohello ./chart
.
Using kubectl
:
- Create pod with
kubectl apply -f ./\*.yaml
. - Verify pod with
kubectl get pods -n gohello
Using terraform
:
- Review deployment plan with
terraform plan
. - Create pod with
terraform apply
. - Verify pod with
kubectl get pods -n gohello
Using helm
:
- Not needed, as the chart already has a service configured. Access in browser by executing
minikube service gohello-svc -n gohello
.
Using k9s
:
- Run by providing namespace
k9s -n gohello
or by switching namespace in k9s by hiting:
followed bynamespaces
. - Find the gohello-container, hit
shift-f
and make it forward tolocalhost
on port8080
. - Access in browser:
http://localhost:8080/
- Remove the port-forward by hitting
f
. This will show all active port-forwards. Hitctrl+d
to remove the entry from the list.
Using kubectl
:
- Port-forward to pod with
kubectl port-forward pod/gohello-pod -n gohello 8080:9090
. - Access in browser:
http://localhost:8080/
Using k9s
:
- Run by providing namespace
k9s -n gohello
or by switching namespace in k9s by hiting:
followed bynamespaces
. - Find the gohello-container, hit
shift-l
to view logs.
Using kubectl
:
- View logs with
kubectl logs -n gohello gohello-pod
.
Using stern
:
- View logs with
stern -n gohello gohello-pod
.
Using helm
:
- Debug the helm chart with
helm template ./chart --debug
. - Lint the helm chart with
helm lint ./chart
Using k9s
:
- Run by providing namespace
k9s -n gohello
or by switching namespace in k9s by hiting:
followed bynamespaces
. - Find the gohello-container, hit
shift-d
to debug.
Using kubectl
:
- Debug with
kubectl debug -n gohello gohello-pod
.
Using helm
:
- Delete chart with
helm uninstall gohello
.
Using kubectl
:
- Delete pod with
kubectl delete -f ./\*.yaml
.
Using terraform
:
- Tear down everything:
terraform destroy
.
- Reset minikube cluster:
minikube stop && minikube delete && minikube start --driver=podman --container-runtime=cri-o
- Get minikube IP:
minikube ip
- Get minikube dashboard:
minikube dashboard
(enable metrics for more features:minikube addons enable metrics-server
) - Something is already running on port XXXX;
lsof -i :XXXX
andkill -9 <PID>
. - Remove cache of downloaded images from minikube:
minikube cache delete <image-name>
minikube cache delete --all
- Validate helm chart with
helm template ./chart --debug
.