From eb956ca299b1741b95e7ca054c517c528ca15e79 Mon Sep 17 00:00:00 2001 From: Danil-Grigorev Date: Mon, 25 Nov 2024 13:38:40 +0100 Subject: [PATCH] Install turtles in a dev-env as opposed to upstream operator Signed-off-by: Danil-Grigorev --- Tiltfile | 11 ++++++++++- config/capiproviders/bootstrap.yaml | 7 +++++++ config/capiproviders/controlplane.yaml | 7 +++++++ config/capiproviders/core.yaml | 6 ++++++ config/capiproviders/docker.yaml | 6 ++++++ config/capiproviders/kustomization.yaml | 5 +++++ scripts/turtles-dev.sh | 25 +++++-------------------- tilt-settings.json.example | 5 ----- tilt/project/Tiltfile | 15 +++++++++++++++ 9 files changed, 61 insertions(+), 26 deletions(-) create mode 100644 config/capiproviders/bootstrap.yaml create mode 100644 config/capiproviders/controlplane.yaml create mode 100644 config/capiproviders/core.yaml create mode 100644 config/capiproviders/docker.yaml create mode 100644 config/capiproviders/kustomization.yaml diff --git a/Tiltfile b/Tiltfile index ce05bcdd..384499d0 100644 --- a/Tiltfile +++ b/Tiltfile @@ -35,7 +35,7 @@ if settings.get("trigger_mode") == "manual": if settings.get("default_registry") != "": default_registry(settings.get("default_registry")) -always_enable_projects = ["turtles", "turtles-etcdsnapshotrestore"] +always_enable_projects = ["turtles", "turtles-etcdsnapshotrestore", "turtles-capiproviders"] projects = { "turtles": { @@ -63,6 +63,15 @@ projects = { ], "kustomize_dir": "config/default", "label": "turtles-etcdsnapshotrestore" + }, + "turtles-capiproviders": { + "context": ".", + "live_reload_deps": [ + "config" + ], + "kustomize_dir": "config/capiproviders", + "label": "turtles-capiproviders", + "op": "apply" } } diff --git a/config/capiproviders/bootstrap.yaml b/config/capiproviders/bootstrap.yaml new file mode 100644 index 00000000..d4065d5a --- /dev/null +++ b/config/capiproviders/bootstrap.yaml @@ -0,0 +1,7 @@ +apiVersion: turtles-capi.cattle.io/v1alpha1 +kind: CAPIProvider +metadata: + name: rke2-bootstrap +spec: + type: bootstrap + name: rke2 \ No newline at end of file diff --git a/config/capiproviders/controlplane.yaml b/config/capiproviders/controlplane.yaml new file mode 100644 index 00000000..0f65bd03 --- /dev/null +++ b/config/capiproviders/controlplane.yaml @@ -0,0 +1,7 @@ +apiVersion: turtles-capi.cattle.io/v1alpha1 +kind: CAPIProvider +metadata: + name: rke2-control-plane +spec: + type: controlPlane + name: rke2 \ No newline at end of file diff --git a/config/capiproviders/core.yaml b/config/capiproviders/core.yaml new file mode 100644 index 00000000..2956a306 --- /dev/null +++ b/config/capiproviders/core.yaml @@ -0,0 +1,6 @@ +apiVersion: turtles-capi.cattle.io/v1alpha1 +kind: CAPIProvider +metadata: + name: cluster-api +spec: + type: core \ No newline at end of file diff --git a/config/capiproviders/docker.yaml b/config/capiproviders/docker.yaml new file mode 100644 index 00000000..825a86f8 --- /dev/null +++ b/config/capiproviders/docker.yaml @@ -0,0 +1,6 @@ +apiVersion: turtles-capi.cattle.io/v1alpha1 +kind: CAPIProvider +metadata: + name: docker +spec: + type: infrastructure \ No newline at end of file diff --git a/config/capiproviders/kustomization.yaml b/config/capiproviders/kustomization.yaml new file mode 100644 index 00000000..993e9b11 --- /dev/null +++ b/config/capiproviders/kustomization.yaml @@ -0,0 +1,5 @@ +resources: +- core.yaml +- docker.yaml +- bootstrap.yaml +- controlplane.yaml diff --git a/scripts/turtles-dev.sh b/scripts/turtles-dev.sh index 81979a87..895b9c2c 100755 --- a/scripts/turtles-dev.sh +++ b/scripts/turtles-dev.sh @@ -43,19 +43,6 @@ helm install cert-manager jetstack/cert-manager \ --create-namespace \ --set crds.enabled=true -export EXP_CLUSTER_RESOURCE_SET=true -export CLUSTER_TOPOLOGY=true - -helm install capi-operator capi-operator/cluster-api-operator \ - --create-namespace -n capi-operator-system \ - --set infrastructure=docker:v1.7.7 \ - --set core=cluster-api:v1.7.7 \ - --set controlPlane=rke2:v0.8.0 \ - --set bootstrap=rke2:v0.8.0 \ - --timeout 90s --wait - -kubectl rollout status deployment capi-operator-cluster-api-operator -n capi-operator-system --timeout=180s - helm upgrade ngrok ngrok/kubernetes-ingress-controller \ --install \ --wait \ @@ -71,8 +58,6 @@ helm install rancher rancher-latest/rancher \ --set bootstrapPassword=rancheradmin \ --set replicas=1 \ --set hostname="$RANCHER_HOSTNAME" \ - --set 'extraEnv[0].name=CATTLE_FEATURES' \ - --set 'extraEnv[0].value=embedded-cluster-api=false' \ --version="$RANCHER_VERSION" \ --wait @@ -93,9 +78,9 @@ install_local_rancher_turtles_chart() { kind load docker-image $ETCD_CONTROLLER_IMAGE:$ETCD_CONTROLLER_IMAGE_TAG --name $CLUSTER_NAME # Install the Rancher Turtles using a local chart with 'etcd-snapshot-restore' feature flag enabled # to run etcdrestore controller - helm install rancher-turtles out/charts/rancher-turtles \ + helm upgrade --install rancher-turtles out/charts/rancher-turtles \ -n rancher-turtles-system \ - --set cluster-api-operator.enabled=false \ + --set cluster-api-operator.enabled=true \ --set cluster-api-operator.cluster-api.enabled=false \ --set rancherTurtles.features.etcd-snapshot-restore.enabled=true \ --dependency-update \ @@ -103,10 +88,10 @@ install_local_rancher_turtles_chart() { --timeout 180s } +echo "Installing local Rancher Turtles chart for development..." +install_local_rancher_turtles_chart + if [ "$USE_TILT_DEV" == "true" ]; then echo "Using Tilt for development..." tilt up -else - echo "Installing local Rancher Turtles chart for development..." - install_local_rancher_turtles_chart fi \ No newline at end of file diff --git a/tilt-settings.json.example b/tilt-settings.json.example index e0d8cf35..dd48acc6 100644 --- a/tilt-settings.json.example +++ b/tilt-settings.json.example @@ -5,11 +5,6 @@ "continue": true, "port": 40000, "insecure_skip_verify": "true" - }, - "turtles-etcdsnapshotrestore": { - "continue": true, - "port": 40000, - "insecure_skip_verify": "true" } } } diff --git a/tilt/project/Tiltfile b/tilt/project/Tiltfile index c21757d1..b9c0d324 100644 --- a/tilt/project/Tiltfile +++ b/tilt/project/Tiltfile @@ -3,6 +3,18 @@ load("../k8s/Tiltfile", "k8s_find_object_name") load("../io/Tiltfile", "info", "file_write", "dir_create", "prepare_file") +def apply_files(name, project, debug): + kustomize_dir = project.get("kustomize_dir", "") + if kustomize_dir != "": + info("doing kustomization") + context = project.get("context") + yaml = kustomize(context + '/' + kustomize_dir) + yaml_path = context + "/.tiltbuild/files.yaml" + prepare_file(yaml_path) + for line in str(yaml).splitlines(): + file_write(yaml_path, line) + k8s_yaml(yaml) + def project_enable(name, project, debug): """Enable a project in Tilt @@ -37,6 +49,9 @@ def project_enable(name, project, debug): if not project: fail("you must supply a project configuration") + if project.get("op") == "apply": + return apply_files(name, project, debug) + label = project.get("label") env = project.get("env", {}) port_forwards, links = get_port_forwards(debug)