change BatchV1beta1Api to BatchV1Api
@@ -18,7 +18,7 @@ def create_namespaced_cron_job(namespace='default', body=None):
if judge_crontab_exists(namespace, name):
print(f'{name} exists, please do not repeat!')
else:
- v1 = client.BatchV1beta1Api()
+ v1 = client.BatchV1Api()
ret = v1.create_namespaced_cron_job(namespace=namespace, body=cronjob_json, pretty=True,
_preload_content=False, async_req=False)
ret_dict = json.loads(ret.data)
@@ -32,7 +32,7 @@ def delete_namespaced_cron_job(namespace='default', name=None):
if not judge_crontab_exists(namespace, name):
print(f"{name} doesn't exists, please enter a new one!")
else:
- v1 = client.BatchV1beta1Api()
+ v1 = client.BatchV1Api()
ret = v1.delete_namespaced_cron_job(name=name, namespace=namespace, _preload_content=False, async_req=False)
ret_dict = json.loads(ret.data)
print(f'delete succeed\n{json.dumps(ret_dict)}')
@@ -45,7 +45,7 @@ def patch_namespaced_cron_job(namespace='default', body=None):
exit(0)
name = body['metadata']['name']
if judge_crontab_exists(namespace, name):
- v1 = client.BatchV1beta1Api()
+ v1 = client.BatchV1Api()
ret = v1.patch_namespaced_cron_job(name=name, namespace=namespace, body=cronjob_json,
_preload_content=False, async_req=False)
ret_dict = json.loads(ret.data)
@@ -55,7 +55,7 @@ def patch_namespaced_cron_job(namespace='default', body=None):
def get_cronjob_list(namespace='default'):
- v1 = client.BatchV1beta1Api()
+ v1 = client.BatchV1Api()
ret = v1.list_namespaced_cron_job(namespace=namespace, pretty=True, _preload_content=False)
cron_job_list = json.loads(ret.data)
print(f'cronjob number={len(cron_job_list["items"])}')
@@ -72,7 +72,7 @@ def judge_crontab_exists(namespace, name):
def get_cronjob_body(namespace, name, command):
body = {
- "apiVersion": "batch/v1beta1",
+ "apiVersion": "batch/v1",
"kind": "CronJob",
"metadata": {
"name": name,
