This guide contains building and installation instructions for developers of this operator.
See USERGUIDE.md for the user guide and user installation instructions.
This project was built with OperatorSDK version 1.2.0. Make sure to install it.
git clone https://github.com/operator-framework/operator-sdk
cd operator-sdk
git checkout v1.2.0
make install
The operator requires a special image to run the sosreport jobs. Build this image with the following commands.
For the CentOS image (registry.example.com:5000/sosreport-centos
):
make podman-build-sosreport REGISTRY=registry.example.com:5000
make podman-push-sosreport REGISTRY=registry.example.com:5000
For the RHEL image (registry.example.com:5000/sosreport-redhat-toolbox
):
make podman-build-sosreport REGISTRY=registry.example.com:5000 RHEL=true
make podman-push-sosreport REGISTRY=registry.example.com:5000 RHEL=true
Adjust the
REGISTRY=(...)
value as needed.
If building and using a RHEL toolbox image instead of CentOS, make sure that the local system is registered and provide
RHEL=true
to all commands that make a reference toREGISTRY
orSOSREPORT_IMG
Provide
SOSREPORT_IMG
to fully override the entire image path
Go through the
Makefile
for more options
Container common scripts are in containers/scripts/
. These scripts are copied to the container sub directory with:
make podman-copy-sosreport-scripts
make podman-copy-sosreport-scripts RHEL=true
This step is automatically executed when building the images.
When creating a new tag for quay.io, make sure to push the most recent scripts to the containers first, if any.
Install Custom Resource Definitions with:
make generate
make manifests
make install
To test run the operator locally:
make run ENABLE_WEBHOOKS=false
To install the operator:
make podman-build REGISTRY=registry.example.com:5000
make podman-push REGISTRY=registry.example.com:5000
make deploy REGISTRY=registry.example.com:5000
To remove the operator again:
make undeploy
make deploy OPERATOR_IMG=quay.io/akaris/sosreport-operator:latest
To remove the operator again:
make undeploy
quai.io will automatically build images from the latest tag in format
x.x.x
Make sure that ConfigMap
sosreport-global-configuration
fieldsosreport-image
points toquay.io/akaris/sosreport-centos:main
(that's also the default if unset)
Example custom resources can be deployed with:
make deploy-examples REGISTRY=registry.example.com:5000 SIMULATION_MODE=false IMAGE_PULL_POLICY="Always"
And for the RHEL image:
make deploy-examples REGISTRY=registry.example.com:5000 SIMULATION_MODE=false IMAGE_PULL_POLICY="Always" RHEL=true
And undeployed with:
make undeploy-examples
For environments that do not use RHEL for the OpenShift nodes such as kind, set
SIMULATION_MODE=true
For testing, set
IMAGE_PULL_POLICY
to "Always"
For OpenShift make sure to set a privileged SCC:
oc new-project sosreport-test
oc adm policy add-scc-to-user privileged -z default
make bundle REGISTRY=registry.example.com:5000
make bundle-build-podman REGISTRY=registry.example.com:5000
make bundle-push-podman REGISTRY=registry.example.com:5000
make bundle-validate-podman REGISTRY=registry.example.com:5000
make bundle REGISTRY=quay.io/akaris
Now, simply commit the current snapshot of the repository with a valid tag (e.g. 0.0.2).
Quay will automatically build an image from the tag.
For further details, see https://github.com/operator-framework/operator-registry#building-an-index-of-operators-using-opm
Prerequisites - installing OPM:
make opm
make index-build REGISTRY=registry.example.com:5000
make index-push-podman REGISTRY=registry.example.com:5000
make index-build REGISTRY=quay.io/akaris
podman login quay.io
make index-push-podman REGISTRY=quay.io/akaris
make deploy-index-subscription REGISTRY=registry.example.com:5000 CATALOG_SOURCE_NAMESPACE=olm
make deploy-index-subscription REGISTRY=quay.io/akaris CATALOG_SOURCE_NAMESPACE=openshift-marketplace
make undeploy-index-subscription
Running automated tests agains a testenv "fake" environment:
make test USE_EXISTING_CLUSTER=false
Running automated tests against a real environment
export KUBECONFIG=(...)
make test USE_EXISTING_CLUSTER=true REGISTRY=registry.example.com:5000
Running automated tests against a real environment with the RHEL image:
export KUBECONFIG=(...)
make test USE_EXISTING_CLUSTER=true REGISTRY=registry.example.com:5000 RHEL=true
If you want to tinker around with the sosreport operator image in a deployment that simulated the jobs that would otherwise be deployed by the operator, run:
make deploy-test-deployment REGISTRY=registry.example.com:5000 # for CentOS
make deploy-test-deployment REGISTRY=registry.example.com:5000 RHEL=true # for RHEL