Skip to content

Commit

Permalink
Create MetalLB and NMState CRs in common (before NNCP CRs)
Browse files Browse the repository at this point in the history
This patch moves the creation of the MetalLB and NMState
CRs to examples/common based on the assumption that all
VAs and DTs will need them. lib/deploy is divided into
lib/nmstate and lib/metallb. The common README is updated
with commands to confirm MetalLB is ready and NMState is
available. The HCI and NFV SRIOV VAs are updated accordingly.

Without this patch running kustomize in examples/va/hci
or examples/va/nfv/sriov results in a single CR containing
MetalLB, NMState and NNCP resources. When all of them are
created at the same time, OpenShift will try to create the
NNCP CRs while the NMState CRs are still installing and
produce a resource mappings not found error. Moving MetalLB
and NMState to common and updating the common README to add
a step to wait for them has a side effect of resolving this
problem.

The workaround section of the docs directory for this issue
has been removed though the workaround docs have been changed
into an FAQ so that the procedure of building smaller CRs
with separate components is still documented.

Jira: OSPRH-3743
Signed-off-by: John Fulton <fulton@redhat.com>
  • Loading branch information
fultonj committed Jan 22, 2024
1 parent e292af3 commit fec27bd
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 45 deletions.
57 changes: 23 additions & 34 deletions docs/wa/missing_nncp.md → docs/faq/cr_by_components.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,50 @@
# Missing NNCPs
# Creating Smaller CRs

## Question

The kustomize command builds and results in the OpenStack control
plane definitions and its dependent Custom Resources (CR).
```bash
kustomize build architecture/examples/va/hci > control-plane.yaml
```
The `control-plane.yaml` file contains CRs for both `NMState` and
`NodeNetworkConfigurationPolicy` (NNCP). When `oc apply -f
control-plane.yaml` is read, OpenShift will try to create the NNCPs
while `NMState` Custom Resource Definitions (CRD) are still installing
and produce a message noting that the resource mappings are not found:
```
nmstate.nmstate.io/nmstate created
[resource mapping not found for name:
"ostest-master-0" namespace: "openstack" from "control-plane.yaml":
no matches for kind "NodeNetworkConfigurationPolicy" in version "nmstate.io/v1"
ensure CRDs are installed first,
resource mapping not found for name: "ostest-master-1" namespace: "openstack"
from "control-plane.yaml": no matches for kind "NodeNetworkConfigurationPolicy"
in version "nmstate.io/v1"
```
Retrying `oc apply -f contol-plane.yaml` a few seconds later is likely to
resolve the problem.
The `control-plane.yaml` file contains CRs for the
`NodeNetworkConfigurationPolicy` (NNCP), the
`NetworkAttachmentDefinition`, MetalLB resources and
OpenStack resources. Is it possible to create a CR file with less
custom resources?

## Alternative Approach
## Answer

It's also possible to create CR files with less components and wait
Yes, it's possible to create CR files with less components and wait
before applying each CR file. E.g. the file `nncp.yaml` would contain
only `NodeNetworkConfigurationPolicy` CRs and `NMState` and other
deployment related CRs could exist in another file like
`deploy.yaml`. The following process may be used to do generate these
files using kustomize.
only `NodeNetworkConfigurationPolicy` CRs and
`NetworkAttachmentDefinition` and other CRs could exist in another
file like `networking.yaml`. The following process may be used to
generate these files using kustomize.

- Modify the
[va/hci/kustomization.yaml](https://github.com/openstack-k8s-operators/architecture/blob/main/va/hci/kustomization.yaml)
file so that the last two lines contain only the deploy component
configuration:
file so that the components list only has the nncp component:
```yaml
components:
- ../../lib/deploy
- ../../lib/nncp
```
- Generate a file with only `MetalLB` and `NMState` CRs:
- Generate a file with only NNCP CRs:
```bash
kustomize build architecture/examples/va/hci > deploy.yaml
kustomize build architecture/examples/va/hci > nncp.yaml
```
- Modify the
[va/hci/kustomization.yaml](https://github.com/openstack-k8s-operators/architecture/blob/main/va/hci/kustomization.yaml)
file so that the last two lines contain only the nncp component
configuration:
file so that the components list only has the networking component:
```yaml
components:
- ../../lib/nncp
- ../../lib/networking
```
- Generate a file with only `NNCP` CRs:
- Generate a file with only Networking CRs:
```bash
kustomize build architecture/examples/va/hci > nncp.yaml
kustomize build architecture/examples/va/hci > networking.yaml
```

The above process may be continued for each component.

Note that [va/hci/kustomization.yaml](https://github.com/openstack-k8s-operators/architecture/blob/main/va/hci/kustomization.yaml)
Expand Down
36 changes: 36 additions & 0 deletions examples/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,39 @@ oc wait pod -n metallb-system --for condition=Ready -l component=webhook-server
timeout 300 bash -c "while ! (oc get deployments/nmstate-operator -n openshift-nmstate); do sleep 10; done"
oc wait deployments/nmstate-operator -n openshift-nmstate --for condition=Available --timeout=300s
```

# MetalLB

Observe CRs which will be generated.
```
kustomize build examples/common/metallb/
```
Create the CRs.
```
oc apply -k examples/common/metallb/
```
The following commands can be used to confirm that each step of this
procedure is complete.
```
timeout 300 bash -c "while ! (oc get pod --no-headers=true -l component=speaker -n metallb-system | grep speaker); do sleep 10; done"
oc wait pod -n metallb-system -l component=speaker --for condition=Ready --timeout=300s
```

# NMState

Observe CRs which will be generated.
```
kustomize build examples/common/nmstate/
```
Create the CRs.
```
oc apply -k examples/common/nmstate/
```
The following commands can be used to confirm that each step of this
procedure is complete.
```
timeout 300 bash -c "while ! (oc get pod --no-headers=true -l component=kubernetes-nmstate-handler -n openshift-nmstate| grep nmstate-handler); do sleep 10; done"
oc wait pod -n openshift-nmstate -l component=kubernetes-nmstate-handler --for condition=Ready --timeout=300s
timeout 300 bash -c "while ! (oc get deployments/nmstate-webhook -n openshift-nmstate); do sleep 10; done"
oc wait deployments/nmstate-webhook -n openshift-nmstate --for condition=Available --timeout=300s
```
2 changes: 2 additions & 0 deletions examples/common/metallb/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
components:
- ../../../lib/metallb
2 changes: 2 additions & 0 deletions examples/common/nmstate/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
components:
- ../../../lib/nmstate
3 changes: 0 additions & 3 deletions examples/va/hci/control-plane.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ kustomize build > control-plane.yaml
```
oc apply -f control-plane.yaml
```
If the `oc apply` command produces a `no matches for kind
NodeNetworkConfigurationPolicy` error, then see
[Missing NNCPs Workaround](../../../docs/wa/missing_nncp.md).

Wait for NNCPs to be available
```
Expand Down
3 changes: 0 additions & 3 deletions examples/va/nfv/sriov/control-plane.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ kustomize build > control-plane.yaml
```
oc apply -f control-plane.yaml
```
If the `oc apply` command produces a `no matches for kind
NodeNetworkConfigurationPolicy` error, then see
[Missing NNCPs Workaround](../../../../docs/wa/missing_nncp.md).

Wait for NNCPs to be available
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ kind: Component

resources:
- metallb_deploy.yaml
- nmstate_deploy.yaml
File renamed without changes.
5 changes: 5 additions & 0 deletions lib/nmstate/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component

resources:
- nmstate_deploy.yaml
File renamed without changes.
4 changes: 2 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ nav:
- NFV SRIOV: https://github.com/openstack-k8s-operators/architecture/blob/main/examples/va/nfv/sriov/README.md
- Deployed Topologies:
- None
- Workarounds:
- Missing NNCPs: wa/missing_nncp.md
- FAQ:
- Creating Smaller CRs: faq/cr_by_components.md
- Contributing:
- contributing/documentation.md
markdown_extensions:
Expand Down
1 change: 0 additions & 1 deletion va/hci/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ transformers:
create: true
components:
- ../../lib/deploy
- ../../lib/nncp
- ../../lib/networking
- ../../lib/control-plane
Expand Down
1 change: 0 additions & 1 deletion va/nfv/sriov/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ transformers:
create: true
components:
- ../../../lib/deploy
- ../../../lib/nncp
- ../../../lib/networking
- ../../../lib/control-plane
Expand Down

0 comments on commit fec27bd

Please sign in to comment.