kubernetes-resource icon indicating copy to clipboard operation
kubernetes-resource copied to clipboard

Support for writing stdin to a parameter.

Open jmdots opened this issue 6 years ago • 3 comments

Is this a BUG REPORT or FEATURE REQUEST?:

  • feature

What happened: Having a hard time specifying JSON on the command line. And I don't wish to read from a file in git/etc in every case. Need a clean way to code stdin for kubectl into the job.

What you expected to happen: A stdin param would make this easy.

How to reproduce it (as minimally and precisely as possible): Try bash here docs or bash here strings with apply operations that idempotently create namespaces. Quoting and carriage returns make these hacks untenable.

Anything else we need to know?: I generate my pipelines from jsonnet. It renders to json/yaml all the same.

Environment: docker-compose file from main repo.

Here's a concept sketch of what I'm looking for. Perhaps there is already something like this that I missed.

jobs:
- name: kubectl.create_namespace(docker-for-desktop, common)
  plan:
  - params:
      kubectl: apply -f -
      stdin: |
        apiVersion: v1
        kind: Namespace
        metadata:
          labels:
            name: common
          name: common
    put: kubectl.profile(docker-for-desktop)

jmdots avatar Feb 26 '19 03:02 jmdots

related: https://github.com/pivotal-cf/staticfile-resource

jmdots avatar Feb 26 '19 03:02 jmdots

You can use the following way for creating namespace:

  plan:
  - put: cluster
    params:
      kubectl: create namespace common

Therefore, do you have other usecases except creating namespace?

superbrothers avatar Mar 04 '19 06:03 superbrothers

@superbrothers Is that method idempotent or convergent? Trying to create the namespace more than once using that kubectl syntax would usually throw a non-zero error code, in my experience. Yes, other use cases exist but I'll try sorting through it in the current framework until I can state them concretely.

jmdots avatar Mar 18 '19 02:03 jmdots