Skip to content

Commit 9248a90

Browse files
committed
Removed the custom_object.py file and and added namespaced_custom_object.py
1 parent 68aeb30 commit 9248a90

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

examples/custom_object.py renamed to examples/namespaced_custom_object.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
a CronTab. This example use an example CRD from this tutorial:
1818
https://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
2222
apiVersion: apiextensions.k8s.io/v1
2323
kind: 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",

0 commit comments

Comments
 (0)