|
| 1 | +# Develop Cluster Stack Provider OpenStack |
| 2 | + |
| 3 | +Developing our operator is quite straightforward. First, you need to install some basic prerequisites: |
| 4 | + |
| 5 | +- Docker |
| 6 | +- Go |
| 7 | + |
| 8 | +Next, configure your environment variables. Once that's done, you can initiate development using the local Kind cluster and the Tilt UI to create a workload cluster that comes pre-configured. |
| 9 | + |
| 10 | +## Setting Tilt up |
| 11 | + |
| 12 | +1. Install Docker and Go. We expect you to run on a Linux OS. |
| 13 | +2. Create an `.envrc` file and specify the values you need. See the `.envrc.sample` for details. |
| 14 | + |
| 15 | +## Developing with Tilt |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | +Operator development requires a lot of iteration, and the “build, tag, push, update deployment” workflow can be very tedious. Tilt makes this process much simpler by watching for updates and automatically building and deploying them. To build a kind cluster and to start Tilt, run: |
| 20 | + |
| 21 | +```shell |
| 22 | +make tilt-up |
| 23 | +``` |
| 24 | + |
| 25 | +> To access the Tilt UI please go to: `http://localhost:10351` |
| 26 | +
|
| 27 | +You should make sure that everything in the UI looks green. If not, you can trigger the Tilt workflow again. To establish a connection to your OpenStack project, you must supply a secret containing the `clouds.yaml` file. |
| 28 | + |
| 29 | +```bash |
| 30 | +kubectl create secret generic <my-secret> --from-file=clouds.yaml=path/to/clouds.yaml -n cluster |
| 31 | +``` |
| 32 | + |
| 33 | +To transfer the credentials stored in the secret mentioned above to the operator, the user must create an `OpenStackClusterStackReleaseTemplate` object and specify this secret in the `identityRef` field. The `clouds.yaml` file may contain one or more clouds, so the user must specify desired connection to a specific cloud by using the `cloudName` field. Refer to the `examples/cspotemplate.yaml` file for more details. Afterward, apply this template to the local Kind cluster, which was built by the previous `make` command. |
| 34 | + |
| 35 | +```bash |
| 36 | +kubectl apply -f <path-to-openstack-clusterstack-release-template> |
| 37 | +``` |
| 38 | + |
| 39 | +Now, proceed to apply the `ClusterStack` to the local Kind cluster. For more details see `examples/clusterstack.yaml`. |
| 40 | + |
| 41 | +```bash |
| 42 | +kubectl apply -f <path-to-openstack-clusterstack> |
| 43 | +``` |
| 44 | + |
| 45 | +Please be patient and wait for the operator to execute the necessary tasks. In case your `ClusterStack` object encounters no errors and `openstacknodeimagereleases` is ready, you can deploy a workload cluster. This could be done by applying cluster-template. See the example of this template in `examples/cluster.yaml`. |
| 46 | + |
| 47 | +```bash |
| 48 | +kubectl apply -f <path-to-cluster-template> |
| 49 | +``` |
| 50 | + |
| 51 | +In case you want to change some code, you can do so and see that Tilt triggers on save. It will update the container of the operator automatically. |
| 52 | + |
| 53 | +To tear down the workload cluster press the "Delete Workload Cluster" button. After a few minutes, the resources should be deleted. |
| 54 | + |
| 55 | +To tear down the kind cluster, use: |
| 56 | + |
| 57 | +```shell |
| 58 | +make delete-bootstrap-cluster |
| 59 | +``` |
| 60 | + |
| 61 | +If you have any trouble finding the right command, then you can use `make help` to get a list of all available make targets. |
0 commit comments