kube-deployments-notifier

command module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

README

kube-deployments-notifier

Build Status Coverage Status Go Report Card

An example Kubernetes controller that list and watch deployments, and send them as json payload to a remote API endpoint.

Build

Assuming you have go 1.14:

make build

Usage

The daemon may run either as a pod, or outside of the Kubernetes cluster. He should find the Kubernetes api-server automatically (or you can use the "-s" or "-k" flags). You can pass parameters from cli args, env, config files, or both.

Example:

kube-deployments-notifier \
  -l 'vendor=mycompany,app!=mmp-database' \
  -t Authorization -a "Bearer vbnf3hjklp5iuytre" \
  -e http://myapiserver:8042 

The command line flags are (all optionals):

Usage:
  kube-deployments-notifier [flags]

Flags:
  -s, --api-server string      kube api server url
  -x, --context string         kube context
  -c, --config string          configuration file (default "/etc/kdn/kube-deployments-notifier.yaml")
  -d, --dry-run                dry-run mode
  -e, --endpoint string        API endpoint
  -l, --filter string          Label filter
  -p, --healthcheck-port int   port for answering healthchecks
  -h, --help                   help for kube-deployments-notifier
  -k, --kube-config string     kube config path
  -v, --log-level string       log level (default "debug")
  -o, --log-output string      log output (default "stderr")
  -r, --log-server string      log server (if using syslog)
  -i, --resync-interval int    resync interval in seconds (0 to disable) (default 900)
  -t, --token-header string    token header name
  -a, --token-value string     token header value

Using an (optional) configuration file:

dry-run: false
healthcheck-port: 8080
api-server: http://example.com:8080
endpoint: https://my-api-endpoint/foo/bar
token-header: Authorization
token-value: "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9"
filter: "vendor=mycompany,app!=mmp-database"
resync-interval: 900

log:
  output: "stdout"
  level: "debug"

The environment variable consumed by kube-deployments-notifier are option names prefixed by KDN_ and using underscore instead of dash. Except KUBECONFIG, used without a prefix (to match kubernetes conventions).

Docker image

A ready to use, public docker image is available at Docker Hub, published at each release. You can use it directly from your Kubernetes deployments, ie.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: kube-deployments-notifier
  namespace: kube-system
  labels:
    k8s-app: kube-deployments-notifier
spec:
  selector:
    matchLabels:
      k8s-app: kube-deployments-notifier
  replicas: 1
  template:
    metadata:
      labels:
        k8s-app: kube-deployments-notifier
    spec:
      containers:
        - name: kube-deployments-notifier
          image: bpineau/kube-deployments-notifier:0.3.0
          args:
            - --log-output=stdout
            - --filter=vendor=mycompany,app!=mmp-database
            - --endpoint=http://mycollector
            - --healthcheck-port=8080
          resources:
            requests:
              cpu: 0.1
              memory: 50Mi
            limits:
              cpu: 0.2
              memory: 100Mi
          livenessProbe:
            httpGet:
              path: /health
              port: 8080
            timeoutSeconds: 5
            initialDelaySeconds: 10

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg
clientset
Package clientset initialize a Kubernete's client-go "clientset" (an initialized connection to the Kubernete's api-server) according the configuration.
Package clientset initialize a Kubernete's client-go "clientset" (an initialized connection to the Kubernete's api-server) according the configuration.
controllers
Package controllers is responsible for watching resources and calling notifiers on creation/change/deletion events.
Package controllers is responsible for watching resources and calling notifiers on creation/change/deletion events.
health
Package health serves healthchecks over HTTP at /health endpoint.
Package health serves healthchecks over HTTP at /health endpoint.
log
Package log initialize and configure a logrus logger.
Package log initialize and configure a logrus logger.
notifiers/http
Package http notifier convey events notifications as json payloads to a configured HTTP API endpoint.
Package http notifier convey events notifications as json payloads to a configured HTTP API endpoint.
notifiers/null
Package null is a no-op Notifier.
Package null is a no-op Notifier.
run
Package run implements the main kube-deployments-controller's loop, by launching the healthcheck service and all known controllers.
Package run implements the main kube-deployments-controller's loop, by launching the healthcheck service and all known controllers.

Jump to

Keyboard shortcuts

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