typePodLifecycleHandlerinterface {// CreatePod takes a Kubernetes Pod and deploys it within the provider.CreatePod(ctx context.Context, pod *corev1.Pod) error// UpdatePod takes a Kubernetes Pod and updates it within the provider.UpdatePod(ctx context.Context, pod *corev1.Pod) error// DeletePod takes a Kubernetes Pod and deletes it from the provider.DeletePod(ctx context.Context, pod *corev1.Pod) error// GetPod retrieves a pod by name from the provider (can be cached).GetPod(ctx context.Context, namespace, name string) (*corev1.Pod, error)// GetPodStatus retrieves the status of a pod by name from the provider.GetPodStatus(ctx context.Context, namespace, name string) (*corev1.PodStatus, error)// GetPods retrieves a list of all pods running on the provider (can be cached).GetPods(context.Context) ([]*corev1.Pod, error)}
pc, _ := node.NewPodController(podControllerConfig) // <-- instatiates the pod controllerpc.Run(ctx) // <-- starts watching for pods to be scheduled on the node
typePodNotifierinterface {// NotifyPods instructs the notifier to call the passed in function when// the pod status changes.//// NotifyPods should not block callers.NotifyPods(context.Context, func(*corev1.Pod))}
typeNodeProviderinterface {// Ping checks if the node is still active.// This is intended to be lightweight as it will be called periodically as a// heartbeat to keep the node marked as ready in Kubernetes.Ping(context.Context) error// NotifyNodeStatus is used to asynchronously monitor the node.// The passed in callback should be called any time there is a change to the// node's status.// This will generally trigger a call to the Kubernetes API server to update// the status.//// NotifyNodeStatus should not block callers.NotifyNodeStatus(ctx context.Context, cb func(*corev1.Node))}
NodeProvider是被NodeController调用,来管理k8s中的node对象。
nc, _ := node.NewNodeController(nodeProvider, nodeSpec) // <-- instantiate a node controller from a node provider and a kubernetes node spec
nc.Run(ctx) // <-- creates the node in kubernetes and starts up he controller