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 create alternatives #914

Closed
pwittrock opened this issue Aug 18, 2020 · 11 comments
Closed

kubectl create alternatives #914

pwittrock opened this issue Aug 18, 2020 · 11 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/backlog Higher priority than priority/awaiting-more-evidence.

Comments

@pwittrock
Copy link
Member

pwittrock commented Aug 18, 2020

@eddiezane
@soltysh
@seans3

There have been numerous requests to expand the support for imperative resource creation commands by adding flags to existing creation commands or adding creation commands for additional resources.

The motivation for imperative create commands tend to fall into the following categories:

  1. As a learning tool
  • Used in courses to teach about the APIs
  • Used in documentation to teach about the APIs
  • Used by end users to discover new resource types and experiment with them
  • As a debugging tool
    • Used to quickly create a Pod in a cluster with an attached tty
    • Used to quickly cretea a resource to test an image
  • As an authoring tool
    • Used to bootstrap configuration for a new resource or package

Sig-cli and the kubectl maintainers have pushed back on expanding the functionality of the existing commands in favor of implementing new commands which better meet these needs.

Why the create commands as written today are a suboptimal solution

Why they are suboptimal as a learning tool

  • Don't show the end user the resource configuration by default -- require -o yaml --dry-run
  • Don't show the user the apply command
  • Serialization populates the resource with a bunch of defaults that should not be present
  • Doesn't support adding comments to the configuration to teach the user about the options

Why they are suboptimal as a debugging tool

  • Don't support debug options such as mounting in debug tools
  • Don't attach by default
  • Not well integrated with other debug commands such as logs

Why they are suboptimal as an authoring tool

  • Don't support extension types
  • Work off the client version rather than the server version
  • Populate the configuration with garbage fields
  • Write to the server by default, requires -o yaml --dry-run

What we want in next-gen generation commands

Learning and creation commands

  • Support for extension types and version skew. Examples:
    • Publish a template as part of the openapi-schema
    • Link to a file which is used as a template
    • Link to a field which is uses kustomize setters to populate fields
    • Use URL convention for build-in types to seed the command and support backward compatibility -- e.g. https://sigs.k8s.io/sig-cli/kubectl/gen
  • Operate on yaml first
    • Support for commenting the configuration
    • Don't populate fields which are populated on serialization
  • Write to stdout by default
    • Write to file with flag
    • Update a file in place by merging the generated contents
  • Consider using the OpenAPI examples field and kustomize setters

Want needs to happen

  • Convert this into a KEP
  • Create a new directory and go module under cli-experimental or cli-utils
  • Define a schema for publishing the creation metadata
    • Input fields (e.g. flags)
    • Template
  • Implent client tooling to read the API definitions and dynamically register kubectl gen cobra commands
  • Update the KEP with design decision changes
  • Tweet about it to get feedback
  • Send PR for review
  • Write generation definitions for built-in types
  • Update the docs
  • Update release notes
  • Tweet about it again
@pwittrock pwittrock added the kind/feature Categorizes issue or PR as related to a new feature. label Aug 18, 2020
@fabiand
Copy link

fabiand commented Sep 9, 2020

This is also something we are interested in from the KubeVirt side cc @ashleyschuett

@eddiezane
Copy link
Member

/priority backlog

@k8s-ci-robot k8s-ci-robot added the priority/backlog Higher priority than priority/awaiting-more-evidence. label Sep 16, 2020
@eddiezane
Copy link
Member

@pwittrock we need to condense this to fit in the FAQ kubernetes/kubernetes#94989

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
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.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 22, 2020
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jan 21, 2021
@soltysh
Copy link
Contributor

soltysh commented Jan 21, 2021

/remove-lifecycle rotten
/lifecycle frozen

@k8s-ci-robot k8s-ci-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Jan 21, 2021
dgofman added a commit to dgofman/kubectl that referenced this issue Sep 12, 2022
dgofman added a commit to dgofman/kubernetes that referenced this issue Sep 25, 2022
https://kubernetes.io/docs/concepts/services-networking/network-policies/

NetworkPolicies are an application-centric construct which allow you to specify how a pod is allowed to communicate with various network "entities" (we use the word "entity" here to avoid overloading the more common terms such as "endpoints" and "services", which have specific Kubernetes connotations) over the network. NetworkPolicies apply to a connection with a pod on one or both ends, and are not relevant to other connections.

#### What type of PR is this?
/kind feature

#### What this PR does / why we need it:

Create a network policy using the kubectl create command line:
- Prevents all ingress AND egress traffic
- Create AND rules
- Create OR rules

#### Which issue(s) this PR fixes:
Fixes #
kubernetes/kubectl#914
kubernetes/kubectl#1240

#### Special notes for your reviewer:

#### Does this PR introduce a user-facing change?
```release-note
NONE
```

#### Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
@sftim
Copy link
Contributor

sftim commented Nov 4, 2022

How about a kubectl something subcommand that creates a sample manifest, perhaps with most fields commented out, and opens it in a text editor before doing anything further.

The user then edits the manifest locally in their text editor or IDE. On saving it, kubectl submits that to the control plane.

This approach could work for making new:

  • Deployments
  • StatefulSets
  • Jobs
  • VerticalPodAutoscalers
  • MachinePools
  • Gateways
  • IngressClasses

and out-of-project things like:

  • ImageRepositories
  • ClusterIssuers
  • (Argo) Rollouts
  • Prometheuses

An alternative form of this command could write the manifest out but not edit it. Importantly, non-mandatory fields would be commented out, so this is different from doing a server-side dry run request and saving the result.

Generated fields such as .metadata.resourceVersion could be omitted entirely, as this command is there for making new resources (I'd expect kubectl to report a conflict rather than trying to autoresolve it).

@sftim
Copy link
Contributor

sftim commented Nov 4, 2022

Extra credit: also make this work for subresources.

@armujahid
Copy link

@sftim, I think kubectl generate will satisfy that use case. It's currently a work in progress (https://github.com/eddiezane/kubectl-generate).
We can generate a manifest, edit it in our favorite editor, then pipe it to kubectl apply to satisfy the use case you mentioned.

@ardaguclu
Copy link
Member

This was enabled by kubernetes/enhancements#3638 already and I'm closing;
/close

@k8s-ci-robot
Copy link
Contributor

@ardaguclu: Closing this issue.

In response to this:

This was enabled by kubernetes/enhancements#3638 already and I'm closing;
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/backlog Higher priority than priority/awaiting-more-evidence.
Projects
None yet
Development

No branches or pull requests

9 participants