Skip to content
Snippets Groups Projects
Commit 4c88ac69 authored by Matthew Mosesohn's avatar Matthew Mosesohn Committed by GitHub
Browse files

Use kubectl apply instead of create/replace (#1610)

Disable checks for existing resources to speed up execution.
parent 85c237bc
No related branches found
No related tags found
No related merge requests found
...@@ -139,7 +139,7 @@ class KubeManager(object): ...@@ -139,7 +139,7 @@ class KubeManager(object):
if check and self.exists(): if check and self.exists():
return [] return []
cmd = ['create'] cmd = ['apply']
if not self.filename: if not self.filename:
self.module.fail_json(msg='filename required to create') self.module.fail_json(msg='filename required to create')
...@@ -150,10 +150,7 @@ class KubeManager(object): ...@@ -150,10 +150,7 @@ class KubeManager(object):
def replace(self): def replace(self):
if not self.force and not self.exists(): cmd = ['apply']
return []
cmd = ['replace']
if self.force: if self.force:
cmd.append('--force') cmd.append('--force')
...@@ -271,7 +268,7 @@ def main(): ...@@ -271,7 +268,7 @@ def main():
manager = KubeManager(module) manager = KubeManager(module)
state = module.params.get('state') state = module.params.get('state')
if state == 'present': if state == 'present':
result = manager.create() result = manager.create(check=False)
elif state == 'absent': elif state == 'absent':
result = manager.delete() result = manager.delete()
...@@ -283,11 +280,7 @@ def main(): ...@@ -283,11 +280,7 @@ def main():
result = manager.stop() result = manager.stop()
elif state == 'latest': elif state == 'latest':
if manager.exists(): result = manager.replace()
manager.force = True
result = manager.replace()
else:
result = manager.create(check=False)
else: else:
module.fail_json(msg='Unrecognized state %s.' % state) module.fail_json(msg='Unrecognized state %s.' % state)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment