kubeapi

package module
v0.0.0-...-e4e9337 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2022 License: Apache-2.0 Imports: 12 Imported by: 7

README

kubeapi

Name

kubeapi - configures a Kubernetes API client.

Description

kubeapi configures a Kubernetes API client and makes it available to other plugins.

Plugins that wish to use the Kubernetes API client can call kubeapi.Client() after the server starts, e.g. via caddy.OnStartup.

Syntax

kubeapi {
    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. [CONTEXT] is optional, if not set, then the current context specified in kubeconfig will be used. 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

To use this plugin, compile CoreDNS with this plugin added to plugin.cfg. It should be placed at/near the end of the chain of plugins.

Examples

The kubenodes plugin (https://github.com/infobloxopen/kubenodes) uses kubeapi to connect to the Kubernetes API.

. {
  kubeapi
  kubenodes node.cluster.local in-addr.arpa ip6.arpa
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client

func Client(config *dnsserver.Config) (kubernetes.Interface, error)

Client returns the Kubernetes API client defined by kubeapi plugin in the server config. This should only be called after all plugins have loaded, e.g. from a caddy Controller OnStartup function.

Types

type KubeAPI

type KubeAPI struct {
	Next plugin.Handler

	APIServer     string
	APICertAuth   string
	APIClientCert string
	APIClientKey  string
	ClientConfig  clientcmd.ClientConfig

	Client kubernetes.Interface
}

KubeAPI implements a plugin that establishes a Kubernetes API client.

func (*KubeAPI) InitAPIConn

func (k *KubeAPI) InitAPIConn(ctx context.Context) (err error)

InitAPIConn initializes the Kubernetes API client

func (KubeAPI) Name

func (k KubeAPI) Name() string

Name implements the Handler interface.

func (KubeAPI) ServeDNS

func (k KubeAPI) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

ServeDNS implements the plugin.Handler interface.

Jump to

Keyboard shortcuts

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