{"id":26493987,"url":"https://github.com/dwarvesf/kubewise-operator","last_synced_at":"2025-03-20T09:58:31.815Z","repository":{"id":253796855,"uuid":"844554352","full_name":"dwarvesf/kubewise-operator","owner":"dwarvesf","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-13T10:33:23.000Z","size":153,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-14T00:09:28.446Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dwarvesf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-19T13:50:13.000Z","updated_at":"2024-09-13T10:33:27.000Z","dependencies_parsed_at":"2024-09-12T20:38:13.675Z","dependency_job_id":null,"html_url":"https://github.com/dwarvesf/kubewise-operator","commit_stats":null,"previous_names":["dwarvesf/kubewise-operator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwarvesf%2Fkubewise-operator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwarvesf%2Fkubewise-operator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwarvesf%2Fkubewise-operator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwarvesf%2Fkubewise-operator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dwarvesf","download_url":"https://codeload.github.com/dwarvesf/kubewise-operator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244591451,"owners_count":20477709,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-20T09:58:31.152Z","updated_at":"2025-03-20T09:58:31.806Z","avatar_url":"https://github.com/dwarvesf.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kubewise-operator\nThis project is designed to provide a Kubernetes operator framework that automates the deployment, management, and scaling of cloud cost optimization resources in a Kubernetes cluster.\n\n## Description\nKubewise-operator helps users save costs by dynamically managing cloud resources related to Kubernetes workloads. This operator implements custom resource definitions (CRDs) to extend Kubernetes capabilities, making it easy to optimize workloads on various cloud providers.\n\n## Features\n- Automatic resource optimization based on historical usage metrics\n- Configurable analysis intervals and cost-saving thresholds\n- Support for ignoring specific resources (Deployments, StatefulSets, DaemonSets) from optimization\n- Integration with Prometheus for metric collection\n- Discord notifications for optimization recommendations\n\n## Roadmap\n\n### Implemented Features\n- [x] Basic CloudCostOptimizer CRD definition\n- [x] Resource analysis based on historical metrics\n- [x] Configurable analysis intervals\n- [x] Ignore specific resources (Deployments, StatefulSets, DaemonSets)\n- [x] Prometheus integration for metric collection\n- [x] Discord notifications for optimization recommendations\n\n### Planned Features\n- [ ] Cost-saving threshold configuration\n- [ ] Machine learning-based predictive optimization\n- [ ] Integration with cloud-specific cost management APIs\n- [ ] User interface for visualization and manual control\n- [ ] Multi-cluster support\n- [ ] Custom metric support beyond Prometheus\n- [ ] Automated rollback of optimizations if performance degrades\n- [ ] Integration with other notification platforms (Slack, Email, etc.)\n- [ ] Cost allocation and chargeback features\n- [ ] Support for optimizing storage resources\n\n## Project Structure\nThe project follows a standard Kubernetes operator structure:\n\n- `api/v1alpha1/`: Contains the API definitions for the CloudCostOptimizer CRD\n- `controllers/`: Contains the main logic for the operator\n- `config/`: Contains Kubernetes manifests for deploying the operator\n- `Dockerfile`: Defines the container image for the operator\n- `main.go`: The entry point of the operator\n\nKey files:\n- `api/v1alpha1/cloudcostoptimizer_types.go`: Defines the CloudCostOptimizer CRD\n- `controllers/cloudcostoptimizer_controller.go`: Main reconciliation loop\n- `controllers/cloudcostoptimizer_analyze.go`: Resource analysis and optimization logic\n- `config/samples/optimization_v1alpha1_cloudcostoptimizer.yaml`: Sample CloudCostOptimizer resource\n\n## Getting Started\n\n### Prerequisites\n- Go version v1.21.0+ (https://golang.org/doc/install)\n- Docker version 17.03+ (https://docs.docker.com/get-docker/)\n- kubectl version v1.11.3+ (https://kubernetes.io/docs/tasks/tools/)\n- Access to a Kubernetes v1.11.3+ cluster\n- Kubernetes cluster with Prometheus installed (for metric collection)\n- kustomize v3.8.7+ (https://kustomize.io/)\n- Operator SDK v1.28.0+ (https://sdk.operatorframework.io/docs/installation/)\n- A container registry account (e.g., Docker Hub) to store the operator image\n\nOptional:\n- Discord webhook URL and bot token (for notifications)\n\n### Development Environment Setup\n1. Install Go, Docker, kubectl, and kustomize using the links provided above.\n2. Install the Operator SDK:\n   ```sh\n   export ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac)\n   export OS=$(uname | awk '{print tolower($0)}')\n   export OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.28.0\n   curl -LO ${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH}\n   chmod +x operator-sdk_${OS}_${ARCH} \u0026\u0026 sudo mv operator-sdk_${OS}_${ARCH} /usr/local/bin/operator-sdk\n   ```\n3. Clone the kubewise-operator repository:\n   ```sh\n   git clone https://github.com/your-org/kubewise-operator.git\n   cd kubewise-operator\n   ```\n\n### To Deploy on the cluster\n**Build and push your image to the location specified by `IMG`:**\n\n```sh\nmake docker-build docker-push IMG=\u003csome-registry\u003e/kubewise-operator:tag\n```\n\n**NOTE:** This image ought to be published in the personal registry you specified.\nAnd it is required to have access to pull the image from the working environment.\nMake sure you have the proper permission to the registry if the above commands don't work.\n\n**Install the CRDs into the cluster:**\n\n```sh\nmake install\n```\n\n**Deploy the Manager to the cluster with the image specified by `IMG`:**\n\n```sh\nmake deploy IMG=\u003csome-registry\u003e/kubewise-operator:tag\n```\n\n\u003e **NOTE**: If you encounter RBAC errors, you may need to grant yourself cluster-admin\nprivileges or be logged in as admin.\n\n**Create instances of your solution**\nYou can apply the samples (examples) from the config/sample:\n\n```sh\nkubectl apply -k config/samples/\n```\n\n\u003e**NOTE**: Ensure that the samples has default values to test it out.\n\n### Configuration\n\nThe CloudCostOptimizer custom resource allows you to configure various aspects of the optimization process. Here's an example configuration:\n\n```yaml\napiVersion: optimization.dwarvesf.com/v1alpha1\nkind: CloudCostOptimizer\nmetadata:\n  name: cloudcostoptimizer-sample\nspec:\n  analysisInterval: \"1h\"\n  targets:\n    - resources: [\"pods\"]\n      namespaces: [\"default\", \"kube-system\"]\n      automateOptimization: false\n      ignoreResources:\n        deployment: [\"important-deployment\", \"critical-app\"]\n        statefulSet: [\"database\"]\n        daemonSet: [\"monitoring-agent\"]\n  costSavingThreshold: 10\n  prometheusConfig:\n    serverAddress: \"http://prometheus-server.monitoring\"\n    historicalMetricDuration: 6h\n  communication:\n    discord:\n      webhookURL: \"https://discord.com/api/webhooks/your-webhook-url\"\n      botToken: \"your-discord-bot-token\"\n```\n\nThis configuration sets up the CloudCostOptimizer to:\n- Analyze resources every hour\n- Target pods in the \"default\" and \"kube-system\" namespaces\n- Ignore specific deployments, statefulsets, and daemonsets\n- Set a cost-saving threshold of 10%\n- Use Prometheus for historical metrics\n- Send notifications to Discord using both a webhook URL and a bot token\n\n#### ArgoCD Integration\n\nWhen using the `automateOptimization` feature with ArgoCD, you need to configure ArgoCD to ignore the changes made by the CloudCostOptimizer. This is because the operator will automatically adjust resource configurations, which may conflict with ArgoCD's sync process.\n\nTo configure ArgoCD to ignore these changes, add the following `ignoreDifferences` section to your Application or ApplicationSet:\n\n```yaml\nspec:\n  ignoreDifferences:\n    - group: apps\n      kind: Deployment\n      jsonPointers:\n        - /spec/template/spec/containers/0/resources\n```\n\nThis configuration tells ArgoCD to ignore differences in the container resources specification, which is where the CloudCostOptimizer makes its optimizations. You can adjust the `jsonPointers` as needed to match the specific resources you want ArgoCD to ignore.\n\nBy applying this configuration, you can ensure that ArgoCD and the CloudCostOptimizer work together harmoniously, allowing the operator to make resource optimizations without triggering unnecessary syncs or conflicts in ArgoCD.\n\n### To Uninstall\n**Delete the instances (CRs) from the cluster:**\n\n```sh\nkubectl delete -k config/samples/\n```\n\n**Delete the APIs(CRDs) from the cluster:**\n\n```sh\nmake uninstall\n```\n\n**UnDeploy the controller from the cluster:**\n\n```sh\nmake undeploy\n```\n\n## Project Distribution\n\nFollowing are the steps to build the installer and distribute this project to users.\n\n1. Build the installer for the image built and published in the registry:\n\n```sh\nmake build-installer IMG=\u003csome-registry\u003e/kubewise-operator:tag\n```\n\nNOTE: The makefile target mentioned above generates an 'install.yaml'\nfile in the dist directory. This file contains all the resources built\nwith Kustomize, which are necessary to install this project without\nits dependencies.\n\n2. Using the installer\n\nUsers can just run kubectl apply -f \u003cURL for YAML BUNDLE\u003e to install the project, i.e.: \n\n```sh\nkubectl apply -f https://raw.githubusercontent.com/\u003corg\u003e/kubewise-operator/\u003ctag or branch\u003e/dist/install.yaml\n```\n\n## Contributing\nTo contribute to this project, please follow these guidelines:\n1. Fork the repository.\n2. Create a feature branch.\n3. Make your changes and commit them.\n4. Push your branch to GitHub.\n5. Create a pull request.\n\nFor detailed information on contribution processes and coding standards, please refer to the CONTRIBUTING.md file (to be created).\n\n**NOTE:** Run `make help` for more information on all potential `make` targets\n\nMore information can be found via the [Kubebuilder Documentation](https://book.kubebuilder.io/introduction.html)\n\n## License\n\nCopyright 2024.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwarvesf%2Fkubewise-operator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdwarvesf%2Fkubewise-operator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwarvesf%2Fkubewise-operator/lists"}