tektoncd / cli

A CLI for interacting with Tekton!
Apache License 2.0
431 stars 250 forks source link

Provide a tkn command to export a pipeline without K8s metadata to be used for version control #1220

Closed markito closed 7 months ago

markito commented 4 years ago

Feature request

As a user building my pipeline using the vscode plugin or any UI I'd like to export the pipeline using the tkn CLI and store it on Git for version control without the metadata k8s add to the yaml.

danielhelfand commented 4 years ago

I guess the question comes down to what this currently looks like with kubectl and whether it would be worth abstracting to make it simpler through tkn.

Also, to clarify what the UX would look like, is the thought to just get the resource definitions from Kubernetes as output and be able to save to a local file?

tkn pipeline export foo > foo.yaml

Or is it something else?

markito commented 4 years ago

That's right. As far as UX I'd expect something similar to what's available for kn - The Knative CLI today, modulo the differences between both tools. In Knative we had to deal with revisions and make sure developers had an option to not export them for example.

The end goal IMO is that I can export this pipeline from my environment A and import it on environment B and "it just works". Which in practice may still be dependent of the tasks my pipeline uses and the tasks available on the cluster being imported. So I'd imagine that the tkn import could potentially check for those things and fail in case a task or other dep is missing.

Hope that helps. Please find below the kn example and options.


$ kn service export --help
Export a service and its revisions

Examples:

  # Export a service in YAML format
  kn service export foo -n bar -o yaml
  # Export a service in JSON format
  kn service export foo -n bar -o json
  # Export a service with revisions
  kn service export foo --with-revisions --mode=resources -n bar -o json
  # Export services in kubectl friendly format, as a list kind, one service item for each revision
  kn service export foo --with-revisions --mode=kubernetes -n bar -o json

Options:
      --allow-missing-template-keys   If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. (default true)
      --mode string                   Format for exporting all routed revisions. One of replay|export (experimental)
  -n, --namespace string              Specify the namespace to operate in.
  -o, --output string                 Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file.
      --template string               Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates
                                      [http://golang.org/pkg/text/template/#pkg-overview].
      --with-revisions                Export all routed revisions (experimental)

Usage:
  kn service export NAME [options]

Use "kn options" for a list of global command-line options (applies to all commands).````
chmouel commented 4 years ago

I use this kubectl plugin for that which does mostly a good job https://github.com/itaysk/kubectl-neat :

image

I am not against having this 'builtin' but there used to have a "kubectl export" command which got deprecated and removed for some reasons, and we probably want to dig around to see what was the reasoning for the removal so we don't make those same errors.

chmouel commented 4 years ago

Since I needed to have this quickly I released this utility :

https://github.com/chmouel/tekton-neat

imho it still make sense to have this in tkn directly.

tekton-robot commented 3 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale with a justification. Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with /close with a justification. If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle stale

Send feedback to tektoncd/plumbing.

piyush-garg commented 3 years ago

/remove-lifecycle stale

tekton-robot commented 3 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale with a justification. Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with /close with a justification. If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle stale

Send feedback to tektoncd/plumbing.

tekton-robot commented 3 years ago

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten with a justification. Rotten issues close after an additional 30d of inactivity. If this issue is safe to close now please do so with /close with a justification. If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle rotten

Send feedback to tektoncd/plumbing.

nikhil-thomas commented 3 years ago

/lifecycle frozen

this is still relevant. this could be functionaly releated to work needed for https://github.com/tektoncd/cli/issues/642

xinnjie commented 1 year ago

I am not against having this 'builtin' but there used to have a "kubectl export" command which got deprecated and removed for some reasons, and we probably want to dig around to see what was the reasoning for the removal so we don't make those same errors.

Found the discussion why kubectl deprecated export utility: https://github.com/kubernetes/kubernetes/pull/73787 https://github.com/tektoncd/cli/pull/1398.

What problem kubectl export utility is not well-defined, and several bugs came out for that reason. Some use case even conflicts.

chmouel commented 7 months ago

tk pipelinerun export/tkn pipeline export is implemented in cli since quite a long time ago