This repository was archived by the owner on Dec 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
✨ [WIP] use local_mode with cspo #78
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9d07ba8
use local_mode with cspo
f6f9d7a
change copy target to /tmp/downloads
5606f6e
Update Tiltfile
kranurag7 f2bdaf3
add docs and update gitignore
b7f50e1
implement docs feedback
c236395
mark local_mode to false in Tiltfile
807ffa7
move cso deployment along with cspo in the repo
a5b406d
address requested changes and more
5bf34a8
Update Tiltfile
kranurag7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,10 +17,11 @@ settings = { | |
| "allowed_contexts": [ | ||
| "kind-cspo", | ||
| ], | ||
| "local_mode": False, | ||
| "deploy_cert_manager": True, | ||
| "preload_images_for_kind": True, | ||
| "kind_cluster_name": "cspo", | ||
| "capi_version": "v1.5.2", | ||
| "capi_version": "v1.6.0", | ||
|
chess-knight marked this conversation as resolved.
|
||
| "cso_version": "v0.1.0-alpha.2", | ||
| "capo_version": "v0.8.0", | ||
| "cert_manager_version": "v1.13.1", | ||
|
|
@@ -29,8 +30,8 @@ settings = { | |
| } | ||
|
|
||
| # global settings | ||
| settings.update(read_json( | ||
| "tilt-settings.json", | ||
| settings.update(read_yaml( | ||
| "tilt-settings.yaml", | ||
|
kranurag7 marked this conversation as resolved.
|
||
| default = {}, | ||
| )) | ||
|
|
||
|
|
@@ -61,12 +62,55 @@ def deploy_capi(): | |
| if kb_extra_args: | ||
| patch_args_with_extra_args("capi-kubeadm-bootstrap-system", "capi-kubeadm-bootstrap-controller-manager", kb_extra_args) | ||
|
|
||
| ## This should have the same versions as the Dockerfile | ||
| if settings.get("local_mode"): | ||
| tilt_dockerfile_header_cso = """ | ||
| FROM ghcr.io/sovereigncloudstack/cso:v0.1.0-alpha.2 as builder | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can the |
||
|
|
||
| FROM docker.io/library/alpine:3.18.0 as tilt | ||
| WORKDIR / | ||
| COPY --from=builder /usr/local/bin/helm /usr/local/bin/helm | ||
| COPY --from=builder /manager /manager | ||
| COPY .release/ /tmp/downloads/cluster-stacks/ | ||
| """ | ||
| else: | ||
| tilt_dockerfile_header_cso = """ | ||
| FROM ghcr.io/sovereigncloudstack/cso:v0.1.0-alpha.2 as builder | ||
|
|
||
| FROM docker.io/library/alpine:3.18.0 as tilt | ||
| WORKDIR / | ||
| COPY --from=builder /usr/local/bin/helm /usr/local/bin/helm | ||
| COPY --from=builder /manager /manager | ||
| """ | ||
|
|
||
|
|
||
| def deploy_cso(): | ||
| # yaml = str(kustomizesub("./hack/observability")) # build an observable kind deployment by default | ||
| version = settings.get("cso_version") | ||
| cso_uri = "https://github.com/sovereignCloudStack/cluster-stack-operator/releases/download/{}/cso-infrastructure-components.yaml".format(version) | ||
| cmd = "curl -sSL {} | {} | kubectl apply -f -".format(cso_uri, envsubst_cmd) | ||
| local(cmd, quiet = True) | ||
|
|
||
| entrypoint = ["/manager"] | ||
| extra_args = settings.get("extra_args") | ||
| if extra_args: | ||
| entrypoint.extend(extra_args) | ||
|
|
||
| # Set up an image build for the provider. The live update configuration syncs the output from the local_resource | ||
| # build into the container. | ||
| if settings.get("local_mode"): | ||
| docker_build_with_restart( | ||
| ref = "ghcr.io/sovereigncloudstack/cso", | ||
| context = ".", | ||
| dockerfile_contents = tilt_dockerfile_header_cso, | ||
| target = "tilt", | ||
| entrypoint = entrypoint, | ||
| live_update = [ | ||
| sync(".release", "/tmp/downloads/cluster-stacks"), | ||
| ], | ||
| ignore = ["templates"], | ||
| ) | ||
|
|
||
| def deploy_capo(): | ||
| version = settings.get("capo_version") | ||
| capo_uri = "https://github.com/kubernetes-sigs/cluster-api-provider-openstack/releases/download/{}/infrastructure-components.yaml".format(version) | ||
|
|
@@ -124,14 +168,25 @@ def fixup_yaml_empty_arrays(yaml_str): | |
| return yaml_str.replace("storedVersions: null", "storedVersions: []") | ||
|
|
||
| ## This should have the same versions as the Dockerfile | ||
| tilt_dockerfile_header_cspo = """ | ||
| FROM docker.io/alpine/helm:3.12.2 as helm | ||
|
|
||
| FROM docker.io/library/alpine:3.18.0 as tilt | ||
| WORKDIR / | ||
| COPY --from=helm --chown=root:root --chmod=755 /usr/bin/helm /usr/local/bin/helm | ||
| COPY manager . | ||
| """ | ||
| if settings.get("local_mode"): | ||
| tilt_dockerfile_header_cspo = """ | ||
| FROM docker.io/alpine/helm:3.12.2 as helm | ||
|
|
||
| FROM docker.io/library/alpine:3.18.0 as tilt | ||
| WORKDIR / | ||
| COPY --from=helm --chown=root:root --chmod=755 /usr/bin/helm /usr/local/bin/helm | ||
| COPY .tiltbuild/manager . | ||
| COPY .release/ /tmp/downloads/cluster-stacks/ | ||
| """ | ||
| else: | ||
| tilt_dockerfile_header_cspo = """ | ||
| FROM docker.io/alpine/helm:3.12.2 as helm | ||
|
|
||
| FROM docker.io/library/alpine:3.18.0 as tilt | ||
| WORKDIR / | ||
| COPY --from=helm --chown=root:root --chmod=755 /usr/bin/helm /usr/local/bin/helm | ||
| COPY manager . | ||
| """ | ||
|
|
||
|
|
||
| # Build cspo and add feature gates | ||
|
|
@@ -166,18 +221,31 @@ def deploy_cspo(): | |
|
|
||
| # Set up an image build for the provider. The live update configuration syncs the output from the local_resource | ||
| # build into the container. | ||
| docker_build_with_restart( | ||
| ref = "ghcr.io/sovereigncloudstack/cspo-staging", | ||
| context = "./.tiltbuild/", | ||
| dockerfile_contents = tilt_dockerfile_header_cspo, | ||
| target = "tilt", | ||
| entrypoint = entrypoint, | ||
| only = "manager", | ||
| live_update = [ | ||
| sync(".tiltbuild/manager", "/manager"), | ||
| ], | ||
| ignore = ["templates"], | ||
| ) | ||
| if settings.get("local_mode"): | ||
| docker_build_with_restart( | ||
| ref = "ghcr.io/sovereigncloudstack/cspo-staging", | ||
| context = ".", | ||
| dockerfile_contents = tilt_dockerfile_header_cspo, | ||
| target = "tilt", | ||
| entrypoint = entrypoint, | ||
| live_update = [ | ||
| sync(".tiltbuild/manager", "/manager"), | ||
| sync(".release", "/tmp/downloads/cluster-stacks"), | ||
| ], | ||
| ignore = ["templates"], | ||
| ) | ||
| else: | ||
| docker_build_with_restart( | ||
| ref = "ghcr.io/sovereigncloudstack/cspo-staging", | ||
| context = "./.tiltbuild/", | ||
| dockerfile_contents = tilt_dockerfile_header_cspo, | ||
| target = "tilt", | ||
| entrypoint = entrypoint, | ||
| live_update = [ | ||
| sync(".tiltbuild/manager", "/manager"), | ||
| ], | ||
| ignore = ["templates"], | ||
| ) | ||
| k8s_yaml(blob(yaml)) | ||
| k8s_resource(workload = "cspo-controller-manager", labels = ["cspo"]) | ||
| k8s_resource( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,3 +50,44 @@ make delete-bootstrap-cluster | |
| ``` | ||
|
|
||
| If you have any trouble finding the right command, then you can use `make help` to get a list of all available make targets. | ||
|
|
||
| ## Toggle between local_mode and remote mode | ||
| We can retrieve cluster-stacks in two modes. One way is to let the controller fetch it from GitHub which is remote mode and other is we mount the cluster-stacks inside the container at `/tmp/downloads/cluster-stacks` directory. | ||
|
|
||
| > [!NOTE] | ||
| > Using remote mode is the default behavior. | ||
|
chess-knight marked this conversation as resolved.
|
||
|
|
||
| Switching between both modes is relatively simple if you're using Tilt. There is a file at the root of the repo `tilt-settings.yaml.example` | ||
| Make a copy of that file with the name of `tilt-settings.yaml` | ||
| ```bash | ||
| cp tilt-settings.yaml.example tilt-settings.yaml | ||
| ``` | ||
| Now, open the file and set the `local_mode` to `true` to use cluster-stacks in local_mode. It should look the following content wise. | ||
| ```yaml | ||
| local_mode: true | ||
| ``` | ||
|
|
||
| > [!NOTE] | ||
| > In this mode you need to have cluster-stacks present locally. | ||
|
|
||
| Downloading cluster-stacks can be achieved by many ways but below is a simple way to download it quickly. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this won't work as this cluster stack is not adapted for csmctl... Can you adapt the docs so that they contain a local workflow with csmctl? |
||
| ```bash | ||
| mkdir -p .release/openstack-scs-1-27-v1/ | ||
| cd .release/openstack-scs-1-27-v1 | ||
| gh release download --repo sovereigncloudstack/cluster-stacks openstack-scs-1-27-v1 | ||
| ``` | ||
| Change the repo and tag as per the requirement. You can also download it directly from browser and move it to `.release` directory. | ||
|
|
||
| Please make sure the directory structure remains the same otherwise you'll not be able to start the tilt setup. Here's an example of structuring `openstack-scs-1-27-v1` cluster-stack. | ||
| ```bash | ||
| $ tree .release/openstack-scs-1-27-v1/ | ||
| .release/openstack-scs-1-27-v1/ | ||
| ├── clusterstack.yaml | ||
| ├── metadata.yaml | ||
| └── openstack-scs-1-27-cluster-class-v1.tgz | ||
| ``` | ||
|
|
||
| > [!IMPORTANT] | ||
| There's an alternative way to get clusterstacks using [csmctl](https://github.com/sovereigncloudstack/csmctl). You can follow the README of csmctl for specific instructions and a good quickstart. | ||
|
|
||
| You can use `csmctl create` subcommand to create clusterstack locally. You'll need a csmctl.yaml file in the cluster-stack configuration directory. Please read more about creating configuration file for csmctl in the csmctl docs. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| allowed_contexts: | ||
| - kind-cspo | ||
| local_mode: false | ||
| deploy_cert_manager: true | ||
| preload_images_for_kind: true | ||
| kind_cluster_name: cspo | ||
| capi_version: v1.6.0 | ||
| cso_version: v0.1.0-alpha.2 | ||
| capo_version: v0.8.0 | ||
| cert_manager_version: v1.13.1 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found IMO huge problem here. The
.releasedirectory is synced to the cspo operator but not to the cso operator and then cso tries to download a non-existent release from remote.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, very good catch.
I think we will have to move the cso deployment in the tree and use multistage build to mount the release assets inside cso.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chess-knight I've pushed a fix for this moving the cso deployment in the repo itself rather than fetching it directly from GitHub.
Please see and test this commit here 807ffa7
Appreciate your review on this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @kranurag7 for that commit, I reviewed it by reading only and wrote down some questions for you. Now I plan to test it and maybe write some other comments, will see