Daniel's Tech Blog

Cloud Computing, Cloud Native & Kubernetes

Local Kubernetes setup with KinD on Podman

In one of my last blog posts I walked you through the setup how to run Podman on macOS with Multipass as Docker for Desktop alternative.

-> https://www.danielstechblog.io/running-podman-on-macos-with-multipass/

Today I briefly show you the local Kubernetes setup with KinD on Podman. Even the Podman support of KinD is in an experimental state it runs stable enough for the daily usage.

The setup I am running is the same I use with Docker for Desktop.

-> https://www.danielstechblog.io/local-kubernetes-setup-with-kind/
-> https://github.com/neumanndaniel/kubernetes/tree/master/kind

A tremendous difference between my Podman setup with Multipass and Docker for Desktop is the network access. KinD on Docker for Desktop uses the localhost interface 127.0.0.1 where Podman with Multipass has its own IP address from the bridge interface.

Therefore, I created a new setup script.

#!/bin/bash

brew install gsed

# Podman IP configuration
INSTANCE_NAME="podman"

IP=$(multipass info $INSTANCE_NAME | grep IPv4: | cut -d ':' -f2 | tr -ds ' ' '')

IP_CONFIG_EXISTS=$(cat /private/etc/hosts | grep -c "$IP")
if [[ $IP_CONFIG_EXISTS -eq 0 ]]; then
  echo "$IP $INSTANCE_NAME" | sudo tee -a /private/etc/hosts
fi

# Create KinD cluster
wget https://raw.githubusercontent.com/neumanndaniel/kubernetes/master/kind/single-node.yaml -O /tmp/single-node.yaml
gsed -i 's/127.0.0.1/'$IP'/g' /tmp/single-node.yaml
kind create cluster --config=/tmp/single-node.yaml

# Calico
kubectl create -f https://docs.projectcalico.org/manifests/tigera-operator.yaml
kubectl apply -f https://raw.githubusercontent.com/neumanndaniel/kubernetes/master/kind/calico-config.yaml

sleep 120

# Metrics Server
kubectl config set-context --current --namespace kube-system

helm repo add bitnami https://charts.bitnami.com/bitnami || true
helm repo update
helm upgrade metrics-server --install \
  --set apiService.create=true \
  --set extraArgs.kubelet-insecure-tls=true \
  --set extraArgs.kubelet-preferred-address-types=InternalIP \
  bitnami/metrics-server --namespace kube-system

First, the script installs GNU sed via brew. It reads then the IP address from the Multipass instance, downloads the KinD configuration, and replaces 127.0.0.1 with the IP. The instance name is also added to the host file. Afterwards the KinD single node gets instantiated with Calico and the metrics server enabled.

I went a step further and installed Istio with a sample application.

-> https://www.danielstechblog.io/running-istio-on-kind-kubernetes-in-docker/

istioctl install -f install-istio.yaml --skip-confirmation

The application is reachable under the instance name the script added earlier to the hosts file on the Mac.

Sample application

As always, you find the script on my GitHub repository.

-> https://github.com/neumanndaniel/scripts/blob/main/Bash/Podman/kind.sh

WordPress Cookie Notice by Real Cookie Banner