Skip to content

Commit d741f26

Browse files
authored
Merge pull request #2376 from Nordix/lentzi90/development-images
📖 Add Image templates, improve dev-test clusterclass and update dev docs
2 parents 16ed71d + 45d16a7 commit d741f26

File tree

4 files changed

+338
-31
lines changed

4 files changed

+338
-31
lines changed

docs/book/src/development/development.md

+48-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,38 @@
3434

3535
# Development Guide
3636

37-
This document explains how to develop Cluster API Provider OpenStack.
37+
This document explains how to develop Cluster API Provider OpenStack (CAPO).
38+
Note that CAPO depends on ORC. No matter how you choose to work, you will need to deploy ORC in order to make CAPO functional:
39+
40+
```bash
41+
kubectl apply -f https://github.com/k-orc/openstack-resource-controller/releases/download/v1.0.0/install.yaml
42+
```
43+
44+
TL;DR: Here is a short version for how to develop with Tilt:
45+
46+
1. Create a devstack
47+
2. Run tilt, configured through the Cluster API repository
48+
3. Install ORC
49+
4. Create a secret with the clouds.yaml to match the devstack
50+
5. Add images to the devstack
51+
52+
```bash
53+
# Create Devstack
54+
export RESOURCE_TYPE=...
55+
./hack/ci/create_devstack.sh
56+
# Start tilt (separate terminal in cluster-api repo)
57+
# NOTE: Configure tilt-settings.yaml first! See below.
58+
make tilt-up
59+
# Back in CAPO repo
60+
# Install ORC
61+
kubectl apply -f https://github.com/k-orc/openstack-resource-controller/releases/download/v1.0.0/install.yaml
62+
# Create secret with clouds.yaml (the file is created by create_devstack.sh)
63+
kubectl create secret generic dev-test-cloud-config --from-file=clouds.yaml
64+
# Add images to use in the tests
65+
clusterctl generate yaml --from templates/images-template.yaml | kubectl apply -f -
66+
```
67+
68+
At this point, you should be able to apply the `dev-test` ClusterClass and start creating/deleting `development` clusters through the Tilt UI.
3869

3970
## Using your own capi-openstack controller image for testing cluster creation or deletion
4071

@@ -61,6 +92,15 @@ make docker-build docker-push
6192

6293
After generating `infrastructure-components.yaml`, replace the `us.gcr.io/k8s-artifacts-prod/capi-openstack/capi-openstack-controller:v0.3.4` with your image.
6394

95+
## Automatically Adding Images to OpenStack
96+
97+
Before you can create a Cluster, you will need a suitable image in OpenStack.
98+
There is a convenient template available in `templates/images-template.yaml` for this purpose.
99+
100+
```bash
101+
clusterctl generate yaml --from templates/images-template.yaml | kubectl apply -f -
102+
```
103+
64104
## Testing Cluster Creation using the 'dev-test' ClusterClass with Tilt
65105

66106
This guide demonstrates how to create a Kubernetes cluster using a ClusterClass, specifically designed for a development environment. It includes configuring secrets, applying the ClusterClass, and creating a cluster with Tilt.
@@ -93,6 +133,8 @@ kustomize_substitutions:
93133
OPENSTACK_NODE_MACHINE_FLAVOR: "<openstack_node_machine_flavor>"
94134
# [Optional] OpenStack Cloud Environment (Default: capo-e2e)
95135
OPENSTACK_CLOUD: "<openstack_cloud>"
136+
# See templates/cluster-template-development.yaml and
137+
# templates/clusterclass-dev-test.yaml for more variables.
96138

97139
# [Optional] Automatically apply a kustomization, e.g. for adding the clouds.yaml secret
98140
additional_kustomizations:
@@ -107,8 +149,7 @@ After a while, you should be able to find resources called `CAPO.clusterclasses`
107149
These shoud correspond to what exists in the `templates` folder and you should see widgets for applying and deleting them.
108150

109151
**Note:** When you apply a cluster template, there will be a `KUBERNETES_VERSION` variable.
110-
This variable is used to pick the image used!
111-
Ensure that an image named `ubuntu-2204-kube-{{ KUBERNETES_VERSION }}` is available in your environment, corresponding to that Kubernetes version.
152+
Make sure that the image or sysext overlay you use exists for and works with that version!
112153

113154
**Note:** All clusters created from the dev-test ClusterClass will require a secret named `dev-test-cloud-config` with the `clouds.yaml` to be used by CAPO for interacting with OpenStack.
114155
You can create it manually or see below how to make Tilt automate it.
@@ -196,7 +237,7 @@ kubectl create secret generic dev-test-cloud-config --from-file=clouds.yaml
196237
You can use `clusterctl` to render the ClusterClass:
197238

198239
```bash
199-
clusterctl generate yaml --from templates/clusterclass-dev-test.yaml
240+
clusterctl generate yaml --from templates/clusterclass-dev-test.yaml | kubectl apply -f -
200241
```
201242

202243
Create a cluster using the development template, that makes use of the ClusterClass:
@@ -324,8 +365,9 @@ The entry point for the creation of the DevStack environment is the [create_devs
324365
- AWS: [aws-project.sh][hack-ci-aws-project]
325366
- GCE: [gce-project.sh][hack-ci-gce-project]
326367
- OpenStack: [openstack.sh][hack-ci-openstack]
368+
- Libvirt: [libvirt.sh][hack-ci-libvirt]
327369

328-
You can switch between these cloud providers, by setting the `RESOURCE_TYPE` environment variable to `aws-project`, `gce-project` or `openstack` respectively.
370+
You can switch between these cloud providers, by setting the `RESOURCE_TYPE` environment variable to `aws-project`, `gce-project`, `openstack` or `libvirt` respectively.
329371

330372
##### OpenStack
331373

@@ -493,6 +535,7 @@ $ sudo ln -s /run/user/$(id -u)/podman/podman.sock /var/run/docker.sock
493535
[hack-ci-create-devstack]: https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/main/hack/ci/create_devstack.sh
494536
[hack-ci-gce-project]: https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/main/hack/ci/gce-project.sh
495537
[hack-ci-openstack]: https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/main/hack/ci/openstack.sh
538+
[hack-ci-libvirt]: https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/main/hack/ci/libvirt.sh
496539

497540
## API concepts
498541

templates/cluster-template-development.yaml

+14-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,21 @@ spec:
66
topology:
77
class: dev-test
88
version: ${KUBERNETES_VERSION}
9+
controlPlane:
10+
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
911
workers:
1012
machineDeployments:
1113
- class: default-worker
1214
name: md-0
13-
replicas: 1
15+
replicas: ${WORKER_MACHINE_COUNT}
16+
variables:
17+
- name: identityRef
18+
value:
19+
name: ${CLOUD_CONFIG_SECRET:=dev-test-cloud-config}
20+
cloudName: ${OPENSTACK_CLOUD:=capo-e2e}
21+
- name: imageName
22+
value: ${IMAGE_NAME:=flatcar_production}
23+
- name: addImageVersion
24+
value: ${ADD_IMAGE_VERSION:=false}
25+
- name: injectIgnitionSysext
26+
value: ${INJECT_IGNITION_SYSEXT:=true}

0 commit comments

Comments
 (0)