Documentation
¶
Index ¶
- Constants
- Variables
- func GetRegisteredStrategies() []string
- func IsInCluster(cfg *config.StaticConfig) bool
- func RegisterProvider(strategy string, factory ProviderFactory)
- type AccessControlClientset
- func (a *AccessControlClientset) DiscoveryClient() discovery.CachedDiscoveryInterface
- func (a *AccessControlClientset) DynamicClient() dynamic.Interface
- func (a *AccessControlClientset) MetricsV1beta1Client() *metricsv1beta1.MetricsV1beta1Client
- func (a *AccessControlClientset) Nodes() (corev1.NodeInterface, error)
- func (a *AccessControlClientset) Pods(namespace string) (corev1.PodInterface, error)
- func (a *AccessControlClientset) RESTMapper() meta.ResettableRESTMapper
- func (a *AccessControlClientset) SelfSubjectAccessReviews() (authorizationv1.SelfSubjectAccessReviewInterface, error)
- func (a *AccessControlClientset) Services(namespace string) (corev1.ServiceInterface, error)
- func (a *AccessControlClientset) ToRawKubeConfigLoader() clientcmd.ClientConfig
- func (a *AccessControlClientset) TokenReview() (authenticationv1.TokenReviewInterface, error)
- type AccessControlRoundTripper
- type CloseWatchKubeConfig
- type HeaderKey
- type Kubernetes
- func (k *Kubernetes) AccessControlClientset() *AccessControlClientset
- func (k *Kubernetes) ConfigurationContextsDefault() (string, error)
- func (k *Kubernetes) ConfigurationContextsList() (map[string]string, error)
- func (k *Kubernetes) ConfigurationView(minify bool) (runtime.Object, error)
- func (k *Kubernetes) EventsList(ctx context.Context, namespace string) ([]map[string]any, error)
- func (k *Kubernetes) NamespaceOrDefault(namespace string) string
- func (k *Kubernetes) NamespacesList(ctx context.Context, options ResourceListOptions) (runtime.Unstructured, error)
- func (k *Kubernetes) NewHelm() *helm.Helm
- func (k *Kubernetes) NewKiali() *kiali.Kiali
- func (k *Kubernetes) NodesLog(ctx context.Context, name string, query string, tailLines int64) (string, error)
- func (k *Kubernetes) NodesStatsSummary(ctx context.Context, name string) (string, error)
- func (k *Kubernetes) NodesTop(ctx context.Context, options NodesTopOptions) (*metrics.NodeMetricsList, error)
- func (k *Kubernetes) PodsDelete(ctx context.Context, namespace, name string) (string, error)
- func (k *Kubernetes) PodsExec(ctx context.Context, namespace, name, container string, command []string) (string, error)
- func (k *Kubernetes) PodsGet(ctx context.Context, namespace, name string) (*unstructured.Unstructured, error)
- func (k *Kubernetes) PodsListInAllNamespaces(ctx context.Context, options ResourceListOptions) (runtime.Unstructured, error)
- func (k *Kubernetes) PodsListInNamespace(ctx context.Context, namespace string, options ResourceListOptions) (runtime.Unstructured, error)
- func (k *Kubernetes) PodsLog(ctx context.Context, namespace, name, container string, previous bool, ...) (string, error)
- func (k *Kubernetes) PodsRun(ctx context.Context, namespace, name, image string, port int32) ([]*unstructured.Unstructured, error)
- func (k *Kubernetes) PodsTop(ctx context.Context, options PodsTopOptions) (*metrics.PodMetricsList, error)
- func (k *Kubernetes) ProjectsList(ctx context.Context, options ResourceListOptions) (runtime.Unstructured, error)
- func (k *Kubernetes) ResourcesCreateOrUpdate(ctx context.Context, resource string) ([]*unstructured.Unstructured, error)
- func (k *Kubernetes) ResourcesDelete(ctx context.Context, gvk *schema.GroupVersionKind, namespace, name string) error
- func (k *Kubernetes) ResourcesGet(ctx context.Context, gvk *schema.GroupVersionKind, namespace, name string) (*unstructured.Unstructured, error)
- func (k *Kubernetes) ResourcesList(ctx context.Context, gvk *schema.GroupVersionKind, namespace string, ...) (runtime.Unstructured, error)
- func (k *Kubernetes) ResourcesScale(ctx context.Context, gvk *schema.GroupVersionKind, namespace, name string, ...) (*unstructured.Unstructured, error)
- func (k *Kubernetes) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
- func (k *Kubernetes) ToRESTConfig() (*rest.Config, error)
- func (k *Kubernetes) ToRESTMapper() (meta.RESTMapper, error)
- func (k *Kubernetes) ToRawKubeConfigLoader() clientcmd.ClientConfig
- type Manager
- type McpReload
- type NodesTopOptions
- type Openshift
- type PodsTopOptions
- type Provider
- type ProviderFactory
- type ResourceListOptions
- type TokenVerifier
Constants ¶
const ( CustomAuthorizationHeader = HeaderKey("kubernetes-authorization") OAuthAuthorizationHeader = HeaderKey("Authorization") CustomUserAgent = "kubernetes-mcp-server/bearer-token-auth" )
const ( AppKubernetesComponent = "app.kubernetes.io/component" AppKubernetesManagedBy = "app.kubernetes.io/managed-by" AppKubernetesName = "app.kubernetes.io/name" AppKubernetesPartOf = "app.kubernetes.io/part-of" )
const DefaultTailLines = int64(100)
DefaultTailLines is the default number of lines to retrieve from the end of the logs
const KubeConfigTargetParameterName = "context"
KubeConfigTargetParameterName is the parameter name used to specify the kubeconfig context when using the kubeconfig cluster provider strategy.
Variables ¶
var ( ErrorKubeconfigInClusterNotAllowed = errors.New("kubeconfig manager cannot be used in in-cluster deployments") ErrorInClusterNotInCluster = errors.New("in-cluster manager cannot be used outside of a cluster") )
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
var ParameterCodec = runtime.NewParameterCodec(Scheme)
var Scheme = scheme.Scheme
Functions ¶
func GetRegisteredStrategies ¶ added in v0.0.53
func GetRegisteredStrategies() []string
GetRegisteredStrategies returns a sorted list of all registered strategy names. This is useful for error messages and debugging.
func IsInCluster ¶ added in v0.0.54
func IsInCluster(cfg *config.StaticConfig) bool
func RegisterProvider ¶ added in v0.0.53
func RegisterProvider(strategy string, factory ProviderFactory)
RegisterProvider registers a provider factory for a given strategy name. This should be called from init() functions in provider implementation files. Panics if a provider is already registered for the given strategy.
Types ¶
type AccessControlClientset ¶
type AccessControlClientset struct {
kubernetes.Interface
// 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(staticConfig *config.StaticConfig, clientCmdConfig clientcmd.ClientConfig, restConfig *rest.Config) (*AccessControlClientset, error)
func (*AccessControlClientset) DiscoveryClient ¶
func (a *AccessControlClientset) DiscoveryClient() discovery.CachedDiscoveryInterface
func (*AccessControlClientset) DynamicClient ¶ added in v0.0.55
func (a *AccessControlClientset) DynamicClient() dynamic.Interface
func (*AccessControlClientset) MetricsV1beta1Client ¶ added in v0.0.55
func (a *AccessControlClientset) MetricsV1beta1Client() *metricsv1beta1.MetricsV1beta1Client
func (*AccessControlClientset) Nodes ¶ added in v0.0.54
func (a *AccessControlClientset) Nodes() (corev1.NodeInterface, error)
Nodes returns NodeInterface Deprecated: use CoreV1().Nodes() directly
func (*AccessControlClientset) Pods ¶
func (a *AccessControlClientset) Pods(namespace string) (corev1.PodInterface, error)
Pods returns PodInterface Deprecated: use CoreV1().Pods(namespace) directly
func (*AccessControlClientset) RESTMapper ¶ added in v0.0.55
func (a *AccessControlClientset) RESTMapper() meta.ResettableRESTMapper
func (*AccessControlClientset) SelfSubjectAccessReviews ¶
func (a *AccessControlClientset) SelfSubjectAccessReviews() (authorizationv1.SelfSubjectAccessReviewInterface, error)
SelfSubjectAccessReviews returns SelfSubjectAccessReviewInterface Deprecated: use AuthorizationV1().SelfSubjectAccessReviews() directly
func (*AccessControlClientset) Services ¶
func (a *AccessControlClientset) Services(namespace string) (corev1.ServiceInterface, error)
Services returns ServiceInterface Deprecated: use CoreV1().Services(namespace) directly
func (*AccessControlClientset) ToRawKubeConfigLoader ¶ added in v0.0.55
func (a *AccessControlClientset) ToRawKubeConfigLoader() clientcmd.ClientConfig
ToRawKubeConfigLoader returns the clientcmd.ClientConfig object (genericclioptions.RESTClientGetter)
func (*AccessControlClientset) TokenReview ¶
func (a *AccessControlClientset) TokenReview() (authenticationv1.TokenReviewInterface, error)
TokenReview returns TokenReviewInterface Deprecated: use AuthenticationV1().TokenReviews() directly
type AccessControlRoundTripper ¶ added in v0.0.55
type AccessControlRoundTripper struct {
// contains filtered or unexported fields
}
type CloseWatchKubeConfig ¶
type CloseWatchKubeConfig func() error
type Kubernetes ¶
type Kubernetes struct {
// contains filtered or unexported fields
}
func (*Kubernetes) AccessControlClientset ¶ added in v0.0.53
func (k *Kubernetes) AccessControlClientset() *AccessControlClientset
AccessControlClientset returns the access-controlled clientset This ensures that any denied resources configured in the system are properly enforced
func (*Kubernetes) ConfigurationContextsDefault ¶ added in v0.0.53
func (k *Kubernetes) ConfigurationContextsDefault() (string, error)
ConfigurationContextsDefault returns the current context name TODO: Should be moved to the Provider level ?
func (*Kubernetes) ConfigurationContextsList ¶ added in v0.0.53
func (k *Kubernetes) ConfigurationContextsList() (map[string]string, error)
ConfigurationContextsList returns the list of available context names TODO: Should be moved to the Provider level ?
func (*Kubernetes) ConfigurationView ¶ added in v0.0.51
func (k *Kubernetes) ConfigurationView(minify bool) (runtime.Object, error)
ConfigurationView returns the current kubeconfig content as a kubeconfig YAML If minify is true, keeps only the current-context and the relevant pieces of the configuration for that context. If minify is false, all contexts, clusters, auth-infos, and users are returned in the configuration. TODO: Should be moved to the Provider level ?
func (*Kubernetes) EventsList ¶
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) NewKiali ¶ added in v0.0.55
func (k *Kubernetes) NewKiali() *kiali.Kiali
NewKiali returns a Kiali client initialized with the same StaticConfig and bearer token as the underlying derived Kubernetes manager.
func (*Kubernetes) NodesStatsSummary ¶ added in v0.0.54
func (*Kubernetes) NodesTop ¶ added in v0.0.54
func (k *Kubernetes) NodesTop(ctx context.Context, options NodesTopOptions) (*metrics.NodeMetricsList, error)
func (*Kubernetes) PodsDelete ¶
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) 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)
func (*Kubernetes) ResourcesScale ¶ added in v0.0.55
func (k *Kubernetes) ResourcesScale( ctx context.Context, gvk *schema.GroupVersionKind, namespace, name string, desiredScale int64, shouldScale bool, ) (*unstructured.Unstructured, error)
func (*Kubernetes) ToDiscoveryClient ¶ added in v0.0.55
func (k *Kubernetes) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
func (*Kubernetes) ToRESTConfig ¶ added in v0.0.55
func (k *Kubernetes) ToRESTConfig() (*rest.Config, error)
ToRESTConfig returns the rest.Config object (genericclioptions.RESTClientGetter)
func (*Kubernetes) ToRESTMapper ¶ added in v0.0.55
func (k *Kubernetes) ToRESTMapper() (meta.RESTMapper, error)
func (*Kubernetes) ToRawKubeConfigLoader ¶ added in v0.0.55
func (k *Kubernetes) ToRawKubeConfigLoader() clientcmd.ClientConfig
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewInClusterManager ¶ added in v0.0.54
func NewInClusterManager(config *config.StaticConfig) (*Manager, error)
func NewKubeconfigManager ¶ added in v0.0.54
func NewKubeconfigManager(config *config.StaticConfig, kubeconfigContext string) (*Manager, error)
func NewManager ¶
func NewManager(config *config.StaticConfig, restConfig *rest.Config, clientCmdConfig clientcmd.ClientConfig) (*Manager, error)
func (*Manager) Invalidate ¶ added in v0.0.55
func (m *Manager) Invalidate()
Invalidate invalidates the cached discovery information.
func (*Manager) VerifyToken ¶
type McpReload ¶ added in v0.0.55
type McpReload func() error
McpReload is a function type that defines a callback for reloading MCP toolsets (including tools, prompts, or other configurations)
type NodesTopOptions ¶ added in v0.0.54
type NodesTopOptions struct {
metav1.ListOptions
Name string
}
type PodsTopOptions ¶
type PodsTopOptions struct {
metav1.ListOptions
AllNamespaces bool
Namespace string
Name string
}
type Provider ¶ added in v0.0.54
type Provider interface {
// Openshift extends the Openshift interface to provide OpenShift specific functionality to toolset providers
// TODO: with the configurable toolset implementation and especially the multi-cluster approach
// extending this interface might not be a good idea anymore.
// For the kubecontext case, a user might be targeting both an OpenShift flavored cluster and a vanilla Kubernetes cluster.
// See: https://github.com/containers/kubernetes-mcp-server/pull/372#discussion_r2421592315
Openshift
TokenVerifier
GetTargets(ctx context.Context) ([]string, error)
GetDerivedKubernetes(ctx context.Context, target string) (*Kubernetes, error)
GetDefaultTarget() string
GetTargetParameterName() string
// WatchTargets sets up a watcher for changes in the cluster targets and calls the provided McpReload function when changes are detected
WatchTargets(reload McpReload)
Close()
}
func NewProvider ¶ added in v0.0.54
func NewProvider(cfg *config.StaticConfig) (Provider, error)
type ProviderFactory ¶ added in v0.0.53
type ProviderFactory func(cfg *config.StaticConfig) (Provider, error)
ProviderFactory creates a new Provider instance for a given strategy. Implementations should validate that the Manager is compatible with their strategy (e.g., kubeconfig provider should reject in-cluster managers).
type ResourceListOptions ¶
type ResourceListOptions struct {
metav1.ListOptions
AsTable bool
}