From badc016461968b8e9c4e566575be67933db205dc Mon Sep 17 00:00:00 2001 From: Dmitry Volodin Date: Fri, 14 Feb 2025 18:03:24 +0300 Subject: [PATCH] :seedling: Utilize tilt-provider.yaml and Tilt deploy approach from the Cluster API --- Tiltfile | 34 ----------------------------- config/tilt/kustomization.yaml | 7 ++++++ docs/local-development.md | 39 ++++++++++++++++++++++++++++------ tilt-provider.yaml | 14 ++++++++++++ 4 files changed, 54 insertions(+), 40 deletions(-) delete mode 100644 Tiltfile create mode 100644 config/tilt/kustomization.yaml create mode 100644 tilt-provider.yaml diff --git a/Tiltfile b/Tiltfile deleted file mode 100644 index 06d26bda..00000000 --- a/Tiltfile +++ /dev/null @@ -1,34 +0,0 @@ -# -*- mode: Python -*- - -load('ext://cert_manager', 'deploy_cert_manager') - -def build_image(): - docker_build( - "gcr.io/k8s-staging-capi-operator/cluster-api-operator", - ".", - ignore=[ - ".git", - ".github", - "docs", - "test", - "scripts", - "*.md", - "LICENSE", - "OWNERS", - "OWNERS_ALIASES", - "PROJECT", - "SECURITY_CONTACTS" - ], - build_args = { - "builder_image": "docker.io/library/golang:1.23.0", - } - ) - -def deploy(): - k8s_yaml( - kustomize('./config/default') - ) - -build_image() -deploy_cert_manager() -deploy() diff --git a/config/tilt/kustomization.yaml b/config/tilt/kustomization.yaml new file mode 100644 index 00000000..2acf6c6d --- /dev/null +++ b/config/tilt/kustomization.yaml @@ -0,0 +1,7 @@ +resources: + - ../default + +labels: + - includeSelectors: false + pairs: + cluster.x-k8s.io/provider: capi-operator diff --git a/docs/local-development.md b/docs/local-development.md index ae98fd45..2070d009 100644 --- a/docs/local-development.md +++ b/docs/local-development.md @@ -1,16 +1,43 @@ # Local Development Tilt is favoured by most Cluster API projects for local development, it offers a simple way of creating a local development environment. +Cluster API includes its own Tiltfile that can be used to run Cluster API Operator on a local Kind cluster. + +## Clone the Cluster API repository + +Clone the Cluster API repository on the same level folder where Cluster API Operator located: -## Create a kind cluster -We'll need to create a kind cluster to deploy the operator to. This cluster will be used to deploy `cluster-api-operator` to, along with all dependencies such as `cert-manager` ```bash -kind create cluster +$ git clone https://github.com/kubernetes-sigs/cluster-api.git +``` + +Afterward your folder structure should look like this: + +``` +some-folder/ +├── cluster-api +└── cluster-api-operator +``` + +## Set up Tilt settings in `cluster-api` folder + +Refer to [this guide](https://cluster-api.sigs.k8s.io/developer/core/tilt.html) to set up Tilt for Cluster API. + +In particular, for our purposes we only need to set up `tilt-settings.yaml` in Cluster API to enable Cluster API Operator. Add the following fields to the lists in `tilt-settings.yaml`: + +```yaml +provider_repos: +- "../cluster-api-operator" +enable_providers: +- capi-operator +enable_core_provider: false ``` ## Run Tilt -Once the cluster is live, and you've confirmed you're using the correct context, you can simply run: + +From `cluster-api` folder run: + ```bash -tilt up +$ make tilt-up ``` -That's it! Tilt will automatically reload the deployment to your local cluster every time you make a code change. +That's it! Tilt will automatically reload the deployment to your local cluster every time you make a code change and able to debug deployed code. diff --git a/tilt-provider.yaml b/tilt-provider.yaml new file mode 100644 index 00000000..ee2f4be8 --- /dev/null +++ b/tilt-provider.yaml @@ -0,0 +1,14 @@ +name: capi-operator +config: + image: gcr.io/k8s-staging-capi-operator/cluster-api-operator + live_reload_deps: + - cmd + - go.mod + - go.sum + - api + - internal + - util + label: CAPIO + kustomize_folder: config/tilt + go_main: cmd/main.go + manager_name: capi-operator-controller-manager