Documentation
¶
Index ¶
- Constants
- Variables
- func GetRegisteredStrategies() []string
- func RegisterProvider(strategy string, factory ProviderFactory)
- type AccessControlClientset
- func (a *AccessControlClientset) DiscoveryClient() discovery.DiscoveryInterface
- func (a *AccessControlClientset) Pods(namespace string) (corev1.PodInterface, error)
- func (a *AccessControlClientset) PodsExec(namespace, name string, podExecOptions *v1.PodExecOptions) (remotecommand.Executor, error)
- func (a *AccessControlClientset) PodsMetricses(ctx context.Context, namespace, name string, listOptions metav1.ListOptions) (*metrics.PodMetricsList, error)
- func (a *AccessControlClientset) SelfSubjectAccessReviews() (authorizationv1.SelfSubjectAccessReviewInterface, error)
- func (a *AccessControlClientset) Services(namespace string) (corev1.ServiceInterface, error)
- func (a *AccessControlClientset) TokenReview() (authenticationv1.TokenReviewInterface, error)
- type AccessControlRESTMapper
- func (a AccessControlRESTMapper) KindFor(resource schema.GroupVersionResource) (schema.GroupVersionKind, error)
- func (a AccessControlRESTMapper) KindsFor(resource schema.GroupVersionResource) ([]schema.GroupVersionKind, error)
- func (a AccessControlRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string) (*meta.RESTMapping, error)
- func (a AccessControlRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string) ([]*meta.RESTMapping, error)
- func (a AccessControlRESTMapper) Reset()
- func (a AccessControlRESTMapper) ResourceFor(input schema.GroupVersionResource) (schema.GroupVersionResource, error)
- func (a AccessControlRESTMapper) ResourceSingularizer(resource string) (singular string, err error)
- func (a AccessControlRESTMapper) ResourcesFor(input schema.GroupVersionResource) ([]schema.GroupVersionResource, error)
- 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) 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)
- type Manager
- func (m *Manager) Close()
- func (m *Manager) Derived(ctx context.Context) (*Kubernetes, error)
- func (m *Manager) GetAPIServerHost() string
- func (m *Manager) IsInCluster() bool
- func (m *Manager) IsOpenShift(_ context.Context) bool
- func (m *Manager) NamespaceOrDefault(namespace string) string
- func (m *Manager) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
- func (m *Manager) ToRESTConfig() (*rest.Config, error)
- func (m *Manager) ToRESTMapper() (meta.RESTMapper, error)
- func (m *Manager) ToRawKubeConfigLoader() clientcmd.ClientConfig
- func (m *Manager) VerifyToken(ctx context.Context, token, audience string) (*authenticationv1api.UserInfo, []string, error)
- func (m *Manager) WatchKubeConfig(onKubeConfigChange func() error)
- type ManagerProvider
- type Openshift
- type PodsTopOptions
- type ProviderFactory
- type ResourceListOptions
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)
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 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 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 {
// 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 (a *AccessControlClientset) DiscoveryClient() discovery.DiscoveryInterface
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 (a *AccessControlClientset) SelfSubjectAccessReviews() (authorizationv1.SelfSubjectAccessReviewInterface, error)
func (*AccessControlClientset) Services ¶
func (a *AccessControlClientset) Services(namespace string) (corev1.ServiceInterface, error)
func (*AccessControlClientset) TokenReview ¶
func (a *AccessControlClientset) TokenReview() (authenticationv1.TokenReviewInterface, error)
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 (a AccessControlRESTMapper) KindFor(resource schema.GroupVersionResource) (schema.GroupVersionKind, error)
func (AccessControlRESTMapper) KindsFor ¶
func (a AccessControlRESTMapper) KindsFor(resource schema.GroupVersionResource) ([]schema.GroupVersionKind, error)
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 (a AccessControlRESTMapper) ResourceFor(input schema.GroupVersionResource) (schema.GroupVersionResource, error)
func (AccessControlRESTMapper) ResourceSingularizer ¶
func (a AccessControlRESTMapper) ResourceSingularizer(resource string) (singular string, err error)
func (AccessControlRESTMapper) ResourcesFor ¶
func (a AccessControlRESTMapper) ResourcesFor(input schema.GroupVersionResource) ([]schema.GroupVersionResource, error)
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.52
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) 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)
type Manager ¶
type Manager struct { CloseWatchKubeConfig CloseWatchKubeConfig // contains filtered or unexported fields }
func NewManager ¶
func NewManager(config *config.StaticConfig) (*Manager, error)
func (*Manager) GetAPIServerHost ¶
func (*Manager) IsInCluster ¶
func (*Manager) NamespaceOrDefault ¶
func (*Manager) ToDiscoveryClient ¶
func (m *Manager) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
func (*Manager) ToRESTConfig ¶
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 (*Manager) WatchKubeConfig ¶
type ManagerProvider ¶ added in v0.0.53
type ManagerProvider interface { GetTargets(ctx context.Context) ([]string, error) GetManagerFor(ctx context.Context, target string) (*Manager, error) GetDefaultTarget() string GetTargetParameterName() string WatchTargets(func() error) Close() }
func NewManagerProvider ¶ added in v0.0.53
func NewManagerProvider(cfg *config.StaticConfig) (ManagerProvider, error)
type PodsTopOptions ¶
type PodsTopOptions struct { metav1.ListOptions AllNamespaces bool Namespace string Name string }
type ProviderFactory ¶ added in v0.0.53
type ProviderFactory func(m *Manager, cfg *config.StaticConfig) (ManagerProvider, error)
ProviderFactory creates a new ManagerProvider 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 }