Skip to content

Commit

Permalink
Merge pull request #1653 from Jont828/tilt-flavors
Browse files Browse the repository at this point in the history
Support Tilt deployment of multiple workload clusters of the same flavor
  • Loading branch information
k8s-ci-robot authored Aug 27, 2021
2 parents 072bdd0 + cd4342a commit 1b87248
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ kubeconfig

# vscode
.vscode
*.code-workspace

# goland
.idea
Expand Down
16 changes: 10 additions & 6 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@ def flavors():
for template in worker_templates:
deploy_worker_templates(template, substitutions)

local_resource(
name = 'delete-all-workload-clusters',
cmd = "kubectl delete clusters --all --wait=false",
auto_init = False,
trigger_mode = TRIGGER_MODE_MANUAL
)

def deploy_worker_templates(template, substitutions):
# validate template exists
Expand Down Expand Up @@ -285,10 +291,9 @@ def deploy_worker_templates(template, substitutions):
# programmatically define any remaining vars
# "windows" can not be for cluster name because it sets the dns to trademarked name during reconciliation
substitutions = {
"CLUSTER_NAME": flavor.replace("windows", "win") + "-template",
"AZURE_LOCATION": "eastus",
"AZURE_VNET_NAME": flavor + "-template-vnet",
"AZURE_RESOURCE_GROUP": flavor + "-template-rg",
"AZURE_VNET_NAME": "${CLUSTER_NAME}-vnet",
"AZURE_RESOURCE_GROUP": "${CLUSTER_NAME}-rg",
"CONTROL_PLANE_MACHINE_COUNT": "1",
"KUBERNETES_VERSION": settings.get("kubernetes_version"),
"AZURE_CONTROL_PLANE_MACHINE_TYPE": "Standard_D2s_v3",
Expand All @@ -305,10 +310,9 @@ def deploy_worker_templates(template, substitutions):
yaml = yaml.replace("${" + substitution + "}", value)

yaml = yaml.replace('"', '\\"') # add escape character to double quotes in yaml

local_resource(
os.path.basename(flavor),
cmd = "make generate-flavors; echo \"" + yaml + "\" > ./.tiltbuild/" + flavor + "; cat ./.tiltbuild/" + flavor + " | " + envsubst_cmd + " | kubectl apply -f -",
name = os.path.basename(flavor),
cmd = "CLUSTER_NAME=" + flavor.replace("windows", "win") + "-$(echo $RANDOM); make generate-flavors; echo \"" + yaml + "\" > ./.tiltbuild/" + flavor + "; cat ./.tiltbuild/" + flavor + " | " + envsubst_cmd + " | kubectl apply -f - && echo \"Cluster \'$CLUSTER_NAME\' created, don't forget to delete\"",
auto_init = False,
trigger_mode = TRIGGER_MODE_MANUAL
)
Expand Down
3 changes: 2 additions & 1 deletion docs/book/src/developers/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- [Developing](#developing)
- [Modules and dependencies](#modules-and-dependencies)
- [Setting up the environment](#setting-up-the-environment)
- [Tilt Requirements](#tilt-requirements)
- [Using Tilt](#using-tilt)
- [Tilt for dev in CAPZ](#tilt-for-dev-in-capz)
- [Tilt for dev in both CAPZ and CAPI](#tilt-for-dev-in-both-capz-and-capi)
Expand Down Expand Up @@ -222,7 +223,7 @@ The cluster-api management components that are deployed are configured at the `/

After your kind management cluster is up and running with Tilt, you can deploy a workload cluster by opening the `tilt` web UI and clicking the clockwise arrow icon ⟳ on a resource listed, such as "aks-aad," "ipv6," or "windows."

Deploying a workload cluster from Tilt UI is also termed as flavor cluster deployment.
Deploying a workload cluster from Tilt UI is also termed as flavor cluster deployment. Note that each time a flavor is deployed, it deploys a new workload cluster in addition to the existing ones. All the workload clusters must be manually deleted by the user.
Please refer to [Running flavor clusters as a tilt resource](../../../../templates/flavors/README.md#Running-flavor-clusters-as-a-tilt-resource) to learn more about this.

Or you can [configure workload cluster settings](#customizing-the-cluster-deployment) and deploy a workload cluster with the following command:
Expand Down

0 comments on commit 1b87248

Please sign in to comment.