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

Drop deprecated run flags and deprecate unused ones #99732

Merged
merged 1 commit into from Mar 6, 2021

Conversation

soltysh
Copy link
Contributor

@soltysh soltysh commented Mar 3, 2021

What type of PR is this?

/kind cleanup
/kind deprecation
/sig cli

What this PR does / why we need it:

This PR remove entirely flags which were deprecated since cleaning kubectl run command.

Special notes for your reviewer:

/assign @rikatz

Does this PR introduce a user-facing change?

Remove deprecated --generator --replicas --service-generator --service-overrides --schedule from kubectl run
Deprecate --serviceaccount --hostport --requests --limits in kubectl run

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/deprecation Categorizes issue or PR as related to a feature/enhancement marked for deprecation. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. sig/cli Categorizes an issue or PR as relevant to SIG CLI. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/kubectl area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Mar 3, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: soltysh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 3, 2021
@soltysh
Copy link
Contributor Author

soltysh commented Mar 3, 2021

/triage accepted
/priority backlog

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/backlog Higher priority than priority/awaiting-more-evidence. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Mar 3, 2021
@rikatz
Copy link
Contributor

rikatz commented Mar 3, 2021

Can we have a :party_parrot: here?

Will review ASAP so this can ship in v1.21

@@ -311,10 +302,7 @@ func (o *RunOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) e
}

generators := generateversioned.GeneratorFn("run")
generator, found := generators[generateversioned.RunPodV1GeneratorName]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we are dropping the generator flag, but I'm wondering if we still shouldn't be checking the existence of this on the map. Otherwise, on the next line (names := generator.ParamNames()) we might be calling a nil value and get a panic, if someone removes this generator :)

generators := generateversioned.GeneratorFn("expose")
generator, found := generators[serviceGenerator]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same concern as above here, but I might be over concerned? :D

@rikatz
Copy link
Contributor

rikatz commented Mar 6, 2021

@soltysh just two points of concern here :)

@rikatz rikatz mentioned this pull request Mar 6, 2021
2 tasks
@soltysh
Copy link
Contributor Author

soltysh commented Mar 6, 2021

@soltysh just two points of concern here :)

Good point, updated.

@rikatz
Copy link
Contributor

rikatz commented Mar 6, 2021

/test pull-kubernetes-e2e-kind

Test passed locally, retesting here

@rikatz
Copy link
Contributor

rikatz commented Mar 6, 2021

/lgtm

Thanks!!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 6, 2021
@k8s-ci-robot k8s-ci-robot merged commit f8151b1 into kubernetes:master Mar 6, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.21 milestone Mar 6, 2021
@soltysh soltysh deleted the clean_run_flags branch March 8, 2021 07:18
@shartte
Copy link

shartte commented Apr 23, 2021

Why was --serviceaccount deprecated for kubectl run? Is the intention really that users have to specify this via a JSON blob instead? (Also: Unlike the message says, it does seem to have an effect for me when I use it)

@RileyMShea
Copy link

@soltysh

As described by shartte,

--serviceaccount is still working for me despite the notice about it having no effect.

I'm most concerned because it's described in the current official CKAD Study Guide:

you can use the --serviceaccount flag in conjunction with the run command when creating the Pod:

Example

❮ k run nginx --image=nginx --restart=Never --serviceaccount=custom
Flag --serviceaccount has been deprecated, has no effect and will be removed in the future.
pod/nginx created

❯ k get po nginx -o yaml | rg -i -C 3 serviceaccount               
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: custom-token-ljvxm
      readOnly: true
  dnsPolicy: ClusterFirst
--
  restartPolicy: Never
  schedulerName: default-scheduler
  securityContext: {}
  serviceAccount: custom
  serviceAccountName: custom

Kubectl version info

❯ k version -o yaml
clientVersion:
  buildDate: "2021-04-08T16:31:21Z"
  compiler: gc
  gitCommit: cb303e613a121a29364f75cc67d3d580833a7479
  gitTreeState: clean
  gitVersion: v1.21.0
  goVersion: go1.16.1
  major: "1"
  minor: "21"
  platform: linux/amd64
serverVersion:
  buildDate: "2021-01-13T13:20:00Z"
  compiler: gc
  gitCommit: faecb196815e248d3ecfb03c680a4507229c2a56
  gitTreeState: clean
  gitVersion: v1.20.2
  goVersion: go1.15.5
  major: "1"
  minor: "20"
  platform: linux/amd64

@davidalger
Copy link

I'd also like to know why --serviceaccount is being deprecated. It is incredibly useful, and nothing in this PR points to a reason for the deprecation.

The alternative is quite clunky:

--overrides='{ "spec": { "serviceAccount" : "my-service-account" } }'

schnatterer added a commit to cloudogu/gitops-playground that referenced this pull request Jul 27, 2021
…lure.

There is some discussion going on about the kubectl run --serviceaccount flag. It is deprecated but still works: kubernetes/kubernetes#99732
So for now, use the "overrides" workaround.

--restart=OnFailure - leaves the pod in status completed, if no errors occur. Otherwise it would restart and apply again, even on success.

Why don't we use a job instead of a pod?

It's likely that we would have to use YAML, because "kubectl create job" does not support --override. This makes handling it much more complicate for the user. For example, passing flags such as --remote, --argocd, etc.
Also interactive mode (""-i --tty") is not possible.
This makes it more complicate to wait for success and to view output. This would likely require a combination of "kubectl wait --for=condition=failure job/myjob" and "kubectl logs -f".

So for now, "kubectl run" seems to be the easiest way here.
@ckittel
Copy link

ckittel commented Aug 30, 2021

Same question but for --limits -- the output says it's not being honored, but it is -- how long will that exist in this state, I wonder.

@llorllale
Copy link
Contributor

Was the reason for deprecation of --serviceaccount ever provided?

@lodotek
Copy link

lodotek commented Dec 5, 2023

Was the reason for deprecation of --serviceaccount ever provided?

According to bing's GPT:

The --serviceaccount flag along with other generators in the kubectl run command were deprecated due to a couple of reasons1:

Complexity for users: The vast number of input parameters for the kubectl run command was overwhelming for both newcomers and experienced users. It was challenging to predict the result of a command invocation, as it required considering several passed options as well as the server version1.

Maintenance challenges: The code behind the kubectl run command was difficult to maintain due to the growing matrix of possibilities1.

The intention behind this deprecation was to simplify the user experience and make maintenance more manageable. The Kubernetes team wanted to move users away from using kubectl run for their daily workflows and encourage them to use explicit kubectl create commands, which are more straightforward1.

As of a certain update, kubectl run will only create Pods, and all generators will be removed entirely1. This change aligns with the experience of running a container in Docker or any other container engine, where a single command runs a container. In Kubernetes, kubectl run will just run a Pod in a cluster1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubectl area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/deprecation Categorizes issue or PR as related to a feature/enhancement marked for deprecation. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/backlog Higher priority than priority/awaiting-more-evidence. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants