{"id":29776822,"url":"https://github.com/jsenon/api-cni-cleanup","last_synced_at":"2025-07-27T10:18:55.090Z","repository":{"id":57524038,"uuid":"147855095","full_name":"jsenon/api-cni-cleanup","owner":"jsenon","description":"Kubernetes CNI cleanner","archived":false,"fork":false,"pushed_at":"2019-07-01T09:24:50.000Z","size":5158,"stargazers_count":28,"open_issues_count":2,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-18T02:47:54.906Z","etag":null,"topics":["cleanner","cni","k8s","kubernetes"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsenon.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-07T17:32:24.000Z","updated_at":"2023-03-23T11:29:07.000Z","dependencies_parsed_at":"2022-09-15T18:24:07.459Z","dependency_job_id":null,"html_url":"https://github.com/jsenon/api-cni-cleanup","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jsenon/api-cni-cleanup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsenon%2Fapi-cni-cleanup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsenon%2Fapi-cni-cleanup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsenon%2Fapi-cni-cleanup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsenon%2Fapi-cni-cleanup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsenon","download_url":"https://codeload.github.com/jsenon/api-cni-cleanup/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsenon%2Fapi-cni-cleanup/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267342668,"owners_count":24071950,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cleanner","cni","k8s","kubernetes"],"created_at":"2025-07-27T10:18:49.044Z","updated_at":"2025-07-27T10:18:55.085Z","avatar_url":"https://github.com/jsenon.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CNI Cleaner API\n\n[![CircleCI](https://circleci.com/gh/jsenon/api-cni-cleanup.svg?style=svg)](https://circleci.com/gh/jsenon/api-cni-cleanup)\n[![Go Report Card](https://goreportcard.com/badge/github.com/jsenon/api-cni-cleanup)](https://goreportcard.com/report/github.com/jsenon/api-cni-cleanup)\n\n## Func\n\n- Remove unecessary cni file on kubernetes nodes (Running Pod/Orphaned Pod)\n- Exports CNI file number in Prometheus endpoint\n- Use Opencensus for tracing and metrics support\n\n### Prerequisite\n\nThis application must run inside kubernetes cluster.\n\nIt's recommended to run it must on Daemonset in order to access to all nodes where the cni files are located.\n\n### Deployment\n\nDeployment on Kubernetes cluster:\n\n```sh\nkubectl apply -f k8s/deployment.yml\n```\n\nWe will deploy:\n\n- RBAC Compatibility\n- Cronjob to launch cleanup each Monday\n- Service\n- Daemonset\n\n### Usage\n\n```sh\nCNI File Cleanner and Monitoring\n\nUsage:\n  api-cni-cleanup [command]\n\nAvailable Commands:\n  clean       Launch CNI Cleanner\n  help        Help about any command\n  job         Job Cleanner\n  server      Launch CNI Cleanner Server\n\nFlags:\n      --api string         External or Internal K8S cluster (default \"internal\")\n      --cnifiles string    Set CNI Folder (default \"/var/lib/cni\")\n      --config string      config file (default is $HOME/.api-cni-cleanup.yaml)\n      --debug              Set log level to Debug\n  -h, --help               help for api-cni-cleanup\n      --jaegerurl string   Set jaegger collector endpoint\n\nUse \"api-cni-cleanup [command] --help\" for more information about a command.\n```\n\n### Run Server Mode\n\nWhen you launch application in server mode you will have prometheus metrics:\n\n```sh\napi-cni-cleanup server --api APITYPE --cnifiles YOURCNIFOLDER\n```\n\nPrometheus metrics are available on:\n\n- [http://localhost:9010/metrics](http://localhost:9010/metrics)\n\nStats are:\n\n```text\n# HELP apicnicleanup_number_count number of files\n# TYPE apicnicleanup_number_count gauge\napicnicleanup_number_count XX\n# HELP apicnicleanup_size_bytes Size of the folder\n# TYPE apicnicleanup_size_bytes gauge\napicnicleanup_size_bytes XX\n```\n\nApi entrypoint to launch the cleaning is:\n\n- [http://localhost:9010/cleanup](http://localhost:9010/cleanup)\n\n### Run Job Mode\n\nIn order to schedule the cleaning with a cronjob you can launch application in job mode:\n\nContact API CNI Cleanner:\n\n```sh\napi-cni-cleanup job --urlserver http://127.0.0.1:9010/cleanup,http://192.168.0.2:9010/cleanup\n```\n\nFor automatic discovery, actually based on daemonset name and port:\n\n```sh\napi-cni-cleanup job --autodiscover\n```\n\nJust specify all you `urlserver` that's represent all you api-cni-cleanup servers\n\n### (OPTIONAL) Run Batch Mode\n\nThis application could be launch on demand. But you need to know where your pod is deployed in order to clean cni file on a targeted node.\n\nBatch Mode cleaning:\n\n```sh\napi-cni-cleanup clean --api APITYPE --cnifiles YOURCNIFOLDER\n```\n\n### TIPS\n\nVendoring [constraint](https://github.com/kubernetes/minikube/issues/3037#issuecomment-418384405)\n\n### TODO\n\n- [x] Create New Metric on Prometheus = Count files + Folder Size\n- [x] Diff IP files and API PodIP\n- [x] Remove files unused\n- [x] Api to launch cleanup\n- [x] k8s deployment: DaemonSet + svc + Cronjob\n- [ ] Redefine api entrypoint with naming convention\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsenon%2Fapi-cni-cleanup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsenon%2Fapi-cni-cleanup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsenon%2Fapi-cni-cleanup/lists"}