diff --git a/Makefile b/Makefile index cb3eea63..80a4ff40 100644 --- a/Makefile +++ b/Makefile @@ -584,12 +584,18 @@ builder-image-push: ## Build $(CONTROLLER_SHORT)-builder to a new version. For m .PHONY: test test: test-unit test-integration ## Runs all unit and integration tests. -create-workload-cluster-openstack: $(ENVSUBST) $(KUBECTL) +apply-workload-cluster-openstack: $(ENVSUBST) $(KUBECTL) cat .cluster.yaml | $(ENVSUBST) - | $(KUBECTL) apply -f - delete-workload-cluster-openstack: $(ENVSUBST) $(KUBECTL) cat .cluster.yaml | $(ENVSUBST) - | $(KUBECTL) delete -f - +apply-clusterstack: $(ENVSUBST) $(KUBECTL) + cat .clusterstack.yaml | $(ENVSUBST) - | $(KUBECTL) apply -f - + +delete-clusterstack: $(ENVSUBST) $(KUBECTL) + cat .clusterstack.yaml | $(ENVSUBST) - | $(KUBECTL) delete -f - + get-kubeconfig-workload-cluster: ./hack/get-kubeconfig-of-workload-cluster.sh diff --git a/Tiltfile b/Tiltfile index abf8959b..f7e97486 100644 --- a/Tiltfile +++ b/Tiltfile @@ -131,17 +131,12 @@ def prepare_environment(): if not os.path.exists('.clusterstack.yaml'): local("cp config/cspo/clusterstack.yaml .clusterstack.yaml") - k8s_yaml('.clusterstack.yaml') - if not os.path.exists('.secret.yaml'): local("cp config/cspo/secret.yaml .secret.yaml") if not os.path.exists('.cluster.yaml'): local("cp config/cspo/cluster.yaml .cluster.yaml") - if not os.path.exists('.cspotemplate.yaml'): - local("cp config/cspo/cspotemplate.yaml .cspotemplate.yaml") - def patch_args_with_extra_args(namespace, name, extra_args): args_str = str(local("kubectl get deployments {} -n {} -o jsonpath='{{.spec.template.spec.containers[0].args}}'".format(name, namespace))) args_to_add = [arg for arg in extra_args if arg not in args_str] @@ -270,15 +265,6 @@ def create_secret(): cmd = "cat .secret.yaml | {} | kubectl apply -f -".format(envsubst_cmd) local_resource('supersecret', cmd, labels=["clouds-yaml-secret"]) -def cspo_template(): - cmd = "cat .cspotemplate.yaml | {}".format(envsubst_cmd) - cspo_yaml = local(cmd, quiet=True) - k8s_yaml(cspo_yaml) - k8s_resource(objects = ["cspotemplate:openstackclusterstackreleasetemplate"], new_name = "cspotemplate", labels = ["cspo-template"]) - -def clusterstack(): - k8s_resource(objects = ["clusterstack:clusterstack"], new_name = "clusterstack", labels = ["clusterstack"]) - def base64_encode(to_encode): encode_blob = local("echo '{}' | tr -d '\n' | base64 - | tr -d '\n'".format(to_encode), quiet = True) return str(encode_blob) @@ -347,19 +333,15 @@ deploy_cspo() deploy_capo() -clusterstack() - waitforsystem() prepare_environment() create_secret() -cspo_template() - cmd_button( - "create workload cluster", - argv=["make", "create-workload-cluster-openstack"], + "apply workload cluster", + argv=["make", "apply-workload-cluster-openstack"], location=location.NAV, icon_name="add_circle", ) @@ -370,3 +352,18 @@ cmd_button( location=location.NAV, icon_name="cancel", ) + +cmd_button( + "apply clusterstack", + argv=["make", "apply-clusterstack"], + location=location.NAV, + icon_name="bolt", +) + +cmd_button( + "delete clusterstack", + argv=["make", "delete-clusterstack"], + location=location.NAV, + icon_name="delete", +) + diff --git a/config/cspo/clusterstack.yaml b/config/cspo/clusterstack.yaml index cb11c030..7289cf4e 100644 --- a/config/cspo/clusterstack.yaml +++ b/config/cspo/clusterstack.yaml @@ -1,3 +1,15 @@ +apiVersion: infrastructure.clusterstack.x-k8s.io/v1alpha1 +kind: OpenStackClusterStackReleaseTemplate +metadata: + name: cspotemplate + namespace: cluster +spec: + template: + spec: + identityRef: + kind: Secret + name: "${SECRET_NAME}" +--- apiVersion: clusterstack.x-k8s.io/v1alpha1 kind: ClusterStack metadata: diff --git a/docs/develop.md b/docs/develop.md index 69283d16..1f184335 100644 --- a/docs/develop.md +++ b/docs/develop.md @@ -24,11 +24,16 @@ make tilt-up > To access the Tilt UI please go to: `http://localhost:10351` -You should make sure that everything in the UI looks green. If not, you can trigger the Tilt workflow again. In the case of the `cspotemplate`, this might be necessary, as it cannot be applied right after the startup of the cluster and fails. Tilt unfortunately does not include a waiting period. +You should make sure that everything in the UI looks green. If not, you can trigger the Tilt workflow again. -If everything is green, then you can already check for your clusterstack that has been deployed. You can use a tool like k9s to have a look at the management cluster and its custom resources. +### Applying ClusterStack -In case your clusterstack shows that it is ready, you can deploy a workload cluster. This could be done through the Tilt UI, by pressing the button in the top right corner `Create Workload Cluster`. This triggers the `make create-workload-cluster-openstack`, which uses the environment variables and the cluster-template. +When you start your tilt setup then the ClusterStack manifest gets copied from `config/cspo` directory to root of your repository. In order to apply the ClusterStack to the running local development cluster, you can click on the tilt UI. There should a click on the top-right hand side that is named as `apply-clusterstack` if you hover over it. +Once the ClusterStack is applied wait for the ClusterStack and ClusterStackRelease object to be ready. In case your ClusterStack shows that it is ready, you can deploy a workload cluster. + +### Creating workload cluster + +This could be done through the Tilt UI, by pressing the button in the top right corner `Create Workload Cluster`. This triggers the `make create-workload-cluster-openstack`, which uses the environment variables and the cluster-template. To interact with your freshly created workload cluster, you can use these commands: @@ -41,6 +46,8 @@ In case you want to change some code, you can do so and see that Tilt triggers o If you want to change something in your ClusterStack or Cluster custom resources, you can have a look at `.cluster.yaml` and `.clusterstack.yaml`, which Tilt uses. +To delete the ClusterStack you can click on the `delete-clusterstack` button in the tilt UI. + To tear down the workload cluster, click on the `Delete Workload Cluster` button in the top right corner of the Tilt UI. This action triggers the execution of `make delete-workload-cluster-openstack`. After a few minutes, the resources should be successfully deleted. To tear down the kind cluster, use: @@ -97,4 +104,4 @@ $ tree .release/openstack-scs-1-27-v1/ > [!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. +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.