Documentation
¶
Overview ¶
Package k8s provides MCP tools for interacting with Kubernetes resources.
Index ¶
- func FormatCustomColumns(items []unstructured.Unstructured, customColumns string) (string, error)
- func FormatTable(obj *unstructured.Unstructured) (string, error)
- func Install(_ context.Context, s *mcp.Server, c *config.Config) error
- func ResolveGVR(_ context.Context, discoveryClient discovery.DiscoveryInterface, ...) (schema.GroupVersionResource, schema.GroupVersionKind, bool, error)
- type APIGroupDiscovery
- type ClientProvider
- func (p *ClientProvider) DiscoveryClient(ctx context.Context, clusterPath string) (discovery.DiscoveryInterface, error)
- func (p *ClientProvider) DynamicClient(ctx context.Context, clusterPath string) (dynamic.Interface, error)
- func (p *ClientProvider) DynamicClientWithHeaders(ctx context.Context, clusterPath string, headerName, headerValue string) (dynamic.Interface, error)
- func (p *ClientProvider) KubernetesClient(ctx context.Context, clusterPath string) (kubernetes.Interface, error)
- func (p *ClientProvider) RESTConfig(_ context.Context, clusterPath string) (*rest.Config, error)
- type HeaderRoundTripper
- type Provider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatCustomColumns ¶
func FormatCustomColumns(items []unstructured.Unstructured, customColumns string) (string, error)
FormatCustomColumns formats a list of unstructured items using the provided custom columns string. The format is "HEADER:JSONPATH,HEADER:JSONPATH".
func FormatTable ¶
func FormatTable(obj *unstructured.Unstructured) (string, error)
FormatTable formats a Kubernetes Table object (stored in Unstructured) into a human-readable string.
func ResolveGVR ¶
func ResolveGVR(_ context.Context, discoveryClient discovery.DiscoveryInterface, resource string) (schema.GroupVersionResource, schema.GroupVersionKind, bool, error)
ResolveGVR resolves a resource kind or name (e.g., "pods", "deployments") to its GroupVersionResource.
Types ¶
type APIGroupDiscovery ¶
type APIGroupDiscovery struct {
Name string `json:"name"`
Versions []string `json:"versions"`
PreferredVersion string `json:"preferred_version"`
}
APIGroupDiscovery represents a discovery document for an API group/resource.
type ClientProvider ¶
type ClientProvider struct {
}
ClientProvider provides Kubernetes clients for a GKE cluster.
func NewClientProvider ¶
func NewClientProvider() *ClientProvider
NewClientProvider creates a new ClientProvider.
func (*ClientProvider) DiscoveryClient ¶
func (p *ClientProvider) DiscoveryClient(ctx context.Context, clusterPath string) (discovery.DiscoveryInterface, error)
DiscoveryClient returns a discovery.DiscoveryInterface for the given cluster.
func (*ClientProvider) DynamicClient ¶
func (p *ClientProvider) DynamicClient(ctx context.Context, clusterPath string) (dynamic.Interface, error)
DynamicClient returns a dynamic.Interface for the given cluster.
func (*ClientProvider) DynamicClientWithHeaders ¶
func (p *ClientProvider) DynamicClientWithHeaders(ctx context.Context, clusterPath string, headerName, headerValue string) (dynamic.Interface, error)
DynamicClientWithHeaders returns a dynamic.Interface that adds specific headers to every request.
func (*ClientProvider) KubernetesClient ¶
func (p *ClientProvider) KubernetesClient(ctx context.Context, clusterPath string) (kubernetes.Interface, error)
KubernetesClient returns a kubernetes.Interface for the given cluster.
func (*ClientProvider) RESTConfig ¶
RESTConfig returns a rest.Config for the given cluster.
type HeaderRoundTripper ¶
type HeaderRoundTripper struct {
Wrapped http.RoundTripper
HeaderName string
HeaderValue string
}
HeaderRoundTripper is an http.RoundTripper that adds a specific header to each request.
type Provider ¶
type Provider interface {
RESTConfig(ctx context.Context, clusterPath string) (*rest.Config, error)
DynamicClient(ctx context.Context, clusterPath string) (dynamic.Interface, error)
DynamicClientWithHeaders(ctx context.Context, clusterPath string, headerName, headerValue string) (dynamic.Interface, error)
DiscoveryClient(ctx context.Context, clusterPath string) (discovery.DiscoveryInterface, error)
KubernetesClient(ctx context.Context, clusterPath string) (kubernetes.Interface, error)
}
Provider defines the interface for providing Kubernetes clients.