Documentation
¶
Overview ¶
Package k8s provides a k8s client.
Index ¶
- func ConnectToServer(socket string) (*grpc.ClientConn, error)
- func CreateHTTPStreams(w http.ResponseWriter, req *http.Request, opts *remotecommand.StreamOptions) (*streamContext, error)
- func CreateListener(addr string) (net.Listener, error)
- type Client
- func (c *Client) Close() error
- func (c *Client) ConfigMap(ctx context.Context, ns string, name string) (map[string]string, error)
- func (c *Client) Exec(ctx context.Context, ns string, pod string, container string, cmd []string) ([]byte, []byte, error)
- func (c *Client) ListPods(ctx context.Context, ns string, opts metav1.ListOptions) ([]Pod, error)
- func (c *Client) ListPodsWithDevs(ctx context.Context) ([]Pod, error)
- func (c *Client) ListUsers(ctx context.Context, ns string) (map[string][]string, error)
- func (c *Client) NewPodInformer(resyncPeriod time.Duration) error
- func (c *Client) Pods() []*v1.Pod
- func (c *Client) StartInformer() error
- type Container
- type Device
- type FakeResourceServer
- func (m *FakeResourceServer) Get(_ context.Context, _ *podresourcesapi.GetPodResourcesRequest) (*podresourcesapi.GetPodResourcesResponse, error)
- func (m *FakeResourceServer) GetAllocatableResources(_ context.Context, _ *podresourcesapi.AllocatableResourcesRequest) (*podresourcesapi.AllocatableResourcesResponse, error)
- func (m *FakeResourceServer) List(_ context.Context, _ *podresourcesapi.ListPodResourcesRequest) (*podresourcesapi.ListPodResourcesResponse, error)
- type Pod
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectToServer ¶
func ConnectToServer(socket string) (*grpc.ClientConn, error)
func CreateHTTPStreams ¶
func CreateHTTPStreams(w http.ResponseWriter, req *http.Request, opts *remotecommand.StreamOptions) (*streamContext, error)
CreateHTTPStreams only support StreamProtocolV4Name Nicked from https://github.com/kubernetes/client-go/blob/c106b23895edc59ff05c65770a17e6a6d3caee66/tools/remotecommand/spdy_test.go#L227-L288
func CreateListener ¶
CreateListener creates a listener on the specified endpoint. based from k8s.io/kubernetes/pkg/kubelet/util Nicked from https://github.com/k8snetworkplumbingwg/multus-cni/blob/v4.2.0/pkg/kubeletclient/kubeletclient_test.go
Types ¶
type Client ¶
type Client struct { Logger *slog.Logger Hostname string Config *rest.Config Clientset kubernetes.Interface PodResourceClient podresourcesapi.PodResourcesListerClient PodInformer coreinformers.PodInformer // contains filtered or unexported fields }
func (*Client) Exec ¶
func (c *Client) Exec(ctx context.Context, ns string, pod string, container string, cmd []string) ([]byte, []byte, error)
Exec executes a given command in the pod and returns output.
func (*Client) ListPodsWithDevs ¶
ListPodsWithDevs returns a slice of pods with devices associated with each pod.
func (*Client) ListUsers ¶
ListUsers returns a slice of map of namespaces to users fetched from rolebindings.
func (*Client) NewPodInformer ¶
NewInformer creates new pod informer using current client.
func (*Client) StartInformer ¶
StartInformer starts shared informers and waits for the shared informer cache to synchronize.
type FakeResourceServer ¶
type FakeResourceServer struct { podresourcesapi.UnimplementedPodResourcesListerServer Server *grpc.Server ListResp *podresourcesapi.ListPodResourcesResponse GetAllocatableResourcesResp *podresourcesapi.AllocatableResourcesResponse }
func FakeKubeletServer ¶
func FakeKubeletServer(socketDir string, listResp *podresourcesapi.ListPodResourcesResponse, getAllocatableResourcesResp *podresourcesapi.AllocatableResourcesResponse) (*FakeResourceServer, error)
FakeKubeletServer returns a mock API resource server.
func (*FakeResourceServer) Get ¶
func (m *FakeResourceServer) Get(_ context.Context, _ *podresourcesapi.GetPodResourcesRequest) (*podresourcesapi.GetPodResourcesResponse, error)
func (*FakeResourceServer) GetAllocatableResources ¶
func (m *FakeResourceServer) GetAllocatableResources(_ context.Context, _ *podresourcesapi.AllocatableResourcesRequest) (*podresourcesapi.AllocatableResourcesResponse, error)
func (*FakeResourceServer) List ¶
func (m *FakeResourceServer) List(_ context.Context, _ *podresourcesapi.ListPodResourcesRequest) (*podresourcesapi.ListPodResourcesResponse, error)