@@ -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+
6476def 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+
70121def 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+
213279def clusterstack ():
214280 k8s_resource (objects = ["clusterstack:clusterstack" ], new_name = "clusterstack" , labels = ["clusterstack" ])
215281
@@ -272,7 +338,10 @@ if settings.get("deploy_observability"):
272338
273339deploy_capi ()
274340
275- deploy_cso ()
341+ if settings .get ("local_mode" ):
342+ deploy_local_cso ()
343+ else :
344+ deploy_cso ()
276345
277346deploy_cspo ()
278347
0 commit comments