Skip to content

How to close stdin in a exec response?Β #2371

@mahesh-hegde

Description

@mahesh-hegde

What is the feature and why do you need it:
I have the use case to do the python equivalent of

cat $local_file | kubectl exec command_in_container

I have been able to use something like this

        core_api = client.CoreV1Api(api_client)
        stream_response: WSClient = stream(
            core_api.connect_get_namespaced_pod_exec, pod_name,
            pod_namespace, command=command,
            stdin=True,
            stdout=False,
            stderr=True,
            _preload_content=False,
        )
        # Ideally I need to do streaming-write, but for sake of example, just a text:
        if input_text:
          stream_response.write_stdin(input_text)

But here's the problem. The process invoked on container through the exec command needs to know the input has ended. I don't find a way to close the stdin of the command.

Describe the solution you'd like to see:

I think ideally we have a function to close the stdin

response.close_stdin()

Need to check how go client and kubectl handles this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions