|
1 | 1 | # Common Design Pitfalls |
2 | 2 |
|
3 | | -This document lists common pitfalls that have been observed in the process of creating |
4 | | -and modifying VAs and DTs. |
| 3 | +This document lists common pitfalls that have been observed in the process of |
| 4 | +creating and modifying VAs and DTs. |
5 | 5 |
|
6 | 6 | ## Accidental OpenStackControlPlane Overwrites |
7 | 7 |
|
8 | | -In general, it is a best practice to keep all kustomizations (`patches`, `replacements`, etc) |
9 | | -for a particular resource in one `kustomization.yaml` file. Sometimes, however, it is |
10 | | -necessary to only perform a subset of `OpenStackControlPlane` kustomizations at a certain stage |
11 | | -of the deployment process. For instance, you might not want to kustomize an `OpenStackControlPlane` |
12 | | -CR with certain data during its initial creation stage because that data is not yet available |
13 | | -for use. Thus it would make sense to have a later stage and `kustomization.yaml` file to |
14 | | -add those kustomzations once the requisite data is available (perhaps during the data plane |
15 | | -deployment stage). |
16 | | - |
17 | | -**What is crucial to keep in mind is that any kustomizations to a resource in an earlier stage |
18 | | -will be lost/overwritten in later stages where that same resource is modified _if_ those stages |
19 | | -do not reference the same `kustomization.yaml` that the earlier stage utilized.** Thus it is |
20 | | -best to have a base `kustomization.yaml` for a given resource for all kustomizations common to |
21 | | -all stages -- and all those stages should thus reference that `kustomization.yaml`. Then, if |
22 | | -later stages need specific changes for that resource, a separate `kustomization.yaml` can be also |
23 | | -used to apply those additional kustomizations beyond the base ones. This approach is also |
24 | | -preferred to creating two somewhat-or-mostly duplicate `kustomization.yaml`s, one for the earlier |
25 | | -stage and one for a later stage. Keeping things DRY by using a common base will make future |
26 | | -potential changes to the `kustomization.yaml`s less prone to error, as changes to the common file |
27 | | -will automatically be picked up by all deployment stages. |
28 | | - |
29 | | -As an illustrative example of the best practice mentioned above, consider the following directory |
30 | | -structure: |
| 8 | +In general, it is a best practice to keep all kustomizations (`patches`, |
| 9 | +`replacements`, etc) for a particular resource in one `kustomization.yaml` |
| 10 | +file. |
| 11 | + |
| 12 | +In some cases it is necessary to only perform a subset of |
| 13 | +`OpenStackControlPlane` kustomizations at a certain stage of the deployment |
| 14 | +process. For instance, you might not want to kustomize an |
| 15 | +`OpenStackControlPlane` CR with certain data during its initial creation stage |
| 16 | +because that data is not yet available for use. In the case of a multi-stage |
| 17 | +deployment, it would make sense to have a separate `kustomization.yaml` file to |
| 18 | +add those kustomizations once the requisite data is available (perhaps during |
| 19 | +the data plane deployment stage). |
| 20 | + |
| 21 | +**What is crucial to keep in mind is that any kustomizations to a resource in |
| 22 | +an earlier stage will be lost/overwritten in later stages where that same |
| 23 | +resource is modified _if_ those stages do not reference the same |
| 24 | +`kustomization.yaml` that the earlier stage utilized.** |
| 25 | + |
| 26 | +It is best to have a base `kustomization.yaml` for a given resource for all |
| 27 | +kustomizations common to all stages -- and all those stages should reference |
| 28 | +that `kustomization.yaml`. If later stages need specific changes for that |
| 29 | +resource, a separate `kustomization.yaml` can used to apply those additional |
| 30 | +kustomizations beyond the base ones. |
| 31 | + |
| 32 | +The use of common base files is preferred to creating two nearly-identical |
| 33 | +`kustomization.yaml` files; one for the earlier stage and one for a later |
| 34 | +stage. Keeping things DRY by using a common base will make future potential |
| 35 | +changes to the `kustomization.yaml` files less prone to error, as changes to |
| 36 | +the common file will automatically be picked up by all deployment stages. |
| 37 | + |
| 38 | +As an illustrative example of the best practice mentioned above, consider the |
| 39 | +following directory structure: |
31 | 40 |
|
32 | 41 | ``` |
33 | 42 | some_dt_or_va/control_plane/kustomization.yaml |
34 | 43 | some_dt_or_va/data_plane/kustomization.yaml |
35 | 44 | ``` |
36 | 45 |
|
37 | | -If the `data_plane/kustomization.yaml` needs to modify the `OpenStackControlPlane`, then it should |
38 | | -reference `../control_plane/kustomization.yaml` as a `Component` and then add additional `replacements` |
39 | | -and/or `patches` as needed. If it were to instead reference this repo's [lib/control-plane](../../lib/control-plane) |
40 | | -directory as its base `OpenStackControlPlane` `Component`, then the `../control_plane/kustomization.yaml` |
41 | | -kustomizations would be lost, since the `OpenStackControlPlane` CR would be generated and applied without |
42 | | -them. |
| 46 | +If the `data_plane/kustomization.yaml` needs to modify the |
| 47 | +`OpenStackControlPlane`, then it should reference |
| 48 | +`../control_plane/kustomization.yaml` as a `Component` and then add additional |
| 49 | +`replacements` and/or `patches` as needed. |
| 50 | + |
| 51 | +If it were to instead reference this repositories |
| 52 | +[lib/control-plane](../../lib/control-plane) directory as its base |
| 53 | +`OpenStackControlPlane` `Component`, then the |
| 54 | +`../control_plane/kustomization.yaml` kustomizations would be lost, since the |
| 55 | +`OpenStackControlPlane` CR would be generated and applied without them. |
43 | 56 |
|
44 | | -It also follows in this scenario that, as mentioned above, the `OpenStackControlPlane` kustomizations for |
45 | | -its initial creation stage should be located in one and only one `kustomization.yaml`. Thus you would |
46 | | -want to avoid something like this... |
| 57 | +The kustomizations for an `OpenStackControlPlane` resource should be within a |
| 58 | +single `kustomization.yaml` that contains the kustomizations for the initial |
| 59 | +creation stage. You want to avoid the use of multiple files, such as creating |
| 60 | +an additional sub-directory within the same base directory containing the |
| 61 | +configuration. The following would be an example to avoid: |
47 | 62 |
|
48 | 63 | ``` |
49 | 64 | some_dt_or_va/control_plane/kustomization.yaml |
50 | 65 | some_dt_or_va/control_plane/some_subdir/kustomization.yaml |
51 | 66 | some_dt_or_va/data_plane/kustomization.yaml |
52 | 67 | ``` |
53 | 68 |
|
54 | | -..._if_ `some_dt_or_va/control_plane/some_subdir/kustomization.yaml` has further kustomizations to the |
55 | | -`OpenStackControlPlane` beyond `some_dt_or_va/control_plane/kustomization.yaml`. (It would be fine, for |
56 | | -instance, if that subdirectory was modifying some other resource like `NodeNetworkConfigurationPolicy`). |
57 | | -The reason for this is again that, if later stages do not want to accidentally overwrite earlier |
58 | | -`OpenStackControlPlane` kustomizations, those later stages will need to reference both |
59 | | -`../control_plane/kustomization.yaml` and `../control_plane/some_subdir/kustomization.yaml` in the case |
60 | | -that those stages are modifying the `OpenStackControlPlane`. It would be better for the two directories |
61 | | -to be collapsed into one, such that a single `kustomization.yaml` can be referenced as a `Component` to |
62 | | -include all the previous stage's kustomizations and not inadvertently overwrite them. |
| 69 | +In some cases having an additional nested directory may be valid, in the case a |
| 70 | +subdirectory was modifying some other resource like |
| 71 | +`NodeNetworkConfigurationPolicy`. |
| 72 | + |
| 73 | +If later stages do not want to accidentally overwrite earlier |
| 74 | +`OpenStackControlPlane` kustomizations, those later stages need to reference |
| 75 | +both `../control_plane/kustomization.yaml` and |
| 76 | +`../control_plane/some_subdir/kustomization.yaml` so that those stages are |
| 77 | +modifying the `OpenStackControlPlane`. |
| 78 | + |
| 79 | +It would be better for the two directories to be collapsed into one, such that |
| 80 | +a single `kustomization.yaml` can be referenced as a `Component` to include all |
| 81 | +the previous stage's kustomizations and not inadvertently overwrite them. |
0 commit comments