kubernetes

package
v0.1.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2020 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAllowedContextMap

func CreateAllowedContextMap(contexts []string) map[string]string

CreateAllowedContextMap creates a dummy map from context name to context name

func GetClientConfigFromServiceAccount

func GetClientConfigFromServiceAccount(
	sa *models.ServiceAccount,
	clusterID uint,
	updateTokenCache UpdateTokenCacheFunc,
) (clientcmd.ClientConfig, error)

GetClientConfigFromServiceAccount will construct new clientcmd.ClientConfig using the configuration saved within a ServiceAccount model

func GetContextsFromBytes

func GetContextsFromBytes(bytes []byte, allowedContexts []string) ([]models.Context, error)

GetContextsFromBytes converts a raw string to a set of Contexts by unmarshaling and calling toContexts

func GetRawConfigFromBytes

func GetRawConfigFromBytes(kubeconfig []byte) (*api.Config, error)

GetRawConfigFromBytes returns the clientcmdapi.Config from kubeconfig bytes

func GetRestrictedClientConfigFromBytes

func GetRestrictedClientConfigFromBytes(
	bytes []byte,
	contextName string,
	allowedContexts []string,
) (clientcmd.ClientConfig, error)

GetRestrictedClientConfigFromBytes returns a clientcmd.ClientConfig from a raw kubeconfig, a context name, and the set of allowed contexts.

func GetServiceAccountCandidates

func GetServiceAccountCandidates(kubeconfig []byte) ([]*models.ServiceAccountCandidate, error)

GetServiceAccountCandidates parses a kubeconfig for a list of service account candidates.

Types

type Agent

type Agent struct {
	RESTClientGetter genericclioptions.RESTClientGetter
	Clientset        kubernetes.Interface
}

Agent is a Kubernetes agent for performing operations that interact with the api server

func GetAgentInClusterConfig

func GetAgentInClusterConfig() (*Agent, error)

GetAgentInClusterConfig uses the service account that kubernetes gives to pods to connect

func GetAgentOutOfClusterConfig

func GetAgentOutOfClusterConfig(conf *OutOfClusterConfig) (*Agent, error)

GetAgentOutOfClusterConfig creates a new Agent using the OutOfClusterConfig

func GetAgentTesting

func GetAgentTesting(objects ...runtime.Object) *Agent

GetAgentTesting creates a new Agent using an optional existing storage class

func (*Agent) GetPodLogs

func (a *Agent) GetPodLogs(namespace string, name string, conn *websocket.Conn) error

GetPodLogs streams real-time logs from a given pod.

func (*Agent) GetPodsByLabel

func (a *Agent) GetPodsByLabel(selector string) (*v1.PodList, error)

GetPodsByLabel retrieves pods with matching labels

func (*Agent) ListNamespaces

func (a *Agent) ListNamespaces() (*v1.NamespaceList, error)

ListNamespaces simply lists namespaces

type OutOfClusterConfig

type OutOfClusterConfig struct {
	ServiceAccount   *models.ServiceAccount `form:"required"`
	ClusterID        uint                   `json:"cluster_id" form:"required"`
	UpdateTokenCache UpdateTokenCacheFunc
}

OutOfClusterConfig is the set of parameters required for an out-of-cluster connection. This implements RESTClientGetter

func (*OutOfClusterConfig) ToDiscoveryClient

func (conf *OutOfClusterConfig) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)

ToDiscoveryClient returns a CachedDiscoveryInterface using a computed RESTConfig It's required to implement the interface genericclioptions.RESTClientGetter

func (*OutOfClusterConfig) ToRESTConfig

func (conf *OutOfClusterConfig) ToRESTConfig() (*rest.Config, error)

ToRESTConfig creates a kubernetes REST client factory -- it calls ClientConfig on the result of ToRawKubeConfigLoader, and also adds a custom http transport layer if necessary (required for GCP auth)

func (*OutOfClusterConfig) ToRESTMapper

func (conf *OutOfClusterConfig) ToRESTMapper() (meta.RESTMapper, error)

ToRESTMapper returns a mapper

func (*OutOfClusterConfig) ToRawKubeConfigLoader

func (conf *OutOfClusterConfig) ToRawKubeConfigLoader() clientcmd.ClientConfig

ToRawKubeConfigLoader creates a clientcmd.ClientConfig from the raw kubeconfig found in the OutOfClusterConfig. It does not implement loading rules or overrides.

type UpdateTokenCacheFunc

type UpdateTokenCacheFunc func(token string, expiry time.Time) error

UpdateTokenCacheFunc is a function that updates the token cache with a new token and expiry time

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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