Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubectl 'exec' and 'cp' equivalent #237

Closed
saada opened this issue Oct 13, 2018 · 5 comments
Closed

kubectl 'exec' and 'cp' equivalent #237

saada opened this issue Oct 13, 2018 · 5 comments
Assignees
Labels
kind/enhancement Improvements or new features resolution/wont-fix This issue won't be fixed

Comments

@saada
Copy link

saada commented Oct 13, 2018

I would like to be able to exec some code on-demand. This is especially relevant for use-cases where I want to use pulumi to build kubernetes operators.

Proposed APIs

exec

// concat stream buffers into entire output strings
const pods = await deployment.getPods()
const {stdout, stderr} = await pods[0].exec("echo", ["hello", "world"])
console.log(stdout, stderr)

execStream

const pods = await deployment.getPods()
const {stdout, stderr} = pods[0].execStream("echo", ["hello", "world"])
stdout.pipe(process.stdout)
stderr.pipe(process.stderr)

cp

import fs from 'fs'
const pods = await deployment.getPods()
const readStream = fs.createReadStream('myfile.txt')
await pods[0].cp(readStream, "/tmp/myfile.txt")

// or from an inline string
import { Readable } from 'stream'
const inlineStream = new Readable()
const inlineFile = `
#!/bin/bash
echo hello world
`
inlineFile.split('\n').forEach(line => inlineStream.push(line))
inlineStream.push(null)
await pods[0].cp(inlineStream, "/tmp/myfile.txt")
@hausdorff
Copy link
Contributor

I've been thinking a lot about this sort of thing too. I think it's super useful, but a key question for me is how this fits into the rest of Pulumi -- the rest of the SDK is highly declarative, and opening the door to imperative APIs that let you mutate existing resources is a huge leap, and one we should consider carefully before committing to. I'll be playing with it more over the next couple months, after which I expect to have stronger opinions.

In the meantime, the official Kubernetes JavaScript client offers these things out of the box. It should be feasible to use this stuff with Pulumi, which should bridge the gap in the short term.

@saada
Copy link
Author

saada commented Oct 15, 2018

Thanks @hausdorff ... In the meantime, I created this: kubernetes-client/javascript#124

@lukehoban lukehoban assigned lblackstone and unassigned hausdorff Nov 27, 2019
@infin8x infin8x added kind/enhancement Improvements or new features and removed kind/feature labels Jul 10, 2021
@yellowhat
Copy link

Are there any update in this?
Thanks

@lblackstone
Copy link
Member

lblackstone commented Jul 13, 2022

Adding this to the Kubernetes provider has not been prioritized, but I believe all of the original use cases can be covered with the use of the pulumi-command provider, or by using the Automation API.

@lblackstone lblackstone added the resolution/wont-fix This issue won't be fixed label Jul 14, 2023
@lblackstone
Copy link
Member

We don't have any current plans to add this directly to pulumi-kubernetes. You can run the kubectl commands directly using pulumi-command, or use a k8s client library with Automation API to address these use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features resolution/wont-fix This issue won't be fixed
Projects
None yet
Development

No branches or pull requests

5 participants