From 4cb94dd19b8ae67ee6dff341b37385aaf1dd8a9c Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Wed, 21 Nov 2018 10:04:36 -0800 Subject: [PATCH] Update docs for how to add a provider --- README.md | 47 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index ddb743bf0..4fafb78f3 100644 --- a/README.md +++ b/README.md @@ -177,40 +177,63 @@ The structure we chose allows you to have all the power of the Kubernetes API on top with a pluggable interface. Create a new directory for your provider under `providers` and implement the -following interface. Then add your new provider under the others in the -[`vkubelet/provider.go`](vkubelet/provider.go) file. +following interface. Then add register your provider in +`providers/register/_provider.go`. Make sure to add a build tag so that +your provider can be excluded from being built. The format for this build tag +should be `no__provider`. Also make sure your provdider has all +neccessary platform build tags, e.g. "linux" if your provider only compiles on Linux. ```go // Provider contains the methods required to implement a virtual-kubelet provider. type Provider interface { // CreatePod takes a Kubernetes Pod and deploys it within the provider. - CreatePod(pod *v1.Pod) error + CreatePod(ctx context.Context, pod *v1.Pod) error // UpdatePod takes a Kubernetes Pod and updates it within the provider. - UpdatePod(pod *v1.Pod) error + UpdatePod(ctx context.Context, pod *v1.Pod) error // DeletePod takes a Kubernetes Pod and deletes it from the provider. - DeletePod(pod *v1.Pod) error + DeletePod(ctx context.Context, pod *v1.Pod) error // GetPod retrieves a pod by name from the provider (can be cached). - GetPod(namespace, name string) (*v1.Pod, error) + GetPod(ctx context.Context, namespace, name string) (*v1.Pod, error) - // GetPodStatus retrievesthe status of a pod by name from the provider. - GetPodStatus(namespace, name string) (*v1.PodStatus, error) + // GetContainerLogs retrieves the logs of a container by name from the provider. + GetContainerLogs(ctx context.Context, namespace, podName, containerName string, tail int) (string, error) + + // ExecInContainer executes a command in a container in the pod, copying data + // between in/out/err and the container's stdin/stdout/stderr. + ExecInContainer(name string, uid types.UID, container string, cmd []string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize, timeout time.Duration) error + + // GetPodStatus retrieves the status of a pod by name from the provider. + GetPodStatus(ctx context.Context, namespace, name string) (*v1.PodStatus, error) // GetPods retrieves a list of all pods running on the provider (can be cached). - GetPods() ([]*v1.Pod, error) + GetPods(context.Context) ([]*v1.Pod, error) // Capacity returns a resource list with the capacity constraints of the provider. - Capacity() v1.ResourceList + Capacity(context.Context) v1.ResourceList - // NodeConditions returns a list of conditions (Ready, OutOfDisk, etc), which is polled periodically to update the node status + // NodeConditions returns a list of conditions (Ready, OutOfDisk, etc), which is + // polled periodically to update the node status within Kubernetes. + NodeConditions(context.Context) []v1.NodeCondition + + // NodeAddresses returns a list of addresses for the node status // within Kubernetes. - NodeConditions() []v1.NodeCondition + NodeAddresses(context.Context) []v1.NodeAddress + + // NodeDaemonEndpoints returns NodeDaemonEndpoints for the node status + // within Kubernetes. + NodeDaemonEndpoints(context.Context) *v1.NodeDaemonEndpoints // OperatingSystem returns the operating system the provider is for. OperatingSystem() string } + +// PodMetricsProvider is an optional interface that providers can implement to expose pod stats +type PodMetricsProvider interface { + GetStatsSummary(context.Context) (*stats.Summary, error) +} ``` ## Testing