Minikube and Helm Reference

August 5, 2021

These are my notes to remember how Minikube and Helm charts work for Kubernetes functionality.

Minikube

Minikube has a web based dashboard that's useful to see what's going on. Start it with:

$ minikube dashboard

Setup Minikube Docker Repository

This sets up docker commands so that they work with the minikube docker image repository, rather than the locally installed docker. This command specifies what environment variables need to be set to do this.

$ minikube docker-env

Helm

A helm chart can be installed from disk using:

$ helm install couchbase6 ./couchbase6

where the first parameter is the name, and the second is the directory that contains Chart.yaml and values.yaml.

To uninstall, use the name:

$ helm uninstall couchbase6

Kubernetes

To get the logs from a pod, use

$ kubectl logs couchbase6-deployment-ABC123 -p

where couchbase6-deployment-ABC123 is the name of the pod. The -p option allows you to see the results of a previous crashed pod.

To get logs from a job, use

$ kubectl logs -f jobs/job-name

Jobs can be listed with

$ kubectl get jobs

Get Prompt in Pod

To get a prompt onto a running pod use

$ kubectl exec --stdin --tty -c container_name pod_name -- /bin/bash

For some containers without bash that last command might need to be /bin/sh

Port Forwarding

It's possible to port forward to a particular pod. This is useful for proving that a service is working. To list pods:

$ kubectl get pods
NAME                              READY   STATUS    RESTARTS   AGE
bob-deployment-6b877bc7bc-pfsnz   1/1     Running   0          6m41s

I know from the definition of the Deployment that this pod is listening on port 8091. I can setup a local port forward directly to this pod:

$ kubectl port-forward bob-deployment-6b877bc7bc-pfsnz 7091:8091

Once this is running, I can access the service using http://localhost:7091 and this will connect to the pod's port 8091.

Using Kubernetes in Docker Desktop on Windows

As an alternative to using Minikube, Docker Desktop now has Kubernetes support, but it needs to be enabled. For more details see https://andrewlock.net/running-kubernetes-and-the-dashboard-with-docker-desktop/.

Once enabled, the Kubernetes dashboard can be installed with:

$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.3.1/aio/deploy/recommended.yaml

and run with

$ kubectl proxy

It can then be viewed at http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/workloads?namespace=default

It's also possible to use the normal Docker Desktop application to view running containers (pods, deployments, etc) and see logs and run prompts.