Skip to content

Commit

Permalink
Operator renamed and removed some cnf- prefixes (#108)
Browse files Browse the repository at this point in the history
New package name: `redhat-best-practices-for-k8s-certsuite-operator`.

```
$ oc get packagemanifests -n certsuite-operator | grep cert
redhat-best-practices-for-k8s-certsuite-operator   OLM Test Catalog for the certsuite operator   3m55s
```
The certsuite's ServiceAccount, the certsuite container image and some
of the sample config yaml have also been updated.

There's still some work to do:
1. Remove "cnf-" from plugin resources' names.
2. Rename the CRD to remove the Cnf/cnf prefixes. The domain and api
group must also be updated.

I will address (2) in the next PR.
  • Loading branch information
greyerof authored Aug 13, 2024
1 parent 9ab2fc4 commit fdcf29a
Show file tree
Hide file tree
Showing 66 changed files with 318 additions and 245 deletions.
21 changes: 11 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
# This variable is used to construct full image tags for bundle and catalog images.
#
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
# redhat.com/cnf-certsuite-operator-bundle:$VERSION and redhat.com/tnf-op-catalog:$VERSION.
IMAGE_TAG_BASE ?= redhat.com/cnf-certsuite-operator
# quay.io/redhat-best-practices-for-k8s/certsuite-operator-bundle:v$VERSION and
# quay.io/redhat-best-practices-for-k8s/certsuite-operator-catalog:v$VERSION.
IMAGE_TAG_BASE ?= quay.io/redhat-best-practices-for-k8s/certsuite-operator

# BUNDLE_IMG defines the image:tag used for the bundle.
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
Expand All @@ -52,8 +53,8 @@ endif
OPERATOR_SDK_VERSION ?= v1.34.2

# Image URL to use all building/pushing image targets
IMG ?= controller:latest
SIDECAR_IMG ?= sidecar:latest
IMG ?= quay.io/redhat-best-practices-for-k8s/certsuite-operator:v$(VERSION)
SIDECAR_IMG ?= quay.io/redhat-best-practices-for-k8s/certsuite-operator-sidecar:v$(VERSION)
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.28.3

Expand Down Expand Up @@ -269,15 +270,15 @@ OPERATOR_SDK = $(shell which operator-sdk)
endif
endif

## IMPORTANT: The serviceaccount "cnf-certsuite-cluster-access" is needed by the CNF's cert pod. The prefix "cnf-certsuite" must match the one in
## IMPORTANT: The serviceaccount "certsuite-cluster-access" is needed by the CNF's cert pod. The prefix "certsuite" must match the one in
## config/default/kustomization.yaml field "namePrefix".
.PHONY: bundle
bundle: manifests kustomize ## Generate bundle manifests and metadata, then validate generated files.
$(OPERATOR_SDK) generate kustomize manifests -q
cd config/manager \
&& $(KUSTOMIZE) edit set image controller=${IMG} \
&& $(KUSTOMIZE) edit add patch --kind Deployment --patch "[{\"op\": \"replace\", \"path\": \"/spec/template/spec/containers/0/env/1\", \"value\": {\"name\": \"SIDECAR_APP_IMG\", \"value\": \"${SIDECAR_IMG}\"} }]"
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) --extra-service-accounts cnf-certsuite-cluster-access
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) --extra-service-accounts certsuite-cluster-access
$(OPERATOR_SDK) bundle validate ./bundle

.PHONY: bundle-build
Expand Down Expand Up @@ -332,15 +333,15 @@ catalog-push: ## Push a catalog image.
.PHONY: deploy-samples
deploy-samples: kustomize ## Deploy the sample CR, configmap and secret in the cluster.
cd config/samples \
&& $(KUSTOMIZE) edit add resource "extra/cnf-certsuite-configmap.yaml" \
&& $(KUSTOMIZE) edit add resource "extra/cnf-certsuite-preflight-secret.yaml"
&& $(KUSTOMIZE) edit add resource "extra/certsuite-configmap.yaml" \
&& $(KUSTOMIZE) edit add resource "extra/certsuite-preflight-secret.yaml"
$(KUBECTL) kustomize config/samples | $(KUBECTL) apply -f -

# Install the operator using OLM subscription. It will create the namespace ${OLM_INSTALL_NAMESPACE}, which
# is defaulted to "cnf-certsuite-operator" if not set, and deploys the CatalogSource, OperatorGroup and
# is defaulted to "certsuite-operator" if not set, and deploys the CatalogSource, OperatorGroup and
# and the subscription, using the operator found in the "alpha" channel of the catalog ${OLM_INSTALL_IMG_CATALOG}.
OLM_INSTALL_IMG_CATALOG ?= quay.io/redhat-best-practices-for-k8s/certsuite-operator-catalog:latest
OLM_INSTALL_NAMESPACE ?= cnf-certsuite-operator
OLM_INSTALL_NAMESPACE ?= certsuite-operator
.PHONY: olm-install
olm-install: kustomize ## Installs the operator using OLM subscription.
cd config/samples/olm \
Expand Down
2 changes: 1 addition & 1 deletion PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ layout:
plugins:
manifests.sdk.operatorframework.io/v2: {}
scorecard.sdk.operatorframework.io/v2: {}
projectName: cnf-certsuite-operator
projectName: rh-best-practices-for-k8s-certsuite-operator
repo: github.com/redhat-best-practices-for-k8s/certsuite-operator
resources:
- api:
Expand Down
56 changes: 28 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# CNF Certification Suite Operator
# Certification Suite Operator

[![red hat](https://img.shields.io/badge/red%20hat---?color=gray&logo=redhat&logoColor=red&style=flat)](https://www.redhat.com)
[![openshift](https://img.shields.io/badge/openshift---?color=gray&logo=redhatopenshift&logoColor=red&style=flat)](https://www.redhat.com/en/technologies/cloud-computing/openshift)

## Description

Kubernetes/Openshift Operator (scaffolded with operator-sdk) running the
[CNF Certification Suite Container](https://github.com/test-network-function/cnf-certification-test).
[Certification Suite Container](https://github.com/redhat-best-practices-for-k8s/certsuite-operator).

The CNF Certification Suites provide a set of test cases for the
The Certification Suites provide a set of test cases for the
Containerized Network Functions/Cloud Native Functions (CNFs) to verify if
best practices for deployment on Red Hat OpenShift clusters are followed.

### How does it work?

The Operator registers a CRD in the cluster: `CnfCertificationSuiteRun`.

In order to fire up the CNF Certification Suite, the user must create
In order to fire up the Certification Suite, the user must create
a CnfCertificationSuiteRun CR, also informally referred as Run CR, which
has to be created with a Config Map containing the cnf certification suites configuration,
and a Secret containing the preflight suite credentials.
**Note:** All resources mentioned above should be created in the operator's
installation namespace (by default `cnf-certsuite-operator`)
installation namespace (by default `certsuite-operator`)

See resources relationship diagram:

Expand All @@ -31,7 +31,7 @@ When the CR is deployed, a new pod with two containers is created:

1. Container built with the cnf certification image in order to run the suites.
2. Container (sidecar) which updates the Run CR's status fields containing the
CNF Certification suites results based on results claim file created by the
Certification suites results based on results claim file created by the
previous container.

**See diagram summarizing the process:**
Expand All @@ -53,24 +53,24 @@ kubeconfig file (i.e. whatever cluster `kubectl cluster-info` shows).
Clone Cnf Certification Operator repo:

```sh
git clone https://github.com/test-network-function/cnf-certsuite-operator.git
git clone https://github.com/redhat-best-practices-for-k8s/certsuite-operator.git
```

#### Option 1: Using OLM subscription

1. Export OLM catalog image and namespace:

```sh
export OLM_INSTALL_IMG_CATALOG=<your-registry.com>/<your-repo>/cnf-certsuite-operator-catalog:<version>
export OLM_INSTALL_IMG_CATALOG=<your-registry.com>/<your-repo>/certsuite-operator-catalog:<version>
export OLM_INSTALL_NAMESPACE=<your-namespace>
```

**Note:** If the catalog image and namespace aren't provided,
they will be set by default to:
```sh
OLM_INSTALL_IMG_CATALOG = quay.io/testnetworkfunction/cnf-certsuite-operator-catalog:latest
OLM_INSTALL_NAMESPACE = cnf-certsuite-operator
OLM_INSTALL_IMG_CATALOG = quay.io/redhat-best-practices-for-k8s/certsuite-operator-catalog:latest
OLM_INSTALL_NAMESPACE = certsuite-operator
```
2. Install Cnf Certification Operator:\
Expand All @@ -89,12 +89,12 @@ git clone https://github.com/test-network-function/cnf-certsuite-operator.git
NAME READY STATUS RESTARTS AGE
afa1738b451274ef681c19ae8e8a6dcc50f65568056ef97355a4a2fe14hbhpn 0/1 Completed 0 3m32s
cnf-certsuite-controller-manager-67f68cd4cb-625ww 2/2 Running 0 3m18s
cnf-certsuite-operator-olm-catalog-mkmqw 1/1 Running 0 3m45s
certsuite-operator-olm-catalog-mkmqw 1/1 Running 0 3m45s
```
<!-- markdownlint-enable -->
**Note:** If `OLM_INSTALL_NAMESPACE` environment variable wasn't exported
in previous steps, use `cnf-certsuite-operator` as namespace instead.
in previous steps, use `certsuite-operator` as namespace instead.

#### Option 2: Manually building and deploying the operator

Expand All @@ -110,8 +110,8 @@ kubectl apply -f https://github.com/jetstack/cert-manager/releases/latest/downlo
1. Export images environment variables:

```sh
export IMG=<your-registry.com>/<your-repo>/cnf-certsuite-operator:<version>
export SIDECAR_IMG=<your-registry.com>/<your-repo>/cnf-certsuite-operator-sidecar:<version>
export IMG=<your-registry.com>/<your-repo>/certsuite-operator:<version>
export SIDECAR_IMG=<your-registry.com>/<your-repo>/certsuite-operator-sidecar:<version>
```

2. Build and upload the controller image to your registry account:
Expand Down Expand Up @@ -139,7 +139,7 @@ kubectl apply -f https://github.com/jetstack/cert-manager/releases/latest/downlo
1. Export images environment variables (optional):

```sh
export IMG=<your-cnf-certsuite-operator-image-name>
export IMG=<your-certsuite-operator-image-name>
export SIDECAR_IMG=<your-sidecar-app-image-name>
```

Expand Down Expand Up @@ -172,10 +172,10 @@ make deploy-samples
```

**Note**: Current sample CnfCertificationSuiteRun CR configures
the CNF Certification Suite to run the "observability" test suite only.
It can be modified by changing manually the `labelsFilter` of the [sample CR](https://github.com/test-network-function/cnf-certsuite-operator/blob/main/config/samples/cnf-certifications_v1alpha1_cnfcertificationsuiterun.yaml).
the Certification Suite to run the "observability" test suite only.
It can be modified by changing manually the `labelsFilter` of the [sample CR](https://github.com/redhat-best-practices-for-k8s/certsuite-operator/blob/main/config/samples/cnf-certifications_v1alpha1_cnfcertificationsuiterun.yaml).

### How to customize the CNF Certification Suite run
### How to customize the Certification Suite run

1. Create Resources

Expand All @@ -185,12 +185,12 @@ It can be modified by changing manually the `labelsFilter` of the [sample CR](ht
1. Config map:\
Containing the cnf certification configuration file
content under the `tnf_config.yaml` key.\
(see [CNF Certification configuration description](https://test-network-function.github.io/cnf-certification-test/configuration/))
(see [Certification configuration description](https://redhat-best-practices-for-k8s.github.io/certsuite-operator/configuration/))
2. Secret:\
Containing cnf preflight suite credentials
under the `preflight_dockerconfig.json` key.\
(see [Preflight Integration description](https://test-network-function.github.io/cnf-certification-test/runtime-env/#disable-intrusive-tests))
(see [Preflight Integration description](https://redhat-best-practices-for-k8s.github.io/certsuite-operator/runtime-env/#disable-intrusive-tests))
3. CnfCertificationSuiteRun CR:\
Containing the following Spec fields that has to be filled in:
Expand All @@ -205,7 +205,7 @@ It can be modified by changing manually the `labelsFilter` of the [sample CR](ht
or "false" otherwise.\
**Note:** When setting this field to true, the claim file will be sent to
a server external to the cluster. see
[collector repository](https://github.com/test-network-function/collector)
[collector repository](https://github.com/redhat-best-practices-for-k8s/collector)
for more details
- **showAllResultsLogs**: Set to "true" to show all result's logs,
and not only logs of failed test cases.
Expand All @@ -214,7 +214,7 @@ It can be modified by changing manually the `labelsFilter` of the [sample CR](ht
resources of all results. and not only compliant and non-compliant
resources of failed test cases. This field is set to "false" by default.

See a [sample CnfCertificationSuiteRun CR](https://github.com/test-network-function/cnf-certsuite-operator/blob/main/config/samples/cnf-certifications_v1alpha1_cnfcertificationsuiterun.yaml)
See a [sample CnfCertificationSuiteRun CR](https://github.com/redhat-best-practices-for-k8s/certsuite-operator/blob/main/config/samples/cnf-certifications_v1alpha1_cnfcertificationsuiterun.yaml)

2. Apply resources into the cluster

Expand All @@ -233,12 +233,12 @@ It can be modified by changing manually the `labelsFilter` of the [sample CR](ht
### Review results
If all of the resources were applied successfully, the cnf certification suites
will run on a new created `pod` in the `cnf-certsuite-operator` namespace.
will run on a new created `pod` in the `certsuite-operator` namespace.
The pod has the name with the form `cnf-job-run-N`:
<!-- markdownlint-disable -->
```sh
$ oc get pods -n cnf-certsuite-operator
$ oc get pods -n certsuite-operator
NAME READY STATUS RESTARTS AGE
cnf-certsuite-controller-manager-6c6bb6d965-jslmd 2/2 Running 0 21h
cnf-job-run-1 0/2 Completed 0 21h
Expand All @@ -250,12 +250,12 @@ by checking CnfCertificationSuiteRun CR's status.
In the successful case, expect to see the following status:

```sh
$ oc get cnfcertificationsuiteruns.cnf-certifications.redhat.com -n cnf-certsuite-operator
$ oc get cnfcertificationsuiteruns.cnf-certifications.redhat.com -n certsuite-operator
NAME AGE STATUS
cnfcertificationsuiterun-sample 50m CertSuiteFinished
```

The status `CertSuiteFinished` means the CNF Cert Suite pod has finished running
The status `CertSuiteFinished` means the Cert Suite pod has finished running
all the test cases, so the results can be inspected in field `report` of the Run
CR's (cnfcertificationsuiterun-sample) status subresource.
Expand Down Expand Up @@ -294,14 +294,14 @@ If the the result is "skipped" or "failed" contains also the skip\failure reason
<!-- markdownlint-enable -->
- Summary: Summarize the total number of tests by their results.
- Verdict: Specifies the overall result of the CNF certificattion suites run.\
- Verdict: Specifies the overall result of the certificattion suites run.\
Poissible verdicts: "pass", "skip", "fail", "error".
Run the following command to ensure its creation:
<!-- markdownlint-disable -->
```sh
$ oc get cnfcertificationsuiteruns.cnf-certifications.redhat.com -n cnf-certsuite-operator cnfcertificationsuiterun-sample -o json | jq '.status.report.verdict'
$ oc get cnfcertificationsuiteruns.cnf-certifications.redhat.com -n certsuite-operator cnfcertificationsuiterun-sample -o json | jq '.status.report.verdict'
"pass"
```
<!-- markdownlint-enable -->
Expand Down
2 changes: 1 addition & 1 deletion bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM scratch
LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=cnf-certsuite-operator
LABEL operators.operatorframework.io.bundle.package.v1=rh-best-practices-for-k8s-certsuite-operator
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.34.2
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: cnf-certsuite-config
namespace: cnf-certsuite-operator
data:
tnf_config.yaml: |
targetNameSpaces:
- name: tnf
podsUnderTestLabels:
- "test-network-function.com/generic: target"
- "redhat-best-practices-for-k8s.com/generic: target"
# deprecated operator label ("test-network-function.com/operator:"") still configured by default, no need to add it here
operatorsUnderTestLabels:
- "test-network-function.com/operator1:new"
- "redhat-best-practices-for-k8s.com/operator:target"
- "redhat-best-practices-for-k8s.com/operator1:new"
- "cnf/test:cr-scale-operator"
targetCrdFilters:
- nameSuffix: "group1.test.com"
scalable: false
- nameSuffix: "test-network-function.com"
- nameSuffix: "redhat-best-practices-for-k8s.com"
scalable: false
- nameSuffix: "tutorial.my.domain"
- nameSuffix: "memcacheds.cache.example.com"
scalable: true
managedDeployments:
- name: jack
Expand Down Expand Up @@ -55,3 +52,6 @@ data:
executedBy: ""
partnerName: ""
collectorAppPassword: ""
kind: ConfigMap
metadata:
name: certsuite-config
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ metadata:
creationTimestamp: null
labels:
app.kubernetes.io/component: kube-rbac-proxy
app.kubernetes.io/created-by: cnf-certsuite-operator
app.kubernetes.io/created-by: certsuite-operator
app.kubernetes.io/instance: controller-manager-metrics-service
app.kubernetes.io/managed-by: kustomize
app.kubernetes.io/name: service
app.kubernetes.io/part-of: cnf-certsuite-operator
app.kubernetes.io/part-of: certsuite-operator
control-plane: controller-manager
name: cnf-certsuite-controller-manager-metrics-service
name: certsuite-controller-manager-metrics-service
spec:
ports:
- name: https
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ metadata:
creationTimestamp: null
labels:
app.kubernetes.io/component: kube-rbac-proxy
app.kubernetes.io/created-by: cnf-certsuite-operator
app.kubernetes.io/created-by: certsuite-operator
app.kubernetes.io/instance: metrics-reader
app.kubernetes.io/managed-by: kustomize
app.kubernetes.io/name: clusterrole
app.kubernetes.io/part-of: cnf-certsuite-operator
name: cnf-certsuite-metrics-reader
app.kubernetes.io/part-of: certsuite-operator
name: certsuite-metrics-reader
rules:
- nonResourceURLs:
- /metrics
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
data:
preflight_dockerconfig.json: |
eyAiYXV0aHMiOiB7fSB9Cg==
kind: Secret
metadata:
name: certsuite-preflight-dockerconfig
type: Opaque
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ metadata:
creationTimestamp: null
labels:
app.kubernetes.io/component: webhook
app.kubernetes.io/created-by: cnf-certsuite-operator
app.kubernetes.io/created-by: certsuite-operator
app.kubernetes.io/instance: webhook-service
app.kubernetes.io/managed-by: kustomize
app.kubernetes.io/name: service
app.kubernetes.io/part-of: cnf-certsuite-operator
name: cnf-certsuite-webhook-service
app.kubernetes.io/part-of: certsuite-operator
name: certsuite-webhook-service
spec:
ports:
- port: 443
Expand Down
Loading

0 comments on commit fdcf29a

Please sign in to comment.