Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .envrc.sample
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export EXP_MACHINE_SET_PREFLIGHT_CHECKS=true
export CLUSTER_NAME=test-dfkhje
export SECRET_NAME=supersecret
export CLOUD_NAME=test
export ENCODED_CLOUDS_YAML=mybase64encodedcloudsyamlfile
export ENCODED_CLOUDS_YAML=bXliYXNlNjRlbmNvZGVkY2xvdWRzeWFtbGZpbGUK
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ temp
# Tilt files.
.tiltbuild
/tilt.d
tilt-settings.json
tilt-settings.yaml
tilt_config.json
baremetalhosts.yaml

Expand Down Expand Up @@ -70,3 +70,8 @@ __pycache__/
/_output
tmp_*

.cluster.yaml
.clusterstack.yaml
.cspotemplate.yaml
.secret.yaml
.release
114 changes: 91 additions & 23 deletions Tiltfile

Copy link
Copy Markdown
Member

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 .release directory is synced to the cspo operator but not to the cso operator and then cso tries to download a non-existent release from remote.

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

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

Original file line number Diff line number Diff line change
Expand Up @@ -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",
Comment thread
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",
Expand All @@ -29,8 +30,8 @@ settings = {
}

# global settings
settings.update(read_json(
"tilt-settings.json",
settings.update(read_yaml(
"tilt-settings.yaml",
Comment thread
kranurag7 marked this conversation as resolved.
default = {},
))

Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the settings.get("cso_version") be used here?


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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion config/cspo/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spec:
cidrBlocks: ["192.168.0.0/16"]
serviceDomain: "cluster.local"
topology:
class: openstack-ferrol-1-27-v1
class: openstack-scs-1-27-v2
controlPlane:
metadata: {}
replicas: 1
Expand Down
4 changes: 2 additions & 2 deletions config/cspo/clusterstack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
namespace: cluster
spec:
provider: openstack
name: ferrol
name: scs
kubernetesVersion: "1.27"
channel: stable
autoSubscribe: false
Expand All @@ -14,4 +14,4 @@ spec:
kind: OpenStackClusterStackReleaseTemplate
name: cspotemplate
versions:
- v1
- v2
41 changes: 41 additions & 0 deletions docs/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment thread
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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.
11 changes: 11 additions & 0 deletions tilt-settings.yaml.example
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