k8s

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

Package k8s provides MCP tools for interacting with Kubernetes resources.

Index

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 Install

func Install(_ context.Context, s *mcp.Server, c *config.Config) error

Install registers Kubernetes-related tools with the MCP server.

func ResolveGVR

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

func (p *ClientProvider) RESTConfig(_ context.Context, clusterPath string) (*rest.Config, error)

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.

func (*HeaderRoundTripper) RoundTrip

func (t *HeaderRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the http.RoundTripper interface.

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.

Jump to

Keyboard shortcuts

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