Docker Desktop for Windows and macOS come with the docker-desktop
cluster. I'm trying to figure out how to either copy it, or make a new cluster based on it as a template. I like to have clusters for each project I'm working on so that things like PVC, PV and secrets are isolated, and I can just switch between them with kubectl config use-context project1
. I've been looking through documentation and Google search results and haven't identified how to do this, or if it is possible. Any suggestions?
If there's a set of resources that you want to routinely deploy to new clusters, you can create a source-control repository that contains the YAML files you need. Then when you have a new cluster you can kubectl apply -f
your directory of bootstrap artifacts. Using kind, for example:
kind create cluster --name dev2
kubectl apply -f ./bootstrap/
...
kind delete cluster --name dev2
If you need to configure or parameterize this setup in some way, packaging it as a Helm chart can make sense.
This approach also means avoiding the imperative-style kubectl create
, kubectl run
, and kubectl expose
type commands. Create the YAML files you need, check them in, and use kubectl apply
to install them.
It can be a little tricky to usefully export a cluster, and this isn't something that's commonly done. For example, if you have a Pod, was it created by a Deployment or directly through a YAML file? Was that PersistentVolume hand-created, or did a provisioner create it, and are its settings specific to a particular Kubernetes environment? Working from a reproducible source-controlled tree avoids these issues.