Commit Graph

28 Commits

Author SHA1 Message Date
Bryan Boreham 40c811e2d9 Comment default behaviour of GracePeriodSeconds
It took me a while to spot this subtlety.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

Kubernetes-commit: 7c764c8550121b48a6e2678700b6a80fa7d3e2f0
2020-11-23 17:46:14 +00:00
blade 9cc15e588a return success if cordon node by replace
Kubernetes-commit: c825e8ec16482ebbefc3ae96a26f4dcf924e750c
2019-12-12 20:20:29 +08:00
Douglas Schilling Landgraf 56ea9621b7 kubectl: deprecate --delete-local-data
The option --delete-local-data according with users is not clear.
This patch deprecate --delete-local-data in favor of --delete-emptydir-data.

Reference:
https://github.com/kubernetes/kubernetes/issues/80228

Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>

Kubernetes-commit: 625e47aaa2769d221c59e5b9b05b4ac97212719b
2020-09-25 17:33:45 -04:00
Amanda Hager Lopes de Andrade Katz 587d894118 Fixes high CPU usage in kubectl drain
Kubernetes-commit: de9c2c2090bbf66943022e902868a5457410af90
2020-10-02 16:02:12 -03:00
Michael Gugino a28f944c90 kubectl/drain add support for custom pod filters
Currently, there is no way to supply custom pod filters to
exclude pods meeting arbitrary criteria when using drain
as a library.

This commit adds the ability for developers to add custom
filters to the drain operation when utilizing drain
as a library.

This commit exports certain types that were previously
private to allow for better code reuse.

This commit also adds appropriate unit tests.

Kubernetes-commit: 85004f030dc3dceb9d15f41fdd607545758d5da2
2020-02-18 19:15:07 -05:00
Michael Gugino e5ddedb459 Handle eviction of pods in deleted namespace
If a pod is already marked deleted, and the eviction
api returns an unauthorized response, ignore that
error since the pod is marked for deletion already.

If the pod is not already marked deleted, retry.

Kubernetes-commit: 8d2a2ffe014ed06b5f8971e7f3dc25ec155e44d4
2020-08-12 16:15:54 -04:00
Ryan Phillips de06b92a12 drain: eviction creates in a deleting namespace will throw a forbidden error
we can safely ignore this error since a deleting namespace will delete
all pods

Kubernetes-commit: 93f62dad6c58bb41c396c48f54c0a73830779599
2020-03-20 14:43:33 -05:00
David Eads 25d0565d86 update drain message to include namespace for pod in kubectl get compatible format
Kubernetes-commit: 9655953000406ce413772ac7d5082c923e913bb4
2020-08-26 11:58:14 -04:00
Jordan Liggitt 197605389f Fix int->string casts
Kubernetes-commit: 124a5ddf725c4862520d8619017cac9db7a03522
2020-07-24 11:13:07 -04:00
Jordan Liggitt cfef71236e client-go: update expansions callers
Kubernetes-commit: d8abacba40a63395cc064452b09a244555536fca
2020-03-06 16:29:23 -05:00
Mike Danese 15efe80aa3 more artisanal fixes
Most of these could have been refactored automatically but it wouldn't
have been uglier. The unsophisticated tooling left lots of unnecessary
struct -> pointer -> struct transitions.

Kubernetes-commit: 76f85943787a5901a34a314a935712177edd2db0
2020-03-01 09:34:30 -08:00
Mike Danese 96c320d500 automated refactor
Kubernetes-commit: c58e69ec791e4dd8a1298d5c2cc0649cf9176f67
2020-03-01 09:24:42 -08:00
Julian V. Modesto f9460c5333 Use --dry-run=client,server in kubectl.
- Support --dry-run=server for subcommands apply, run, create, annotate,
expose, patch, label, autoscale, apply set-last-applied, drain, rollout undo
- Support --dry-run=server for set subcommands
  - image
  - resources
  - serviceaccount
  - selector
  - env
  - subject
- Support --dry-run=server for create subcommands.
  - clusterrole
  - clusterrolebinding
  - configmap
  - cronjob
  - job
  - deployment
  - namespace
  - poddisruptionbudget
  - priorityclass
  - quota
  - role
  - rolebinding
  - service
  - secret
  - serviceaccount
- Remove GetClientSideDryRun

Kubernetes-commit: 13b80b48cd02b8263d910f2423a1f5b92cdf7644
2020-01-30 20:23:33 -05:00
zhouya0 94b91c1d51 fix kubectl drain ignore daemonsets and others
Kubernetes-commit: e3c8add683a095f1bffef1b0ca413f1e42be7fe0
2020-01-19 14:28:53 +08:00
Mike Danese 29cd24b6cc generated: run refactor
Kubernetes-commit: 25651408aeadf38c3df7ea8c760e7519fd37d625
2020-02-08 12:30:21 -05:00
Mike Danese 71d8052cb0 generated: run refactor
Kubernetes-commit: 3aa59f7f3077642592dc8a864fcef8ba98699894
2020-02-07 18:16:47 -08:00
Michael Gugino a17d91f9f5 kubectl: remove unreachable code
This code cannot be reached and causes some external linters
to fail.

Kubernetes-commit: 46fd8fce45cfbbe5681a44872602da6daea80cf6
2019-10-23 11:20:40 -04:00
Michael Gugino ebda9f6262 kubectl/drain: add option skip-wait-for-delete-timeout
Currently, some circumstances may cause waitForDelete to
never succeed after the pod has been marked for deletion.
In particular, Nodes that are unresponsive and have
pods with local-storage will not be able to
successfully drain.

We should allow drain to ignore pods that have a
DeletionTimestamp older than a user-provided age.
This will allow controllers utilizing kubectl/drain
to optionally account for a pod that cannot be
removed due to a misbehaving node.

Kubernetes-commit: da53044abdf8c8a9771a5c3dfd861f0c4ec78c40
2019-11-23 20:00:06 -05:00
Sally O'Malley 6d309ed99e When running `kubectl drain` in dry-run, list warnings and pods that would be deleted.
Kubernetes-commit: 909300b8be909c48a68900c407de03be95555409
2019-09-12 14:31:09 -04:00
Michael Gugino feccbe3c28 kubectl/drain: add disable-eviction option
Currently, if eviction is supported during a drain operation,
eviction is always used.

This commit allows the user to specify disabling eviction.
This is particularly useful when you wish to ignore
PodDisruptionBudgets after a normal drain has failed for
some time.

Kubernetes-commit: 6c1d587d5142b95e6c169a198a086332a7e4d8ad
2019-11-23 11:18:52 -05:00
Michael Gugino fe592e7f80 kubectl/drain: Add context support
This commits allows specifying a context.Context
in the Helper type. This context is utilized to
cancel waitForDelete.

Kubernetes-commit: 8682e902f5487e04b893da7230125db0d7ae66b4
2019-11-23 13:58:59 -05:00
Ted Yu eb7c1bf189 Only put un-filtered pod in podDeleteList
Kubernetes-commit: 65c2f61806468d25795516d6077ce0c31c83adcd
2019-10-30 09:55:34 -07:00
ritho b0cd1c2290 Do some Kubectl optimizations suggested by the golangci linter
The tool golangci-lint gives a bunch of warnings. This PR solves the easier/less controversial ones, so the code is simpler and a little bit more optimal, since it removes some if conditions.

Kubernetes-commit: cd2adbe760641f844d84d411f9adcf17fb6982ff
2019-06-04 01:25:43 -05:00
Michael Gugino ff5adba11b Add timeout info to kubectl drain logging
Kubernetes-commit: 0088a9e6a8c47b2710fc49b82a912861cda8a554
2019-10-21 15:21:26 -04:00
Michael Gugino e09feee202 kubectl drain: avoid leaking goroutines
Recently, kubectl drain has been refactored to be consumeable
as a library.  Currently, if a pod cannot be evicted due
to PDBs, we will leak a goroutine.

This commit ensures the goroutine always exists.

Related-bug: https://github.com/kubernetes/kubernetes/issues/81333

Kubernetes-commit: 0e8998a040efe5dd82592911e739fe2e2258cfa3
2019-10-15 15:24:27 -04:00
Justin SB 75fdf29ade Add tests for newly exposed drain code
Kubernetes-commit: 4bba4449ae41a7889ad29da4bd1704ae8d19d126
2019-08-19 16:22:04 -04:00
Justin SB 3989dccd8b Make drain library more reusable
Move more functionality from the kubectl cmd to a package with
fewer dependencies.

Kubernetes-commit: c74f2f6a72bf6fe2718d1e386e4e08747f34fe7b
2019-07-11 13:28:25 -04:00
Sean Sullivan 200ba9edb8 Move pkg/kubectl/drain to staging
Kubernetes-commit: eaea71cf8449a804c762b96f6d278064c0926ae4
2019-07-24 21:10:54 -07:00