Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from kubernetes import config
- from kubernetes.client import Configuration
- from kubernetes.client.api import core_v1_api
- from kubernetes.client.rest import ApiException
- from kubernetes.stream import stream
- def main():
- config.load_kube_config()
- try:
- core_v1 = core_v1_api.CoreV1Api()
- resp = core_v1.read_namespaced_pod(name='transcode-api-2zvb2',namespace='default')
- print(resp.spec.containers[0].image)
- resp.spec.containers[0].image = '192.168.1.179:5000/wondertek/f:v3.0.0_d1_k8s_1_14_5.20201215093847'
- pod_manifest = {
- 'apiVersion': 'v1',
- 'kind': 'Pod',
- 'metadata': {'name':'transcode-api-12346'},
- 'spec': resp.spec
- }
- #core_v1.delete_namespaced_pod(name='transcode-api-123456', namespace='default')
- core_v1.create_namespaced_pod(body=pod_manifest, namespace='default')
- except ApiException as e:
- print(e)
- if e.status != 404:
- print("Unknown error: %s" % e)
- exit(1)
Add Comment
Please, Sign In to add comment