File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 17
17
a CronTab. This example use an example CRD from this tutorial:
18
18
https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/
19
19
20
- The following yaml manifest has to be applied first:
20
+ The following yaml manifest has to be applied first for namespaced scoped CRD :
21
21
22
22
apiVersion: apiextensions.k8s.io/v1
23
23
kind: CustomResourceDefinition
@@ -72,6 +72,11 @@ def main():
72
72
}
73
73
}
74
74
75
+ # patch to update the `spec.cronSpec` field
76
+ patch_body = {
77
+ "spec" : {"cronSpec" : "* * * * */10" , "image" : "my-awesome-cron-image" }
78
+ }
79
+
75
80
# create the resource
76
81
api .create_namespaced_custom_object (
77
82
group = "stable.example.com" ,
@@ -93,6 +98,18 @@ def main():
93
98
print ("Resource details:" )
94
99
pprint (resource )
95
100
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
+
96
113
# delete it
97
114
api .delete_namespaced_custom_object (
98
115
group = "stable.example.com" ,
You can’t perform that action at this time.
0 commit comments