Update docs for how to add a provider
This commit is contained in:
47
README.md
47
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.
|
on top with a pluggable interface.
|
||||||
|
|
||||||
Create a new directory for your provider under `providers` and implement the
|
Create a new directory for your provider under `providers` and implement the
|
||||||
following interface. Then add your new provider under the others in the
|
following interface. Then add register your provider in
|
||||||
[`vkubelet/provider.go`](vkubelet/provider.go) file.
|
`providers/register/<provider_name>_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_name>_provider`. Also make sure your provdider has all
|
||||||
|
neccessary platform build tags, e.g. "linux" if your provider only compiles on Linux.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
// Provider contains the methods required to implement a virtual-kubelet provider.
|
// Provider contains the methods required to implement a virtual-kubelet provider.
|
||||||
type Provider interface {
|
type Provider interface {
|
||||||
// CreatePod takes a Kubernetes Pod and deploys it within the provider.
|
// 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 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 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 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.
|
// GetContainerLogs retrieves the logs of a container by name from the provider.
|
||||||
GetPodStatus(namespace, name string) (*v1.PodStatus, error)
|
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 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 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.
|
// 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 returns the operating system the provider is for.
|
||||||
OperatingSystem() string
|
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
|
## Testing
|
||||||
|
|||||||
Reference in New Issue
Block a user