mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Merge pull request #46927 from shiywang/delete
Automatic merge from submit-queue (batch tested with PRs 46927, 50664, 50710) Remove deprecated command 'kubectl stop' Fixes https://github.com/kubernetes/kubernetes/issues/11384 I think this is the final step @kubernetes/sig-cli-pr-reviews @kargakis
This commit is contained in:
commit
0439695ee8
@ -109,7 +109,6 @@ docs/man/man1/kubectl-set-selector.1
|
|||||||
docs/man/man1/kubectl-set-serviceaccount.1
|
docs/man/man1/kubectl-set-serviceaccount.1
|
||||||
docs/man/man1/kubectl-set-subject.1
|
docs/man/man1/kubectl-set-subject.1
|
||||||
docs/man/man1/kubectl-set.1
|
docs/man/man1/kubectl-set.1
|
||||||
docs/man/man1/kubectl-stop.1
|
|
||||||
docs/man/man1/kubectl-taint.1
|
docs/man/man1/kubectl-taint.1
|
||||||
docs/man/man1/kubectl-top-node.1
|
docs/man/man1/kubectl-top-node.1
|
||||||
docs/man/man1/kubectl-top-pod.1
|
docs/man/man1/kubectl-top-pod.1
|
||||||
@ -252,7 +251,6 @@ docs/yaml/kubectl/kubectl_run-container.yaml
|
|||||||
docs/yaml/kubectl/kubectl_run.yaml
|
docs/yaml/kubectl/kubectl_run.yaml
|
||||||
docs/yaml/kubectl/kubectl_scale.yaml
|
docs/yaml/kubectl/kubectl_scale.yaml
|
||||||
docs/yaml/kubectl/kubectl_set.yaml
|
docs/yaml/kubectl/kubectl_set.yaml
|
||||||
docs/yaml/kubectl/kubectl_stop.yaml
|
|
||||||
docs/yaml/kubectl/kubectl_taint.yaml
|
docs/yaml/kubectl/kubectl_taint.yaml
|
||||||
docs/yaml/kubectl/kubectl_top.yaml
|
docs/yaml/kubectl/kubectl_top.yaml
|
||||||
docs/yaml/kubectl/kubectl_uncordon.yaml
|
docs/yaml/kubectl/kubectl_uncordon.yaml
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
This file is autogenerated, but we've stopped checking such files into the
|
|
||||||
repository to reduce the need for rebases. Please run hack/generate-docs.sh to
|
|
||||||
populate this file.
|
|
@ -1,3 +0,0 @@
|
|||||||
This file is autogenerated, but we've stopped checking such files into the
|
|
||||||
repository to reduce the need for rebases. Please run hack/generate-docs.sh to
|
|
||||||
populate this file.
|
|
@ -56,7 +56,6 @@ go_library(
|
|||||||
"rollingupdate.go",
|
"rollingupdate.go",
|
||||||
"run.go",
|
"run.go",
|
||||||
"scale.go",
|
"scale.go",
|
||||||
"stop.go",
|
|
||||||
"taint.go",
|
"taint.go",
|
||||||
"top.go",
|
"top.go",
|
||||||
"top_node.go",
|
"top_node.go",
|
||||||
|
@ -161,7 +161,7 @@ __kubectl_require_pod_and_container()
|
|||||||
|
|
||||||
__custom_func() {
|
__custom_func() {
|
||||||
case ${last_command} in
|
case ${last_command} in
|
||||||
kubectl_get | kubectl_describe | kubectl_delete | kubectl_label | kubectl_stop | kubectl_edit | kubectl_patch |\
|
kubectl_get | kubectl_describe | kubectl_delete | kubectl_label | kubectl_edit | kubectl_patch |\
|
||||||
kubectl_annotate | kubectl_expose | kubectl_scale | kubectl_autoscale | kubectl_taint | kubectl_rollout_*)
|
kubectl_annotate | kubectl_expose | kubectl_scale | kubectl_autoscale | kubectl_taint | kubectl_rollout_*)
|
||||||
__kubectl_get_resource
|
__kubectl_get_resource
|
||||||
return
|
return
|
||||||
@ -356,10 +356,7 @@ func NewKubectlCommand(f cmdutil.Factory, in io.Reader, out, err io.Writer) *cob
|
|||||||
}
|
}
|
||||||
groups.Add(cmds)
|
groups.Add(cmds)
|
||||||
|
|
||||||
filters := []string{
|
filters := []string{"options"}
|
||||||
"options",
|
|
||||||
deprecated("kubectl", "delete", cmds, NewCmdStop(f, out)),
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hide the "alpha" subcommand if there are no alpha commands in this build.
|
// Hide the "alpha" subcommand if there are no alpha commands in this build.
|
||||||
alpha := NewCmdAlpha(f, in, out, err)
|
alpha := NewCmdAlpha(f, in, out, err)
|
||||||
|
@ -1,109 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2014 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
|
|
||||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
|
||||||
"k8s.io/kubernetes/pkg/kubectl/resource"
|
|
||||||
"k8s.io/kubernetes/pkg/util/i18n"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
stopLong = templates.LongDesc(i18n.T(`
|
|
||||||
Deprecated: Gracefully shut down a resource by name or filename.
|
|
||||||
|
|
||||||
The stop command is deprecated, all its functionalities are covered by delete command.
|
|
||||||
See 'kubectl delete --help' for more details.
|
|
||||||
|
|
||||||
Attempts to shut down and delete a resource that supports graceful termination.
|
|
||||||
If the resource is scalable it will be scaled to 0 before deletion.`))
|
|
||||||
|
|
||||||
stopExample = templates.Examples(i18n.T(`
|
|
||||||
# Shut down foo.
|
|
||||||
kubectl stop replicationcontroller foo
|
|
||||||
|
|
||||||
# Stop pods and services with label name=myLabel.
|
|
||||||
kubectl stop pods,services -l name=myLabel
|
|
||||||
|
|
||||||
# Shut down the service defined in service.json
|
|
||||||
kubectl stop -f service.json
|
|
||||||
|
|
||||||
# Shut down all resources in the path/to/resources directory
|
|
||||||
kubectl stop -f path/to/resources`))
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewCmdStop(f cmdutil.Factory, out io.Writer) *cobra.Command {
|
|
||||||
options := &resource.FilenameOptions{}
|
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "stop (-f FILENAME | TYPE (NAME | -l label | --all))",
|
|
||||||
Short: i18n.T("Deprecated: Gracefully shut down a resource by name or filename"),
|
|
||||||
Long: stopLong,
|
|
||||||
Example: stopExample,
|
|
||||||
Deprecated: fmt.Sprintf("use %q instead.", "delete"),
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
|
||||||
cmdutil.CheckErr(cmdutil.ValidateOutputArgs(cmd))
|
|
||||||
cmdutil.CheckErr(RunStop(f, cmd, args, out, options))
|
|
||||||
},
|
|
||||||
}
|
|
||||||
usage := "of resource(s) to be stopped."
|
|
||||||
cmdutil.AddFilenameOptionFlags(cmd, options, usage)
|
|
||||||
cmd.Flags().StringP("selector", "l", "", "Selector (label query) to filter on.")
|
|
||||||
cmd.Flags().Bool("all", false, "Select all resources in the namespace of the specified resource types.")
|
|
||||||
cmd.Flags().Bool("ignore-not-found", false, "Treat \"resource not found\" as a successful stop.")
|
|
||||||
cmd.Flags().Int("grace-period", -1, "Period of time in seconds given to the resource to terminate gracefully. Ignored if negative.")
|
|
||||||
cmd.Flags().Duration("timeout", 0, "The length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object")
|
|
||||||
cmdutil.AddOutputFlagsForMutation(cmd)
|
|
||||||
cmdutil.AddInclude3rdPartyFlags(cmd)
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
func RunStop(f cmdutil.Factory, cmd *cobra.Command, args []string, out io.Writer, options *resource.FilenameOptions) error {
|
|
||||||
cmdNamespace, enforceNamespace, err := f.DefaultNamespace()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
mapper, _ := f.Object()
|
|
||||||
r := f.NewBuilder(true).
|
|
||||||
ContinueOnError().
|
|
||||||
NamespaceParam(cmdNamespace).DefaultNamespace().
|
|
||||||
ResourceTypeOrNameArgs(false, args...).
|
|
||||||
FilenameParam(enforceNamespace, options).
|
|
||||||
SelectorParam(cmdutil.GetFlagString(cmd, "selector")).
|
|
||||||
SelectAllParam(cmdutil.GetFlagBool(cmd, "all")).
|
|
||||||
Flatten().
|
|
||||||
Do()
|
|
||||||
if r.Err() != nil {
|
|
||||||
return r.Err()
|
|
||||||
}
|
|
||||||
shortOutput := cmdutil.GetFlagString(cmd, "output") == "name"
|
|
||||||
gracePeriod := cmdutil.GetFlagInt(cmd, "grace-period")
|
|
||||||
waitForDeletion := false
|
|
||||||
if gracePeriod == 0 {
|
|
||||||
// To preserve backwards compatibility, but prevent accidental data loss, we convert --grace-period=0
|
|
||||||
// into --grace-period=1 and wait until the object is successfully deleted.
|
|
||||||
gracePeriod = 1
|
|
||||||
waitForDeletion = true
|
|
||||||
}
|
|
||||||
return ReapResult(r, f, out, false, cmdutil.GetFlagBool(cmd, "ignore-not-found"), cmdutil.GetFlagDuration(cmd, "timeout"), gracePeriod, waitForDeletion, shortOutput, mapper, false)
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user