mirror of
https://github.com/kubernetes/sample-controller.git
synced 2026-02-04 00:06:14 +08:00
sample-controller: add status subresource support
- Add an example to show how to use status subresources with custom resources. - Update the comment in the controller to mention that `UpdateStatus` can now be used. - Generate `UpdateStatus` for Foo. - Update the README to remove feature gate information for CRD validation since the current example requires a v1.9 cluster and it is enabled by default. - Update the README to add feature gate information for CustomResourceSubResources. Kubernetes-commit: 7c06d6fb17ee46f587c1facff93b9bb185522855
This commit is contained in:
committed by
Kubernetes Publisher
parent
aadb6d02da
commit
ad67096f17
@@ -327,10 +327,10 @@ func (c *Controller) updateFooStatus(foo *samplev1alpha1.Foo, deployment *appsv1
|
||||
// Or create a copy manually for better performance
|
||||
fooCopy := foo.DeepCopy()
|
||||
fooCopy.Status.AvailableReplicas = deployment.Status.AvailableReplicas
|
||||
// Until #38113 is merged, we must use Update instead of UpdateStatus to
|
||||
// update the Status block of the Foo resource. UpdateStatus will not
|
||||
// allow changes to the Spec of the resource, which is ideal for ensuring
|
||||
// nothing other than resource status has been updated.
|
||||
// If the CustomResourceSubresources feature gate is not enabled,
|
||||
// we must use Update instead of UpdateStatus to update the Status block of the Foo resource.
|
||||
// UpdateStatus will not allow changes to the Spec of the resource,
|
||||
// which is ideal for ensuring nothing other than resource status has been updated.
|
||||
_, err := c.sampleclientset.SamplecontrollerV1alpha1().Foos(foo.Namespace).Update(fooCopy)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user