Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit 9a65361

Browse files
authored
use local_mode with cspo (#88)
Signed-off-by: kranurag7 <[email protected]>
1 parent 6aa18f2 commit 9a65361

File tree

13 files changed

+1118
-74
lines changed

13 files changed

+1118
-74
lines changed

.github/labels.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
color: "ffc300"
3030
- name: update/github-action
3131
color: "ffc300"
32-
- name: update/helm
33-
color: "ffc300"
3432
- name: update/go
3533
color: "ffc300"
3634
# Semantic Type

.github/renovate/commitMessage.json5

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
"commitMessageSuffix": "",
66
"group": { commitMessageTopic: "{{{groupName}}} group" },
77
"packageRules": [
8-
{
9-
"matchDatasources": ["helm"],
10-
"commitMessageTopic": "chart {{depName}}"
11-
},
128
{
139
"matchDatasources": ["docker"],
1410
"commitMessageTopic": "image {{depName}}",

.github/renovate/labels.json5

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
"matchUpdateTypes": ["patch"],
1313
"labels": ["type/patch"]
1414
},
15-
{
16-
"matchDatasources": ["helm"],
17-
"addLabels": ["update/helm"]
18-
},
1915
{
2016
"matchDatasources": ["docker"],
2117
"addLabels": ["update/container"]

.github/workflows/test.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
uses: ./.github/actions/setup-go
4646

4747
- name: Install dependencies
48-
run: make gotestsum go-cover-treemap setup-envtest helm
48+
run: make gotestsum go-cover-treemap setup-envtest
4949

5050
- name: Install go modules for test
5151
shell: bash
@@ -64,17 +64,17 @@ jobs:
6464
ENCODED_CLOUDS_YAML: ${{ secrets.ENCODED_CLOUDS_YAML }}
6565
run: make test-integration
6666

67-
# - name: Create Report
68-
# run: make report-cover-html report-cover-treemap
67+
# - name: Create Report
68+
# run: make report-cover-html report-cover-treemap
6969

70-
# - name: Test Summary
71-
# uses: test-summary/action@62bc5c68de2a6a0d02039763b8c754569df99e3f # v2.1
72-
# with:
73-
# paths: ".coverage/junit.xml"
70+
# - name: Test Summary
71+
# uses: test-summary/action@62bc5c68de2a6a0d02039763b8c754569df99e3f # v2.1
72+
# with:
73+
# paths: ".coverage/junit.xml"
7474

75-
# - name: Upload Report
76-
# uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
77-
# with:
78-
# name: reports-${{ steps.name.outputs.name }}
79-
# path: .reports
80-
# retention-days: 30
75+
# - name: Upload Report
76+
# uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
77+
# with:
78+
# name: reports-${{ steps.name.outputs.name }}
79+
# path: .reports
80+
# retention-days: 30

.gitignore

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ temp
3131
# Tilt files.
3232
.tiltbuild
3333
/tilt.d
34-
tilt-settings.json
34+
tilt-settings.yaml
3535
tilt_config.json
3636
baremetalhosts.yaml
3737

@@ -60,13 +60,15 @@ out
6060
_releasenotes
6161
templates/cluster-templates/cluster-template*
6262

63-
# Helm
64-
.helm
65-
6663
# Byte-compiled / optimized / DLL files
6764
__pycache__/
6865
*.py[cod]
6966
*$py.class
7067
/_output
7168
tmp_*
7269

70+
.cluster.yaml
71+
.clusterstack.yaml
72+
.cspotemplate.yaml
73+
.secret.yaml
74+
.release

Makefile

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,6 @@ $(TRIVY):
139139
curl -sSL https://github.com/aquasecurity/trivy/releases/download/v0.45.1/trivy_0.45.1_Linux-64bit.tar.gz | tar xz -C $(TOOLS_BIN_DIR) trivy
140140
chmod a+rx $(TRIVY)
141141

142-
HELM := $(abspath $(TOOLS_BIN_DIR)/helm)
143-
helm: $(HELM) ## Build a local copy of helm
144-
$(HELM):
145-
curl -sSL https://get.helm.sh/helm-v3.12.2-linux-amd64.tar.gz | tar xz -C $(TOOLS_BIN_DIR) --strip-components=1 linux-amd64/helm
146-
chmod a+rx $(HELM)
147-
148142
go-binsize-treemap := $(abspath $(TOOLS_BIN_DIR)/go-binsize-treemap)
149143
go-binsize-treemap: $(go-binsize-treemap) # Build go-binsize-treemap from tools folder.
150144
$(go-binsize-treemap):
@@ -537,7 +531,7 @@ test-unit: test-unit-openstack ## Run unit tests
537531
echo done
538532

539533
.PHONY: test-unit-openstack
540-
test-unit-openstack: $(SETUP_ENVTEST) $(GOTESTSUM) $(HELM)
534+
test-unit-openstack: $(SETUP_ENVTEST) $(GOTESTSUM)
541535
@mkdir -p $(shell pwd)/.coverage
542536
KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" $(GOTESTSUM) --junitfile=.coverage/junit.xml --format testname -- -mod=vendor \
543537
-covermode=atomic -coverprofile=.coverage/cover.out -p=4 ./internal/controller/...

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Note that it is a common practice to create a temporary, local [bootstrap cluste
2020

2121
- Install [Docker] and [kind]
2222
- Install [kubectl]
23-
- Install [Helm]
2423
- Install [clusterctl]
2524
- Install [go] # installation of the Go package `envsubst` is required to enable the expansion of variables specified in CSPO and CSO manifests.
2625

@@ -165,7 +164,6 @@ CSPO currently exposes the following APIs:
165164

166165
<!-- links -->
167166
[Docker]: https://www.docker.com/
168-
[Helm]: https://helm.sh/docs/intro/install/
169167
[kind]: https://kind.sigs.k8s.io/
170168
[kubectl]: https://kubernetes.io/docs/tasks/tools/install-kubectl/
171169
[clusterctl]: https://cluster-api.sigs.k8s.io/user/quick-start.html#install-clusterctl

Tiltfile

Lines changed: 103 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,21 @@ settings = {
1717
"allowed_contexts": [
1818
"kind-cspo",
1919
],
20+
"local_mode": False,
2021
"deploy_cert_manager": True,
2122
"preload_images_for_kind": True,
2223
"kind_cluster_name": "cspo",
23-
"capi_version": "v1.5.2",
24-
"cso_version": "v0.1.0-alpha.2",
24+
"capi_version": "v1.6.0",
25+
"cso_version": "v0.1.0-alpha.3",
2526
"capo_version": "v0.8.0",
2627
"cert_manager_version": "v1.13.1",
2728
"kustomize_substitutions": {
2829
},
2930
}
3031

3132
# global settings
32-
settings.update(read_json(
33-
"tilt-settings.json",
33+
settings.update(read_yaml(
34+
"tilt-settings.yaml",
3435
default = {},
3536
))
3637

@@ -61,12 +62,62 @@ def deploy_capi():
6162
if kb_extra_args:
6263
patch_args_with_extra_args("capi-kubeadm-bootstrap-system", "capi-kubeadm-bootstrap-controller-manager", kb_extra_args)
6364

65+
tilt_dockerfile_header_cso = """
66+
FROM ghcr.io/sovereigncloudstack/cso:{} as builder
67+
68+
FROM docker.io/library/alpine:3.18.0 as tilt
69+
WORKDIR /
70+
COPY --from=builder /usr/local/bin/helm /usr/local/bin/helm
71+
COPY --from=builder /manager /manager
72+
COPY .release/ /tmp/downloads/cluster-stacks/
73+
COPY local_cso.yaml /local_cso.yaml
74+
""".format(settings.get("cso_version"))
75+
6476
def deploy_cso():
6577
version = settings.get("cso_version")
6678
cso_uri = "https://github.com/sovereignCloudStack/cluster-stack-operator/releases/download/{}/cso-infrastructure-components.yaml".format(version)
6779
cmd = "curl -sSL {} | {} | kubectl apply -f -".format(cso_uri, envsubst_cmd)
6880
local(cmd, quiet = True)
6981

82+
def deploy_local_cso():
83+
yaml_cso = './local_cso.yaml'
84+
85+
entrypoint = ["/manager"]
86+
extra_args = settings.get("extra_args")
87+
if extra_args:
88+
entrypoint.extend(extra_args)
89+
90+
docker_build_with_restart(
91+
ref = "ghcr.io/sovereigncloudstack/cso-test",
92+
context = ".",
93+
dockerfile_contents = tilt_dockerfile_header_cso,
94+
target = "tilt",
95+
entrypoint = entrypoint,
96+
live_update = [
97+
sync("./local_cso.yaml", "/local_cso.yaml"), # reload when we change the manifest
98+
sync("./.release", "/tmp/downloads/cluster-stacks"),
99+
],
100+
)
101+
k8s_yaml(yaml_cso)
102+
k8s_resource(workload = "cso-controller-manager", labels = ["CSO"])
103+
k8s_resource(
104+
objects = [
105+
"cso-system:namespace",
106+
"clusteraddons.clusterstack.x-k8s.io:customresourcedefinition",
107+
"clusterstackreleases.clusterstack.x-k8s.io:customresourcedefinition",
108+
"clusterstacks.clusterstack.x-k8s.io:customresourcedefinition",
109+
"cso-controller-manager:serviceaccount",
110+
"cso-leader-election-role:role",
111+
"cso-manager-role:clusterrole",
112+
"cso-leader-election-rolebinding:rolebinding",
113+
"cso-manager-rolebinding:clusterrolebinding",
114+
"cso-serving-cert:certificate",
115+
"cso-selfsigned-issuer:issuer",
116+
],
117+
new_name = "cso-misc",
118+
labels = ["CSO"],
119+
)
120+
70121
def deploy_capo():
71122
version = settings.get("capo_version")
72123
capo_uri = "https://github.com/kubernetes-sigs/cluster-api-provider-openstack/releases/download/{}/infrastructure-components.yaml".format(version)
@@ -124,14 +175,19 @@ def fixup_yaml_empty_arrays(yaml_str):
124175
return yaml_str.replace("storedVersions: null", "storedVersions: []")
125176

126177
## This should have the same versions as the Dockerfile
127-
tilt_dockerfile_header_cspo = """
128-
FROM docker.io/alpine/helm:3.12.2 as helm
129-
130-
FROM docker.io/library/alpine:3.18.0 as tilt
131-
WORKDIR /
132-
COPY --from=helm --chown=root:root --chmod=755 /usr/bin/helm /usr/local/bin/helm
133-
COPY manager .
134-
"""
178+
if settings.get("local_mode"):
179+
tilt_dockerfile_header_cspo = """
180+
FROM docker.io/library/alpine:3.18.0 as tilt
181+
WORKDIR /
182+
COPY .tiltbuild/manager .
183+
COPY .release/ /tmp/downloads/cluster-stacks/
184+
"""
185+
else:
186+
tilt_dockerfile_header_cspo = """
187+
FROM docker.io/library/alpine:3.18.0 as tilt
188+
WORKDIR /
189+
COPY manager .
190+
"""
135191

136192

137193
# Build cspo and add feature gates
@@ -164,36 +220,47 @@ def deploy_cspo():
164220
if extra_args:
165221
entrypoint.extend(extra_args)
166222

167-
# Set up an image build for the provider. The live update configuration syncs the output from the local_resource
168-
# build into the container.
169-
docker_build_with_restart(
170-
ref = "ghcr.io/sovereigncloudstack/cspo-staging",
171-
context = "./.tiltbuild/",
172-
dockerfile_contents = tilt_dockerfile_header_cspo,
173-
target = "tilt",
174-
entrypoint = entrypoint,
175-
only = "manager",
176-
live_update = [
177-
sync(".tiltbuild/manager", "/manager"),
178-
],
179-
ignore = ["templates"],
180-
)
223+
if settings.get("local_mode"):
224+
docker_build_with_restart(
225+
ref = "ghcr.io/sovereigncloudstack/cspo-staging",
226+
context = ".",
227+
dockerfile_contents = tilt_dockerfile_header_cspo,
228+
target = "tilt",
229+
entrypoint = entrypoint,
230+
live_update = [
231+
sync(".tiltbuild/manager", "/manager"),
232+
sync(".release", "/tmp/downloads/cluster-stacks"),
233+
],
234+
ignore = ["templates"],
235+
)
236+
else:
237+
docker_build_with_restart(
238+
ref = "ghcr.io/sovereigncloudstack/cspo-staging",
239+
context = "./.tiltbuild/",
240+
dockerfile_contents = tilt_dockerfile_header_cspo,
241+
target = "tilt",
242+
entrypoint = entrypoint,
243+
live_update = [
244+
sync(".tiltbuild/manager", "/manager"),
245+
],
246+
ignore = ["templates"],
247+
)
181248
k8s_yaml(blob(yaml))
182249
k8s_resource(workload = "cspo-controller-manager", labels = ["cspo"])
183250
k8s_resource(
184251
objects = [
185252
"cspo-system:namespace",
186-
#"clusterstackreleases.clusterstack.x-k8s.io:customresourcedefinition",
187-
#"clusterstacks.clusterstack.x-k8s.io:customresourcedefinition",
188253
"cspo-controller-manager:serviceaccount",
189254
"cspo-leader-election-role:role",
190255
"cspo-manager-role:clusterrole",
191256
"cspo-leader-election-rolebinding:rolebinding",
192257
"cspo-manager-rolebinding:clusterrolebinding",
193-
#"cspo-serving-cert:certificate",
194258
"cspo-cluster-stack-variables:secret",
195-
#"cspo-selfsigned-issuer:issuer",
196-
#"cspo-validating-webhook-configuration:validatingwebhookconfiguration",
259+
"openstackclusterstackreleases.infrastructure.clusterstack.x-k8s.io:customresourcedefinition",
260+
"openstackclusterstackreleasetemplates.infrastructure.clusterstack.x-k8s.io:customresourcedefinition",
261+
"openstacknodeimagereleases.infrastructure.clusterstack.x-k8s.io:customresourcedefinition",
262+
# "cspo-serving-cert:certificate",
263+
# "cspo-selfsigned-issuer:issuer", # uncomment when you add webhook code.
197264
],
198265
new_name = "cspo-misc",
199266
labels = ["cspo"],
@@ -208,8 +275,7 @@ def cspo_template():
208275
cspo_yaml = local(cmd, quiet=True)
209276
k8s_yaml(cspo_yaml)
210277
k8s_resource(objects = ["cspotemplate:openstackclusterstackreleasetemplate"], new_name = "cspotemplate", labels = ["cspo-template"])
211-
212-
278+
213279
def clusterstack():
214280
k8s_resource(objects = ["clusterstack:clusterstack"], new_name = "clusterstack", labels = ["clusterstack"])
215281

@@ -272,7 +338,10 @@ if settings.get("deploy_observability"):
272338

273339
deploy_capi()
274340

275-
deploy_cso()
341+
if settings.get("local_mode"):
342+
deploy_local_cso()
343+
else:
344+
deploy_cso()
276345

277346
deploy_cspo()
278347

config/cspo/cluster.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ spec:
1111
cidrBlocks: ["192.168.0.0/16"]
1212
serviceDomain: "cluster.local"
1313
topology:
14-
class: openstack-ferrol-1-27-v1
14+
class: openstack-scs-1-27-v2
1515
controlPlane:
1616
metadata: {}
1717
replicas: 1

config/cspo/clusterstack.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
namespace: cluster
66
spec:
77
provider: openstack
8-
name: ferrol
8+
name: scs
99
kubernetesVersion: "1.27"
1010
channel: stable
1111
autoSubscribe: false
@@ -14,4 +14,4 @@ spec:
1414
kind: OpenStackClusterStackReleaseTemplate
1515
name: cspotemplate
1616
versions:
17-
- v1
17+
- v2

0 commit comments

Comments
 (0)