k8s

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiscoverServices

func DiscoverServices(kubernetesConfig *Config) ([]*core.Service, error)

DiscoverServices return discovered services

func GetKubernetesServices

func GetKubernetesServices(client KubernetesClientApi, namespace string) ([]v1.Service, error)

GetKubernetesServices return a list of Services from the given namespace

Types

type ClusterMode

type ClusterMode string

ClusterMode is the mode to use to authenticate to Kubernetes

const (
	ClusterModeIn   ClusterMode = "in"
	ClusterModeOut  ClusterMode = "out"
	ClusterModeMock ClusterMode = "mock"
)

type Config

type Config struct {
	// AutoDiscover to discover services to monitor
	AutoDiscover bool `yaml:"auto-discover"`

	// ClusterMode is the mode to use to authenticate with Kubernetes
	ClusterMode ClusterMode `yaml:"cluster-mode"`

	// ServiceTemplate is the template for auto discovered services
	ServiceTemplate *core.Service `yaml:"service-template"`

	// ExcludedServiceSuffixes is a list of service suffixes that should be ignored
	ExcludedServiceSuffixes []string `yaml:"excluded-service-suffixes"`

	// Namespaces is a list of configurations for the namespaces from which services will be discovered
	Namespaces []*NamespaceConfig `yaml:"namespaces"`
}

Config for Kubernetes auto-discovery

type KubernetesClient

type KubernetesClient struct {
	// contains filtered or unexported fields
}

KubernetesClient is a working implementation of KubernetesClientApi

func NewKubernetesClient

func NewKubernetesClient(client *kubernetes.Clientset) *KubernetesClient

NewKubernetesClient creates a KubernetesClient

func (*KubernetesClient) GetServices

func (k *KubernetesClient) GetServices(namespace string) ([]v1.Service, error)

GetServices returns a list of services for a given namespace

type KubernetesClientApi

type KubernetesClientApi interface {
	GetServices(namespace string) ([]v1.Service, error)
}

KubernetesClientApi is a minimal interface for interacting with Kubernetes Created mostly to make mocking the Kubernetes client easier

func NewClient

func NewClient(clusterMode ClusterMode) (KubernetesClientApi, error)

NewClient creates a Kubernetes client for the given ClusterMode

type NamespaceConfig

type NamespaceConfig struct {
	// Name of the namespace
	Name string `yaml:"name"`

	// ExcludedServices is a list of services to exclude from the auto discovery
	ExcludedServices []string `yaml:"excluded-services"`

	// HostnameSuffix is a suffix to append to each service name before calling TargetPath
	HostnameSuffix string `yaml:"hostname-suffix"`

	// TargetPath Path to append after the HostnameSuffix
	TargetPath string `yaml:"target-path"`
}

NamespaceConfig level config

Jump to

Keyboard shortcuts

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