A Kubernetes Operator to automate deployment of Kruize Autotune, a resource optimization tool for Kubernetes workloads.
The Kruize operator simplifies deployment and management of Kruize on Kubernetes and OpenShift clusters. It provides a declarative way to configure and deploy Kruize components including the core Kruize service and UI through Custom Resource Definitions (CRDs).
For examples of running Kruize and the operator, see kruize-demos. You can customize the YAML file (found in config/samples) to deploy with your preferred options.
- Kruize Autotune - Main Kruize service providing resource optimization recommendations
- kruize-ui - Web interface for Kruize
- kruize-demos - Example deployments and demonstrations
For Deployment:
- kubectl version v1.23.0+
- Access to a Kubernetes v1.23.0+ or OpenShift v4.10+ cluster
- Prometheus (for Minikube, Kind clusters)
For Building/Development:
- Go version v1.21.0+ (tested with v1.22.5 and v1.24.0)
- operator-sdk v1.37.0+ (as specified in Makefile)
- Docker version 17.03+
The operator uses Kustomize overlays to manage platform-specific configurations:
- OpenShift (default): Deploys to
openshift-tuningnamespace - Local (Minikube/KIND): Deploys to
monitoringnamespace
Quick Start:
- Build and push your image:
make docker-build docker-push IMG=<some-registry>/kruize-operator:tag
NOTE: Ensure the image is published to a registry accessible from your cluster.
-
Install the CRDs:
make install
-
Deploy the operator:
Platform Command Namespace OpenShift make deploy-openshift IMG=<registry>/kruize-operator:tagopenshift-tuningMinikube make deploy-minikube IMG=<registry>/kruize-operator:tagmonitoringKIND make deploy-kind IMG=<registry>/kruize-operator:tagmonitoringNote:
IMGparameter is optional. If not specified, the default image from the Makefile will be used.Alternative: Use
make deploy OVERLAY=<openshift\|local> IMG=<registry>/kruize-operator:tag -
Create a Kruize instance:
# For OpenShift kubectl apply -f config/samples/v1alpha1_kruize.yaml -n openshift-tuning # For Minikube/KIND kubectl apply -f config/samples/v1alpha1_kruize.yaml -n monitoring
NOTE: Before applying for Minikube/KIND, update
config/samples/v1alpha1_kruize.yaml:- Set
cluster_type: "minikube"orcluster_type: "kind" - Set
namespace: "monitoring"(instead of"openshift-tuning")
- Set
For detailed deployment options, overlay configurations, and advanced usage, see config/overlays/README.md.
NOTE: If you encounter RBAC errors, you may need to grant yourself cluster-admin privileges or be logged in as admin.
-
Delete the Kruize instance(CR):
# For OpenShift kubectl delete -f config/samples/v1alpha1_kruize.yaml -n openshift-tuning # For Minikube/KIND kubectl delete -f config/samples/v1alpha1_kruize.yaml -n monitoring
-
Undeploy the controller:
make undeploy-openshift # For OpenShift make undeploy-minikube # For Minikube make undeploy-kind # For KIND
-
Delete the CRDs:
make uninstall
For more undeployment options, see config/overlays/README.md.
See Prerequisites section above for required tools and versions.
Instructions
make generate manifests will trigger code/YAML generation and compile the operator controller manager.
make docker-build IMG=<registry>/kruize-operator:tag will build an OCI image. If IMG is not specified, the default image from the Makefile will be used.
make bundle will create an OLM bundle in the bundle/ directory. make bundle-build will create an OCI image of this bundle.
make catalog-build will build an OCI image of the operator catalog.
Run the operator locally:
make runThis runs the controller manager as a process on your local machine. Note that it will not have access to certain in-cluster resources.
Run unit tests:
make testRun end-to-end tests:
The test-e2e target supports optional flags for customizing the test environment:
# Default (OpenShift cluster)
make test-e2eThis requires a Kubernetes or OpenShift cluster. Recommended: Minikube, KIND, or OpenShift.
For detailed testing documentation, see:
Apache License 2.0, see LICENSE.