Skip to content

Commit d593fc6

Browse files
committed
change BatchV1beta1Api to BatchV1Api
1 parent ab58e5c commit d593fc6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

examples/cronjob_crud.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def create_namespaced_cron_job(namespace='default', body=None):
1818
if judge_crontab_exists(namespace, name):
1919
print(f'{name} exists, please do not repeat!')
2020
else:
21-
v1 = client.BatchV1beta1Api()
21+
v1 = client.BatchV1Api()
2222
ret = v1.create_namespaced_cron_job(namespace=namespace, body=cronjob_json, pretty=True,
2323
_preload_content=False, async_req=False)
2424
ret_dict = json.loads(ret.data)
@@ -32,7 +32,7 @@ def delete_namespaced_cron_job(namespace='default', name=None):
3232
if not judge_crontab_exists(namespace, name):
3333
print(f"{name} doesn't exists, please enter a new one!")
3434
else:
35-
v1 = client.BatchV1beta1Api()
35+
v1 = client.BatchV1Api()
3636
ret = v1.delete_namespaced_cron_job(name=name, namespace=namespace, _preload_content=False, async_req=False)
3737
ret_dict = json.loads(ret.data)
3838
print(f'delete succeed\n{json.dumps(ret_dict)}')
@@ -45,7 +45,7 @@ def patch_namespaced_cron_job(namespace='default', body=None):
4545
exit(0)
4646
name = body['metadata']['name']
4747
if judge_crontab_exists(namespace, name):
48-
v1 = client.BatchV1beta1Api()
48+
v1 = client.BatchV1Api()
4949
ret = v1.patch_namespaced_cron_job(name=name, namespace=namespace, body=cronjob_json,
5050
_preload_content=False, async_req=False)
5151
ret_dict = json.loads(ret.data)
@@ -55,7 +55,7 @@ def patch_namespaced_cron_job(namespace='default', body=None):
5555

5656

5757
def get_cronjob_list(namespace='default'):
58-
v1 = client.BatchV1beta1Api()
58+
v1 = client.BatchV1Api()
5959
ret = v1.list_namespaced_cron_job(namespace=namespace, pretty=True, _preload_content=False)
6060
cron_job_list = json.loads(ret.data)
6161
print(f'cronjob number={len(cron_job_list["items"])}')
@@ -72,7 +72,7 @@ def judge_crontab_exists(namespace, name):
7272

7373
def get_cronjob_body(namespace, name, command):
7474
body = {
75-
"apiVersion": "batch/v1beta1",
75+
"apiVersion": "batch/v1",
7676
"kind": "CronJob",
7777
"metadata": {
7878
"name": name,

0 commit comments

Comments
 (0)