kube-cloudwatch-node-metrics

command module
v0.0.0-...-2399cf3 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2015 License: BSD-3-Clause Imports: 14 Imported by: 0

README

kube-cloudwatch-node-metrics

Emit AWS Cloudwatch metrics for Kubernetes node CPU usage for Autoscaling

kube-cloudwatch-node-metrics is a simple program that emits the percentage of CPU "reserved" on a Kubernetes node. It defines "reserved" CPU as the sum of all the compute resources of all the containers on a node. It uses requests if set, limits if requests is not set, and a default if neither are set.

kube-cloudwatch-node-metrics emits a single metric KubernetesCPUPercent in the Kubernetes Cloudwatch namespace every 60 seconds. This can be used for alerting and/or for configuring AWS autoscaling.

kube-cloudwatch-node-metrics should be run on each Kubernetes node. A daemonset is the preferred method. An example manifest is included.

Building and Using

This assumes you have enabled daemonsets in your Kubernetes cluster. The nodes also need permissions to describe instances, describe tags and push Cloudwatch metrics. A policy can be used, such as:

{
    "Version" : "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "ec2:DescribeInstances",
                "ec2:DescribeTags",
                "cloudwatch:PutMetricData"
            ],
            "Resource": "*"
            }
       ]
}

The simple way is to use the build script:

export DOCKER_REPO=my.docker.registry/mynamespace
docker login ${DOCKER_REPO}
./build.sh

This will build the binary and the Docker image. If DOCKER_REPO is set, it will also push to it.

Edit daemonset.json with the correct image information, and then create the daemonset using kubectl create -f daemonset.json.

Design

This initial version is extremely simple.

  • It does not handle API authentication. It assumes you will be running kubectl proxy in the same pod.
  • It does not use watches. It fetches the pods for the node on every run.
  • It curently only uses the Kubernetes API. It could use the "pods" end point on the kubelet.
  • It does not use the official Kubernetes Go API client. The official one has many dependencies and can challenging to build. This only uses a few structs, so doing it "by hand" is more straightforward.

TODO

LICENSE

see LICENSE

Authors

Written by the Engineering Team at Yik Yak

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Godeps
_workspace/src/github.com/aws/aws-sdk-go/aws
Package aws provides core functionality for making requests to AWS services.
Package aws provides core functionality for making requests to AWS services.
_workspace/src/github.com/aws/aws-sdk-go/aws/awserr
Package awserr represents API error interface accessors for the SDK.
Package awserr represents API error interface accessors for the SDK.
_workspace/src/github.com/aws/aws-sdk-go/aws/credentials
Package credentials provides credential retrieval and management The Credentials is the primary method of getting access to and managing credentials Values.
Package credentials provides credential retrieval and management The Credentials is the primary method of getting access to and managing credentials Values.
_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/stscreds
Package stscreds are credential Providers to retrieve STS AWS credentials.
Package stscreds are credential Providers to retrieve STS AWS credentials.
_workspace/src/github.com/aws/aws-sdk-go/aws/defaults
Package defaults is a collection of helpers to retrieve the SDK's default configuration and handlers.
Package defaults is a collection of helpers to retrieve the SDK's default configuration and handlers.
_workspace/src/github.com/aws/aws-sdk-go/aws/ec2metadata
Package ec2metadata provides the client for making API calls to the EC2 Metadata service.
Package ec2metadata provides the client for making API calls to the EC2 Metadata service.
_workspace/src/github.com/aws/aws-sdk-go/aws/session
Package session provides a way to create service clients with shared configuration and handlers.
Package session provides a way to create service clients with shared configuration and handlers.
_workspace/src/github.com/aws/aws-sdk-go/private/endpoints
Package endpoints validates regional endpoints for services.
Package endpoints validates regional endpoints for services.
_workspace/src/github.com/aws/aws-sdk-go/private/protocol/ec2query
Package ec2query provides serialisation of AWS EC2 requests and responses.
Package ec2query provides serialisation of AWS EC2 requests and responses.
_workspace/src/github.com/aws/aws-sdk-go/private/protocol/query
Package query provides serialisation of AWS query requests, and responses.
Package query provides serialisation of AWS query requests, and responses.
_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest
Package rest provides RESTful serialization of AWS requests and responses.
Package rest provides RESTful serialization of AWS requests and responses.
_workspace/src/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil
Package xmlutil provides XML serialisation of AWS requests and responses.
Package xmlutil provides XML serialisation of AWS requests and responses.
_workspace/src/github.com/aws/aws-sdk-go/private/signer/v4
Package v4 implements signing for AWS V4 signer
Package v4 implements signing for AWS V4 signer
_workspace/src/github.com/aws/aws-sdk-go/service/cloudwatch
Package cloudwatch provides a client for Amazon CloudWatch.
Package cloudwatch provides a client for Amazon CloudWatch.
_workspace/src/github.com/aws/aws-sdk-go/service/cloudwatch/cloudwatchiface
Package cloudwatchiface provides an interface for the Amazon CloudWatch.
Package cloudwatchiface provides an interface for the Amazon CloudWatch.
_workspace/src/github.com/aws/aws-sdk-go/service/ec2
Package ec2 provides a client for Amazon Elastic Compute Cloud.
Package ec2 provides a client for Amazon Elastic Compute Cloud.
_workspace/src/github.com/aws/aws-sdk-go/service/ec2/ec2iface
Package ec2iface provides an interface for the Amazon Elastic Compute Cloud.
Package ec2iface provides an interface for the Amazon Elastic Compute Cloud.
_workspace/src/github.com/go-ini/ini
Package ini provides INI file read and write functionality in Go.
Package ini provides INI file read and write functionality in Go.
_workspace/src/github.com/google/gofuzz
Package fuzz is a library for populating go objects with random values.
Package fuzz is a library for populating go objects with random values.
_workspace/src/github.com/spf13/pflag
pflag is a drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.
pflag is a drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.
_workspace/src/speter.net/go/exp/math/dec/inf
Package inf (type inf.Dec) implements "infinite-precision" decimal arithmetic.
Package inf (type inf.Dec) implements "infinite-precision" decimal arithmetic.

Jump to

Keyboard shortcuts

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