-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
Hi,
I'm using Kubernetes client to write a file once the pod turns to running state. Below code creates the file but throwing 403 exception and not able to write the file.
Note: I'm running this code within a pod (say, namespace a) and trying to create file in another namespaced pod (say namespace b).
Code:
config.load_incluster_config()
client_config = Configuration()
batch_client = client.BatchV1Api()
client_config.verify_ssl = False
kube_api = client.CoreV1Api(client.ApiClient(client_config))
script = TEMPLATE_STARTER_SCRIPT.format(instance_name, instance_type, instance_size)
exec_command = ['/bin/sh', '-c', "echo helloworld"]
pod_resp = stream(kube_api.connect_get_namespaced_pod_exec, pod_name, 'jhub-starter',
stderr=True, stdin=True,
stdout=True, tty=False,
_preload_content=False)
LOG.info("preload content")
pod_resp.close()
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/kubernetes/stream/ws_client.py", line 254, in websocket_call
client = WSClient(configuration, get_websocket_url(url), headers)
File "/usr/local/lib/python3.7/site-packages/kubernetes/stream/ws_client.py", line 77, in init
self.sock.connect(url, header=header)
File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 226, in connect
self.handshake_response = handshake(self.sock, *addrs, **options)
File "/usr/local/lib/python3.7/site-packages/websocket/_handshake.py", line 79, in handshake
status, resp = _get_resp_headers(sock)
File "/usr/local/lib/python3.7/site-packages/websocket/_handshake.py", line 160, in _get_resp_headers
raise WebSocketBadStatusException("Handshake status %d %s", status, status_message, resp_headers)
websocket._exceptions.WebSocketBadStatusException: Handshake status 403 Forbidden
Could anyone please help on this issue? I'm struck!
Thanks
Rajashree