Wait for a resource to exist in the k8s api. This is a blocking call with no timeout. resource_type: k8s resource type. e.a. pod, secret, deployment. resource_name: k8s resource name.
(ns, resource_type, resource_name)
| 209 | raise(e) |
| 210 | |
| 211 | def _waitforresource(ns, resource_type, resource_name): |
| 212 | """ |
| 213 | Wait for a resource to exist in the k8s api. This is a blocking call with no timeout. |
| 214 | resource_type: k8s resource type. e.a. pod, secret, deployment. |
| 215 | resource_name: k8s resource name. |
| 216 | """ |
| 217 | print(f'Waiting for {resource_type} "{resource_name}" to exist in the cluster: ', end='') |
| 218 | sys.stdout.flush() |
| 219 | while True: |
| 220 | try: |
| 221 | run('kubectl', f'-n {ns} get {resource_type} {resource_name}', |
| 222 | cstderr=True, cstdout=True) |
| 223 | print('done') |
| 224 | break |
| 225 | except Exception as _: |
| 226 | print('.', end='') |
| 227 | sys.stdout.flush() |
| 228 | time.sleep(1) |
| 229 | continue |
| 230 | |
| 231 | def _runwithtimeout(target, args, secs): |
| 232 | """ |