From ec758f0f0a5d3cb6a31bd7deef018da9fee6d1eb Mon Sep 17 00:00:00 2001 From: Johanan Liebermann Date: Fri, 10 Jan 2025 12:57:05 +0200 Subject: [PATCH] Add KubeVirt instructions to tilt.md Signed-off-by: Johanan Liebermann --- docs/book/src/developer/core/tilt.md | 103 +++++++++++++++++++++++---- 1 file changed, 91 insertions(+), 12 deletions(-) diff --git a/docs/book/src/developer/core/tilt.md b/docs/book/src/developer/core/tilt.md index 8e693e6a6d27..fa797ba9f7e3 100644 --- a/docs/book/src/developer/core/tilt.md +++ b/docs/book/src/developer/core/tilt.md @@ -8,26 +8,76 @@ workflow that offers easy deployments and rapid iterative builds. ## Prerequisites 1. [Docker](https://docs.docker.com/install/): v19.03 or newer (on MacOS e.g. via [Lima](https://github.com/lima-vm/lima)) -2. [kind](https://kind.sigs.k8s.io): v0.25.0 or newer -3. [Tilt](https://docs.tilt.dev/install.html): v0.30.8 or newer -4. [kustomize](https://github.com/kubernetes-sigs/kustomize): provided via `make kustomize` -5. [envsubst](https://github.com/drone/envsubst): provided via `make envsubst` -6. [helm](https://github.com/helm/helm): v3.7.1 or newer -7. Clone the [Cluster API](https://github.com/kubernetes-sigs/cluster-api) repository +1. [kind](https://kind.sigs.k8s.io): v0.25.0 or newer +1. [Tilt](https://docs.tilt.dev/install.html): v0.30.8 or newer +1. [kustomize](https://github.com/kubernetes-sigs/kustomize): provided via `make kustomize` +1. [envsubst](https://github.com/drone/envsubst): provided via `make envsubst` +1. [helm](https://github.com/helm/helm): v3.7.1 or newer +1. Clone the [Cluster API](https://github.com/kubernetes-sigs/cluster-api) repository locally -8. Clone the provider(s) you want to deploy locally as well +1. Clone the provider(s) you want to deploy locally as well ## Getting started ### Create a kind cluster -A script to create a KIND cluster along with a local Docker registry and the correct mounts to run CAPD is included in the hack/ folder. -To create a pre-configured cluster run: +The following CAPI infrastructure providers are suitable for local development: + +- [CAPD](https://github.com/kubernetes-sigs/cluster-api/blob/main/test/infrastructure/docker/README.md) - uses Docker containers as workload cluster nodes +- [CAPK](https://github.com/kubernetes-sigs/cluster-api-provider-kubevirt) - uses KubeVirt VMs as workload cluster nodes + +CAPD is the default as it's more lightweight and requires less setup. KubeVirt is useful when +Docker isn't suitable for whatever reason. + +{{#tabs name:"tab-management-cluster-creation" tabs:"Docker,KubeVirt"}} +{{#tab Docker}} + +To create a kind cluster with CAPD, run the following: + +```bash +make kind-cluster +``` + +{{#/tab }} +{{#tab KubeVirt}} + +To create a kind cluster with CAPD, run the following: ```bash -./hack/kind-install-for-capd.sh +make kind-cluster-kubevirt ``` + + + + +{{#/tab }} +{{#/tabs }} + You can see the status of the cluster with: ```bash @@ -36,7 +86,10 @@ kubectl cluster-info --context kind-capi-test ### Create a tilt-settings file -Next, create a `tilt-settings.yaml` file and place it in your local copy of `cluster-api`. Here is an example that uses the components from the CAPI repo: +Next, create a `tilt-settings.yaml` file and place it in your local copy of `cluster-api`. + +{{#tabs name:"tab-tilt-settings" tabs:"Docker,KubeVirt"}} +{{#tab Docker}} ```yaml default_registry: gcr.io/your-project-name-here @@ -46,7 +99,33 @@ enable_providers: - kubeadm-control-plane ``` -To use tilt to launch a provider with its own repo, using Cluster API Provider AWS here, `tilt-settings.yaml` should look like: +{{#/tab }} +{{#tab KubeVirt}} + +```yaml +enable_providers: +- kubevirt +- kubeadm-bootstrap +- kubeadm-control-plane +provider_repos: +# Path to a local clone of CAPK (replace with actual path) +- ../cluster-api-provider-kubevirt +kustomize_substitutions: + # CAPK needs access to the containerd socket (replace with actual path) + CRI_PATH: "/var/run/containerd/containerd.sock" + # An example - replace with an appropriate container disk image for the desired k8s version + NODE_VM_IMAGE_TEMPLATE: "quay.io/capk/ubuntu-2204-container-disk:v1.30.1" + KUBERNETES_VERSION: "v1.30.1" +# Allow deploying CAPK workload clusters from the Tilt UI +template_dirs: + kubevirt: + - ../cluster-api-provider-kubevirt/templates +``` + +{{#/tab }} +{{#/tabs }} + +Other infrastructure providers may be added to the cluster using local clones and a configuration similar to the following: ```yaml default_registry: gcr.io/your-project-name-here