kubernetes

package
v0.0.47 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CustomAuthorizationHeader = HeaderKey("kubernetes-authorization")
	OAuthAuthorizationHeader  = HeaderKey("Authorization")

	CustomUserAgent = "kubernetes-mcp-server/bearer-token-auth"
)
View Source
const (
	AppKubernetesComponent = "app.kubernetes.io/component"
	AppKubernetesManagedBy = "app.kubernetes.io/managed-by"
	AppKubernetesName      = "app.kubernetes.io/name"
	AppKubernetesPartOf    = "app.kubernetes.io/part-of"
)

Variables

View Source
var InClusterConfig = func() (*rest.Config, error) {

	inClusterConfig, err := rest.InClusterConfig()
	if inClusterConfig != nil {
		inClusterConfig.Host = "https://kubernetes.default.svc"
	}
	return inClusterConfig, err
}

InClusterConfig is a variable that holds the function to get the in-cluster config Exposed for testing

View Source
var Scheme = scheme.Scheme

Functions

This section is empty.

Types

type AccessControlClientset

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

AccessControlClientset is a limited clientset delegating interface to the standard kubernetes.Clientset Only a limited set of functions are implemented with a single point of access to the kubernetes API where apiVersion and kinds are checked for allowed access

func NewAccessControlClientset

func NewAccessControlClientset(cfg *rest.Config, staticConfig *config.StaticConfig) (*AccessControlClientset, error)

func (*AccessControlClientset) DiscoveryClient

func (*AccessControlClientset) Pods

func (a *AccessControlClientset) Pods(namespace string) (corev1.PodInterface, error)

func (*AccessControlClientset) PodsExec

func (a *AccessControlClientset) PodsExec(namespace, name string, podExecOptions *v1.PodExecOptions) (remotecommand.Executor, error)

func (*AccessControlClientset) PodsMetricses

func (a *AccessControlClientset) PodsMetricses(ctx context.Context, namespace, name string, listOptions metav1.ListOptions) (*metrics.PodMetricsList, error)

func (*AccessControlClientset) SelfSubjectAccessReviews

func (*AccessControlClientset) Services

func (a *AccessControlClientset) Services(namespace string) (corev1.ServiceInterface, error)

func (*AccessControlClientset) TokenReview

TokenReview returns TokenReviewInterface

type AccessControlRESTMapper

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

func NewAccessControlRESTMapper

func NewAccessControlRESTMapper(delegate *restmapper.DeferredDiscoveryRESTMapper, staticConfig *config.StaticConfig) *AccessControlRESTMapper

func (AccessControlRESTMapper) KindFor

func (AccessControlRESTMapper) KindsFor

func (AccessControlRESTMapper) RESTMapping

func (a AccessControlRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string) (*meta.RESTMapping, error)

func (AccessControlRESTMapper) RESTMappings

func (a AccessControlRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string) ([]*meta.RESTMapping, error)

func (AccessControlRESTMapper) Reset

func (a AccessControlRESTMapper) Reset()

func (AccessControlRESTMapper) ResourceFor

func (AccessControlRESTMapper) ResourceSingularizer

func (a AccessControlRESTMapper) ResourceSingularizer(resource string) (singular string, err error)

func (AccessControlRESTMapper) ResourcesFor

type CloseWatchKubeConfig

type CloseWatchKubeConfig func() error

type HeaderKey

type HeaderKey string

type Kubernetes

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

func (*Kubernetes) EventsList

func (k *Kubernetes) EventsList(ctx context.Context, namespace string) ([]map[string]any, error)

func (*Kubernetes) NamespaceOrDefault

func (k *Kubernetes) NamespaceOrDefault(namespace string) string

func (*Kubernetes) NamespacesList

func (k *Kubernetes) NamespacesList(ctx context.Context, options ResourceListOptions) (runtime.Unstructured, error)

func (*Kubernetes) NewHelm

func (k *Kubernetes) NewHelm() *helm.Helm

func (*Kubernetes) PodsDelete

func (k *Kubernetes) PodsDelete(ctx context.Context, namespace, name string) (string, error)

func (*Kubernetes) PodsExec

func (k *Kubernetes) PodsExec(ctx context.Context, namespace, name, container string, command []string) (string, error)

func (*Kubernetes) PodsGet

func (k *Kubernetes) PodsGet(ctx context.Context, namespace, name string) (*unstructured.Unstructured, error)

func (*Kubernetes) PodsListInAllNamespaces

func (k *Kubernetes) PodsListInAllNamespaces(ctx context.Context, options ResourceListOptions) (runtime.Unstructured, error)

func (*Kubernetes) PodsListInNamespace

func (k *Kubernetes) PodsListInNamespace(ctx context.Context, namespace string, options ResourceListOptions) (runtime.Unstructured, error)

func (*Kubernetes) PodsLog

func (k *Kubernetes) PodsLog(ctx context.Context, namespace, name, container string) (string, error)

func (*Kubernetes) PodsRun

func (k *Kubernetes) PodsRun(ctx context.Context, namespace, name, image string, port int32) ([]*unstructured.Unstructured, error)

func (*Kubernetes) PodsTop

func (k *Kubernetes) PodsTop(ctx context.Context, options PodsTopOptions) (*metrics.PodMetricsList, error)

func (*Kubernetes) ProjectsList

func (k *Kubernetes) ProjectsList(ctx context.Context, options ResourceListOptions) (runtime.Unstructured, error)

func (*Kubernetes) ResourcesCreateOrUpdate

func (k *Kubernetes) ResourcesCreateOrUpdate(ctx context.Context, resource string) ([]*unstructured.Unstructured, error)

func (*Kubernetes) ResourcesDelete

func (k *Kubernetes) ResourcesDelete(ctx context.Context, gvk *schema.GroupVersionKind, namespace, name string) error

func (*Kubernetes) ResourcesGet

func (k *Kubernetes) ResourcesGet(ctx context.Context, gvk *schema.GroupVersionKind, namespace, name string) (*unstructured.Unstructured, error)

func (*Kubernetes) ResourcesList

func (k *Kubernetes) ResourcesList(ctx context.Context, gvk *schema.GroupVersionKind, namespace string, options ResourceListOptions) (runtime.Unstructured, error)

type Manager

type Manager struct {
	CloseWatchKubeConfig CloseWatchKubeConfig
	// contains filtered or unexported fields
}

func NewManager

func NewManager(config *config.StaticConfig) (*Manager, error)

func (*Manager) Close

func (m *Manager) Close()

func (*Manager) ConfigurationView

func (m *Manager) ConfigurationView(minify bool) (runtime.Object, error)

func (*Manager) Derived

func (m *Manager) Derived(ctx context.Context) (*Kubernetes, error)

func (*Manager) GetAPIServerHost

func (m *Manager) GetAPIServerHost() string

func (*Manager) IsInCluster

func (m *Manager) IsInCluster() bool

func (*Manager) IsOpenShift

func (m *Manager) IsOpenShift(_ context.Context) bool

func (*Manager) NamespaceOrDefault

func (m *Manager) NamespaceOrDefault(namespace string) string

func (*Manager) ToDiscoveryClient

func (m *Manager) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)

func (*Manager) ToRESTConfig

func (m *Manager) ToRESTConfig() (*rest.Config, error)

ToRESTConfig returns the rest.Config object (genericclioptions.RESTClientGetter)

func (*Manager) ToRESTMapper

func (m *Manager) ToRESTMapper() (meta.RESTMapper, error)

func (*Manager) ToRawKubeConfigLoader

func (m *Manager) ToRawKubeConfigLoader() clientcmd.ClientConfig

ToRawKubeConfigLoader returns the clientcmd.ClientConfig object (genericclioptions.RESTClientGetter)

func (*Manager) VerifyToken

func (m *Manager) VerifyToken(ctx context.Context, token, audience string) (*authenticationv1api.UserInfo, []string, error)

func (*Manager) WatchKubeConfig

func (m *Manager) WatchKubeConfig(onKubeConfigChange func() error)

type PodsTopOptions

type PodsTopOptions struct {
	metav1.ListOptions
	AllNamespaces bool
	Namespace     string
	Name          string
}

type ResourceListOptions

type ResourceListOptions struct {
	metav1.ListOptions
	AsTable bool
}

Jump to

Keyboard shortcuts

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