Quick-Start Guide
This is the quick-start guide that will assist you in spinning up a k2d instance and start consuming it.
Pre-requisites
To install and configure k2d
, the following pre-requisites must be met:
docker
server and client version23.0+
podman
version4.4.0+
kubectl
version1.26+
This is not required on the k2d host, just on your management PC
Install kubectl from https://kubernetes.io/docs/tasks/tools/
(optional)
helm
version3.10+
Hardware Requirements
ARM v7 CPU of 700MHhz or higher
512 MB RAM or higher
16GB SD-Card or greater
Upgrading from 1.0.0-alpha
The 1.0.0-beta build is not compatible with the 1.0.0-alpha build. If you used the 1.0.0-alpha on the system, make sure to remove resources that were created by k2d before using the instructions below.
These instructions will remove all the containers previously created by k2d and their associated data.
First, remove any existing k2d container:
Then you will need to remove all the containers that have been created by k2d previously:
Afterwards, remove any network created by k2d:
Finally, clean up the k2d data folder:
You can use the following one-liner to issue all the commands above at once:
Installation
The k2d image can run on the following platforms/archs: linux/amd64
, linux/arm64
, linux/386
, linux/armv6
and linux/armv7
.
The deployment of k2d
is based on a simple Docker run:
Use the
K2D_ADVERTISE_ADDR
only if you have multiple net interfaces at the OS levelThe
K2D_SECRET
is used as an authentication token to secure thek2d
API:If the
K2D_SECRET
environment variable is not set, it will be automatically generated, and you can retrieve it in thek2d
container logs
Use of the
host
network is not mandatory. Using thebridge
network is supported:K2D_ADVERTISE_ADDR
must be specified when using thebridge
networkDocker Desktop for Mac and Docker Desktop for Windows do not support the HOST network, so you must use the bridge network if testing on these platforms.
Use of the volume mounts is for:
The
/var/run/docker.sock
must be mounted to interact with the underlying Docker Engine serverThe
/var/lib/k2d
path must be persisted for:SSL certificates
Secrets
Configmaps
Kubernetes Token
Installation with Podman
For Podman to work with k2d, the Podman Socket first needs to be enabled:
Then, create the k2d directory under /var/lib
and change the owner to your user & group:
Finally, you can use the following command to run k2d with Podman in the rootless mode:
The following memory-related issues have arisen for CentOS 9:
crun: cannot set memory swappiness with cgroupv2
crun: write to /proc/self/oom_score_adj: Permission denied: OCI permission denied
It is recommended that CentOS 8 be run to avoid the problems listed above.
Installation with Docker via Snap
When Docker Engine is installed via Snap, due to its confinement, most of the underlying directories are set to read-only. Hence, amending the default k2d data path is required.
You can use the following command to run k2d with Docker installed via Snap:
Usage
The k2d
instance exposes an API endpoint to return a kubeconfig
format to start interacting with it:
Note: You must use the K2D_SECRET
to retrieve the config file successfully.
The output can be saved directly to your local ~/.kube/config
, or set KUBECONFIG
environment variable. You can treat it just like Kubernetes!
Now, use kubectl
to interact with the k2d
translator:
helm
will also be supported as long as the chart contains the resources supported by k2d
.
The List of Supported API Resources
To identify which Kubernetes API resources are supported by k2d
, you can run kubectl api-resources
to obtain the list:
Uninstall k2d
In order to uninstall k2d
, you can simply remove the k2d container:
To reset the system and remove all the resources that have been created by k2d and via k2d, you can use the following command:
This command will remove any workload and data that have been deployed through k2d.
With Podman
If you are using Podman, you can use the following instructions:
This command will remove any workload and data that have been deployed through k2d.
Last updated