Skip to content

Commit fd0889e

Browse files
Add develop doc (#36)
Signed-off-by: michal.gubricky <[email protected]>
1 parent 4755125 commit fd0889e

File tree

6 files changed

+129
-0
lines changed

6 files changed

+129
-0
lines changed

.envrc.sample

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export KUBECONFIG=$PWD/.mgt-cluster-kubeconfig.yaml
2+
export K8S_VERSION=1-27
3+
export GIT_PROVIDER_B64=Z2l0aHVi
4+
export GIT_ACCESS_TOKEN_B64=mybase64encodedtoken
5+
export GIT_ORG_NAME_B64=U292ZXJlaWduQ2xvdWRTdGFjaw==
6+
export GIT_REPOSITORY_NAME_B64=Y2x1c3Rlci1zdGFja3M=
7+
export EXP_CLUSTER_RESOURCE_SET=true
8+
export EXP_MACHINE_POOL=true
9+
export CLUSTER_TOPOLOGY=true
10+
export EXP_RUNTIME_SDK=true
11+
export EXP_MACHINE_SET_PREFLIGHT_CHECKS=true
12+
export CLUSTER_NAME=test-dfkhje

docs/develop.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
![tilt](./pics/tilt.png "Tilt")
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.

docs/pics/tilt.png

175 KB
Loading

examples/cluster.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: cluster.x-k8s.io/v1beta1
2+
kind: Cluster
3+
metadata:
4+
name: <my-workload-cluster-name>
5+
namespace: cluster
6+
spec:
7+
clusterNetwork:
8+
services:
9+
cidrBlocks: ["10.128.0.0/12"]
10+
pods:
11+
cidrBlocks: ["192.168.0.0/16"]
12+
serviceDomain: "cluster.local"
13+
topology:
14+
class: openstack-ferrol-1-27-v1
15+
controlPlane:
16+
metadata: {}
17+
replicas: 1
18+
variables:
19+
- name: imageRepository
20+
value: ""
21+
version: v1.27.3
22+
workers:
23+
machineDeployments:
24+
- class: workeramd64
25+
name: md-0
26+
replicas: 1
27+
failureDomain: nova

examples/clusterstack.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: clusterstack.x-k8s.io/v1alpha1
2+
kind: ClusterStack
3+
metadata:
4+
name: clusterstack
5+
namespace: cluster
6+
spec:
7+
provider: openstack
8+
name: ferrol
9+
kubernetesVersion: "1.27"
10+
channel: stable
11+
autoSubscribe: false
12+
providerRef:
13+
apiVersion: infrastructure.clusterstack.x-k8s.io/v1alpha1
14+
kind: OpenStackClusterStackReleaseTemplate
15+
name: cspotemplate
16+
versions:
17+
- v1

examples/cspotemplate.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: infrastructure.clusterstack.x-k8s.io/v1alpha1
2+
kind: OpenStackClusterStackReleaseTemplate
3+
metadata:
4+
name: cspotemplate
5+
namespace: cluster
6+
spec:
7+
template:
8+
spec:
9+
cloudName: <name of the cloud to use from the clouds secret>
10+
identityRef:
11+
kind: Secret
12+
name: <my-secret>

0 commit comments

Comments
 (0)