mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-07 12:11:43 +00:00
Periodically update pod status from kubelet.
This commit is contained in:
@@ -40,6 +40,7 @@ type PodInterface interface {
|
||||
Update(pod *api.Pod) (*api.Pod, error)
|
||||
Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
|
||||
Bind(binding *api.Binding) error
|
||||
UpdateStatus(name string, status *api.PodStatus) (*api.Pod, error)
|
||||
}
|
||||
|
||||
// pods implements PodsNamespacer interface
|
||||
@@ -63,7 +64,7 @@ func (c *pods) List(selector labels.Selector) (result *api.PodList, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// GetPod takes the name of the pod, and returns the corresponding Pod object, and an error if it occurs
|
||||
// Get takes the name of the pod, and returns the corresponding Pod object, and an error if it occurs
|
||||
func (c *pods) Get(name string) (result *api.Pod, err error) {
|
||||
if len(name) == 0 {
|
||||
return nil, errors.New("name is required parameter to Get")
|
||||
@@ -74,19 +75,19 @@ func (c *pods) Get(name string) (result *api.Pod, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// DeletePod takes the name of the pod, and returns an error if one occurs
|
||||
// Delete takes the name of the pod, and returns an error if one occurs
|
||||
func (c *pods) Delete(name string) error {
|
||||
return c.r.Delete().Namespace(c.ns).Resource("pods").Name(name).Do().Error()
|
||||
}
|
||||
|
||||
// CreatePod takes the representation of a pod. Returns the server's representation of the pod, and an error, if it occurs.
|
||||
// Create takes the representation of a pod. Returns the server's representation of the pod, and an error, if it occurs.
|
||||
func (c *pods) Create(pod *api.Pod) (result *api.Pod, err error) {
|
||||
result = &api.Pod{}
|
||||
err = c.r.Post().Namespace(c.ns).Resource("pods").Body(pod).Do().Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdatePod takes the representation of a pod to update. Returns the server's representation of the pod, and an error, if it occurs.
|
||||
// Update takes the representation of a pod to update. Returns the server's representation of the pod, and an error, if it occurs.
|
||||
func (c *pods) Update(pod *api.Pod) (result *api.Pod, err error) {
|
||||
result = &api.Pod{}
|
||||
if len(pod.ResourceVersion) == 0 {
|
||||
@@ -113,3 +114,15 @@ func (c *pods) Watch(label labels.Selector, field fields.Selector, resourceVersi
|
||||
func (c *pods) Bind(binding *api.Binding) error {
|
||||
return c.r.Post().Namespace(c.ns).Resource("pods").Name(binding.Name).SubResource("binding").Body(binding).Do().Error()
|
||||
}
|
||||
|
||||
// UpdateStatus takes the name of the pod and the new status. Returns the server's representation of the pod, and an error, if it occurs.
|
||||
func (c *pods) UpdateStatus(name string, newStatus *api.PodStatus) (result *api.Pod, err error) {
|
||||
result = &api.Pod{}
|
||||
pod, err := c.Get(name)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
pod.Status = *newStatus
|
||||
err = c.r.Put().Namespace(c.ns).Resource("pods").Name(pod.Name).SubResource("status").Body(pod).Do().Into(result)
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user