Giter VIP home page Giter VIP logo

k8s_api's Introduction

k8s_api

Name

k8s_api - a CoreDNS plugin that enables other plugins to register/share Kubernetes API watches.

Description

k8s_api enables any plugin that implements the k8sapi.APIWatcher interface to register Kubernetes API informers and share access to object stores.

type APIWatcher interface {

	// Informers should return a list of functions that return an Kubernetes Object Informer, each mapped by watch name.
	// k8s_api will start each Informer on the API connection. If multiple plugins return an Informer func with the same
	// name, the first plugin (per plugin execution order), will take precedence.
	Informers() map[string]InformerFunc

	// SetIndexer should set the index passed to a local pointer to be used by the plugin.  k8s_api calls this function
	// for *all* Informers added via the Informers() function by any plugins implementing APIWatcher. This enables
	// multiple plugins to share the same store/index managed by a single Informer.
	SetIndexer(string, cache.KeyListerGetter) error

	// SetHasSynced should set the HasSyncedFunc passed to a local function to be used by the plugin. Implement this
	// if the plugin needs to know if the API informers have fully synced (i.e. completed initial list action before
	// beginning the watch).
	SetHasSynced(HasSyncedFunc)
}

Syntax

k8s_api {
    endpoint URL
    tls CERT KEY CACERT
    kubeconfig KUBECONFIG CONTEXT
}

  • endpoint specifies the URL for a remote k8s API endpoint. If omitted, it will connect to k8s in-cluster using the cluster service account.
  • tls CERT KEY CACERT are the TLS cert, key and the CA cert file names for remote k8s connection. This option is ignored if connecting in-cluster (i.e. endpoint is not specified).
  • kubeconfig KUBECONFIG CONTEXT authenticates the connection to a remote k8s cluster using a kubeconfig file. It supports TLS, username and password, or token-based authentication. This option is ignored if connecting in-cluster (i.e., the endpoint is not specified).

External Plugin

k8s_api is an external plugin, which means it is not included in CoreDNS releases. To use k8s_api, you'll need to build a CoreDNS image with k8s_api. In a nutshell you'll need to:

  • Clone https://github.com/coredns/coredns into $GOPATH/src/github.com/coredns
  • Add this plugin to plugin.cfg per instructions therein. This plugin must be ordered after any plugins that use it (i.e. plugins that implement APIWatcher).
  • make -f Makefile.release DOCKER=your-docker-repo release
  • make -f Makefile.release DOCKER=your-docker-repo docker
  • make -f Makefile.release DOCKER=your-docker-repo docker-push

Examples

Example plugins that implement k8sapi.APIWatcher can be found in the examples directory.

k8s_api's People

Contributors

chrisohaver avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

k8s_api's Issues

Fix plugin loading order dependence

Currently, the order in which k8s_api is registered is important in relation to other plugins. However, that order is not predictable, since CoreDNS iterates through a map to load them.

Two possible fixes:

  1. Change CoreDNS to initialize the plugins in order (the order established in plugin.cfg). This is a simple and harmless fix, but it has been proposed and rejected before in CoreDNS.
  2. Change k8s_api to defer looking for plugins that implement APIWatcher until after all plugins are registered (OnStartup). This makes the code a bit tougher to follow, and requires that k8s_api actually sit in the plugin packet serving path even though it has no functional need to process packets. But this doesn't require any change to CoreDNS.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.