File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717a CronTab. This example use an example CRD from this tutorial:
1818https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/
1919
20- The following yaml manifest has to be applied first:
20+ The following yaml manifest has to be applied first for namespaced scoped CRD :
2121
2222apiVersion: apiextensions.k8s.io/v1
2323kind: CustomResourceDefinition
@@ -72,6 +72,11 @@ def main():
7272 }
7373 }
7474
75+ # patch to update the `spec.cronSpec` field
76+ patch_body = {
77+ "spec" : {"cronSpec" : "* * * * */10" , "image" : "my-awesome-cron-image" }
78+ }
79+
7580 # create the resource
7681 api .create_namespaced_custom_object (
7782 group = "stable.example.com" ,
@@ -93,6 +98,18 @@ def main():
9398 print ("Resource details:" )
9499 pprint (resource )
95100
101+ # patch the namespaced custom object to update the `spec.cronSpec` field
102+ patch_resource = api .patch_namespaced_custom_object (
103+ group = "stable.example.com" ,
104+ version = "v1" ,
105+ name = "my-new-cron-object" ,
106+ namespace = "default" ,
107+ plural = "crontabs" ,
108+ body = patch_body ,
109+ )
110+ print ("Resource details:" )
111+ pprint (patch_resource )
112+
96113 # delete it
97114 api .delete_namespaced_custom_object (
98115 group = "stable.example.com" ,
You can’t perform that action at this time.
0 commit comments