Skip to content

Commit

Permalink
Install turtles in a dev-env as opposed to upstream operator
Browse files Browse the repository at this point in the history
Signed-off-by: Danil-Grigorev <[email protected]>
  • Loading branch information
Danil-Grigorev committed Nov 25, 2024
1 parent a7bb9ab commit eb956ca
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 26 deletions.
11 changes: 10 additions & 1 deletion Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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"
}
}

Expand Down
7 changes: 7 additions & 0 deletions config/capiproviders/bootstrap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: turtles-capi.cattle.io/v1alpha1
kind: CAPIProvider
metadata:
name: rke2-bootstrap
spec:
type: bootstrap
name: rke2
7 changes: 7 additions & 0 deletions config/capiproviders/controlplane.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: turtles-capi.cattle.io/v1alpha1
kind: CAPIProvider
metadata:
name: rke2-control-plane
spec:
type: controlPlane
name: rke2
6 changes: 6 additions & 0 deletions config/capiproviders/core.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: turtles-capi.cattle.io/v1alpha1
kind: CAPIProvider
metadata:
name: cluster-api
spec:
type: core
6 changes: 6 additions & 0 deletions config/capiproviders/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: turtles-capi.cattle.io/v1alpha1
kind: CAPIProvider
metadata:
name: docker
spec:
type: infrastructure
5 changes: 5 additions & 0 deletions config/capiproviders/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resources:
- core.yaml
- docker.yaml
- bootstrap.yaml
- controlplane.yaml
25 changes: 5 additions & 20 deletions scripts/turtles-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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

Expand All @@ -93,20 +78,20 @@ 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 \
--create-namespace --wait \
--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
5 changes: 0 additions & 5 deletions tilt-settings.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
"continue": true,
"port": 40000,
"insecure_skip_verify": "true"
},
"turtles-etcdsnapshotrestore": {
"continue": true,
"port": 40000,
"insecure_skip_verify": "true"
}
}
}
15 changes: 15 additions & 0 deletions tilt/project/Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit eb956ca

Please sign in to comment.