api-cni-cleanup

command module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2019 License: Apache-2.0 Imports: 1 Imported by: 0

README

CNI Cleaner API

CircleCI Go Report Card

Func

  • Remove unecessary cni file on kubernetes nodes (Running Pod/Orphaned Pod)
  • Exports CNI file number in Prometheus endpoint
  • Use Opencensus for tracing and metrics support
Prerequisite

This application must run inside kubernetes cluster.

It's recommended to run it must on Daemonset in order to access to all nodes where the cni files are located.

Deployment

Deployment on Kubernetes cluster:

kubectl apply -f k8s/deployment.yml

We will deploy:

  • RBAC Compatibility
  • Cronjob to launch cleanup each Monday
  • Service
  • Daemonset
Usage
CNI File Cleanner and Monitoring

Usage:
  api-cni-cleanup [command]

Available Commands:
  clean       Launch CNI Cleanner
  help        Help about any command
  job         Job Cleanner
  server      Launch CNI Cleanner Server

Flags:
      --api string         External or Internal K8S cluster (default "internal")
      --cnifiles string    Set CNI Folder (default "/var/lib/cni")
      --config string      config file (default is $HOME/.api-cni-cleanup.yaml)
      --debug              Set log level to Debug
  -h, --help               help for api-cni-cleanup
      --jaegerurl string   Set jaegger collector endpoint

Use "api-cni-cleanup [command] --help" for more information about a command.
Run Server Mode

When you launch application in server mode you will have prometheus metrics:

api-cni-cleanup server --api APITYPE --cnifiles YOURCNIFOLDER

Prometheus metrics are available on:

Stats are:

# HELP apicnicleanup_number_count number of files
# TYPE apicnicleanup_number_count gauge
apicnicleanup_number_count XX
# HELP apicnicleanup_size_bytes Size of the folder
# TYPE apicnicleanup_size_bytes gauge
apicnicleanup_size_bytes XX

Api entrypoint to launch the cleaning is:

Run Job Mode

In order to schedule the cleaning with a cronjob you can launch application in job mode:

Contact API CNI Cleanner:

api-cni-cleanup job --urlserver http://127.0.0.1:9010/cleanup,http://192.168.0.2:9010/cleanup

For automatic discovery, actually based on daemonset name and port:

api-cni-cleanup job --autodiscover

Just specify all you urlserver that's represent all you api-cni-cleanup servers

(OPTIONAL) Run Batch Mode

This 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.

Batch Mode cleaning:

api-cni-cleanup clean --api APITYPE --cnifiles YOURCNIFOLDER
TIPS

Vendoring constraint

TODO
  • Create New Metric on Prometheus = Count files + Folder Size
  • Diff IP files and API PodIP
  • Remove files unused
  • Api to launch cleanup
  • k8s deployment: DaemonSet + svc + Cronjob
  • Redefine api entrypoint with naming convention

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
pkg
kubernetes
Package kubernetes Manage connection to kubernetes
Package kubernetes Manage connection to kubernetes

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL