When I try to fetch logs from rundeck using kubernetes plugin, I got an below error.
ERROR: kubernetes-model-source: Exception error creating: (400)
20:05:58 | Reason: Bad Request
20:05:58 | HTTP response headers: HTTPHeaderDict({'Content-Length': '171', 'Access-Control-Allow-Headers': 'X-Auth-Token,Content-Type,Authorization', 'Strict-Transport-Security': 'max-age=15724800; includeSubDomains', 'Server': 'nginx/1.15.9', 'Connection': 'keep-alive', 'Access-Control-Allow-Credentials': 'true', 'Date': 'Mon, 06 Jan 2020 11:05:58 GMT', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET, PUT, POST, DELETE, PATCH, OPTIONS', 'Content-Type': 'application/json'})
20:05:58 | HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"container None is not valid for pod app-xxxxxxxxxx-xxxxx","reason":"BadRequest","code":400}
20:05:58
I've investigate cause and found that os.environ.get('RD_NODE_DEFAULT_CONTAINER_NAME') returns None and Kubernetes client use it to select container inside pod.
When I try to fetch logs from rundeck using kubernetes plugin, I got an below error.
I've investigate cause and found that
os.environ.get('RD_NODE_DEFAULT_CONTAINER_NAME')
returnsNone
and Kubernetes client use it to select container inside pod.Below code is a current master branch code.
https://github.com/rundeck-plugins/kubernetes/blob/885762da5a949c78632dac17d3cd1df43830ddff/contents/pods-read-logs.py#L22-L37
But we can't specify default container name on Rundeck job window and I've fetched pod logs successfully if I omitted default container name.
So my opinion is that we can remove this default container name and fetch without container name like this: