Commit Graph

888 Commits

Author SHA1 Message Date
Maciej Szulik fe89be9c6f Use separate pathSpec for local and remote to properly handle cleaning paths
Kubernetes-commit: 0fb6815f08f39c8af814fa733d5235681a124b81
2020-08-21 19:24:19 +02:00
Arda Güçlü 8307ca4a3c Add diff command return status code greater than 1 when flags invalid
This PR adds flagerror handler function to detect when flags are invalid.
Default flag handler returns status code 1. However, diff command embraces
this status code as changes are found. By overriding flag errors,
this PR shows same message with default case and returns status code 2.

Kubernetes-commit: 4f0848520d4cdd679c76479949546002c5935e3c
2021-10-04 13:02:34 +03:00
Marc Khouzam e6118325f3 Ignore flags that could precede the Cobra command
See https://github.com/kubernetes/kubectl/issues/1119

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>

Kubernetes-commit: d41c2685b67317fea1d1a3843d8f5870bc724b3b
2021-09-20 18:20:49 -04:00
Marc Khouzam 10504c18ad Do not try to load plugins for cobra commands
Cobra adds the commands 'help', '__complete' and '__completeNoDesc'
inside rootCmd.Execute(), however, when kubectl decides if it should
lookup plugins, rootCmd.Execute() had not been called yet.  Therefore,
the call to cmd.Find(cmdPathPieces) done by kubectl does not find the
commands added by Cobra.  To fix this we must check for them explicitly.

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>

Kubernetes-commit: e703b3d25377e763b117805b3d88fe7236f3ff76
2021-09-19 14:34:10 -04:00
Sean Sullivan 8a45e525e5 Fixes kubectl command headers which hangs on kubectl run
Kubernetes-commit: 1d1a5499e717b928c6b2782fdcad9fa4052a38a1
2021-09-30 13:53:00 -07:00
Patrick Ohly 466b483531 initialize logging after flag parsing
It wasn't documented that InitLogs already uses the log flush frequency, so
some commands have called it before parsing (for example, kubectl in the
original code for logs.go). The flag never had an effect in such commands.

Fixing this turned into a major refactoring of how commands set up flags and
run their Cobra command:

- component-base/logs: implicitely registering flags during package init is an
  anti-pattern that makes it impossible to use the package in commands which
  want full control over their command line. Logging flags must be added
  explicitly now, something that the new cli.Run does automatically.

- component-base/logs: AddFlags would have crashed in kubectl-convert if it
  had been called because it relied on the global pflag.CommandLine. This
  has been fixed and kubectl-convert now has the same --log-flush-frequency
  flag as other commands.

- component-base/logs/testinit: an exception are tests where flag.CommandLine has
  to be used. This new package can be imported to add flags to that
  once per test program.

- Normalization of the klog command line flags was inconsistent. Some commands
  unintentionally didn't normalize to the recommended format with hyphens. This
  gets fixed for sample programs, but not for production programs because
  it would be a breaking change.

This refactoring has the following user-visible effects:

- The validation error for `go run ./cmd/kube-apiserver --logging-format=json
  --add-dir-header` now references `add-dir-header` instead of `add_dir_header`.

- `staging/src/k8s.io/cloud-provider/sample` uses flags with hyphen instead of
  underscore.

- `--log-flush-frequency` is not listed anymore in the --logging-format flag's
  `non-default formats don't honor these flags` usage text because it will also
  work for non-default formats once it is needed.

- `cmd/kubelet`: the description of `--logging-format` uses hyphens instead of
  underscores for the flags, which now matches what the command is using.

- `staging/src/k8s.io/component-base/logs/example/cmd`: added logging flags.

- `apiextensions-apiserver` no longer prints a useless stack trace for `main`
  when command line parsing raises an error.

Kubernetes-commit: 21d1bcd6b8498370832fa76f680d3de56837bc83
2021-09-16 18:18:35 +02:00
wujiangfa-xlauncher cadea4d691 fix top node output format incorrect
#105112

Kubernetes-commit: e838017f11dae4bc1c0a12c9703d0153661bd27d
2021-09-18 09:41:51 +08:00
caozhiyuan 0cf1a18bec handle error when parse Quantity
Kubernetes-commit: b9d7584c3a838d83c6c8c6e405907bf05addc850
2021-09-18 15:05:21 +08:00
Julian V. Modesto f9ab824bc9 Remove deprecated kubectl --dry-run values.
The boolean values for --dry-run have been deprecated for removal since
1.18, more than 2 releases.

The default value for --dry-run with the flag set and unspecified has
been deprecated for removal since 1.18, more than 2 releases.

Both values are now removed in this change. Any kubectl --dry-run
usage no longer accepts --dry-run=(true|false) boolean values and usage
now requires that a value of (client|server|none) is specified.

Kubernetes-commit: e0b7a85ee5b5d546bec2dc0e8cbf5cd4c0c684d8
2021-09-28 10:03:20 -04:00
Chok Yip Lau fad6761bba Improve configmap test
Kubernetes-commit: fa7ad6e4657769f767e3a34407cb6ad327d5259c
2021-09-03 15:54:11 -04:00
Harjas 809211b6c8 kubectl: Use fields from event series when computing describe events for a object (#104482)
* take into account new fields for event

* add event with old event fields for test

* fix: remove unnecessary "+1" from event series count

* fix: update the assertion for failing test case

Kubernetes-commit: c6935ad50e0809c1dc2d3ac9000abda0ecb49bcc
2021-09-14 00:18:50 +00:00
Eddie Zaneski 20604e9e21 Remove functionality from deprecated kubectl run flags
Signed-off-by: Eddie Zaneski <eddiezane@gmail.com>

Kubernetes-commit: da8f404ae09823ff5fa214397215263f095e90f2
2021-09-09 15:22:28 -06:00
jaehnri 72b220068c Fix typo in kubectl describe pods example
Signed-off-by: jaehnri <joao.henri.cr@gmail.com>

Kubernetes-commit: bf1b75f165d0afde7fe9bc810425b488b5c1659e
2021-08-26 21:00:18 -03:00
Zovin Khanmohammed 723266d145 Adds the PowerShell completion generation (#103758)
* Adds the powershell completion generation

* Fixes formatting based on verification script

* Changes generation to include descriptions

* Adjusts formatting and Adds startup information

* Fix build

Kubernetes-commit: dec8528abaa58a4c7fc190df2cad8848799f9891
2021-08-25 22:29:23 -05:00
Wei Lun cdae2c3d88 fix indentation
Kubernetes-commit: 8a1987f0da1d6d881272f9609cadc03fa32c6f11
2021-08-10 16:31:32 +08:00
Wei Lun cb657f63a2 add kubectl fish shell completion
Kubernetes-commit: 3f5176c26512fdb9154a0bd1d34ee61196874251
2020-07-11 22:07:05 +08:00
Stephen Augustus 55e15b6165 generated: Run hack/update-gofmt.sh
Signed-off-by: Stephen Augustus <foo@auggie.dev>

Kubernetes-commit: 481cf6fbe753b9eb2a47ced179211206b0a99540
2021-08-12 17:13:11 -04:00
Chok Yip Lau 5d2f1d8a56 Added support for multiple --from-env flags
Kubernetes-commit: 9a13bae5108beb113dd0ca5605f4adeeac127915
2021-08-09 00:05:43 -04:00
fabiankramm 3d34311c79 kubectl proxy: append context host path to request path
Signed-off-by: fabiankramm <fab.kramm@googlemail.com>

Kubernetes-commit: b1a6f8cdf90c0a3861157fea24dcfa89c2aafcf9
2020-12-16 17:37:44 +01:00
Senthil Kumaran 5f6099143c Provide reference to impersonation options for kubectl auth can-i command.
Kubernetes-commit: ef181c14e128fd70c9d95193d676e1019601556c
2021-07-19 21:08:04 -07:00
Di Xu f106a734e3 cleanup description on deprecated include-uninitialized flag
Kubernetes-commit: ae7b9787ee7b46bb83b05d3769ed54374c0337a7
2021-07-26 11:14:55 +08:00
Eddie Zaneski 3e89fad72d Fix kubectl version unit test
Signed-off-by: Eddie Zaneski <eddiezane@gmail.com>

Kubernetes-commit: 93ef5acb35f40e6cb5aae3297858371349fed10a
2021-07-27 11:46:45 -06:00
huiwq1990 de9043d5d2 use already defined variable
Kubernetes-commit: 7aab5df381fb58814afdc0bba1b7352332d53edb
2021-03-13 15:49:44 +08:00
kabab 3e3ae2747f kubectl: Add labels to ingress describe
Kubernetes-commit: 2ad2bc6844318034dd3296a0b0d5a7ce97e51962
2021-07-24 22:56:36 +02:00
Manu Gupta 2e61cacc45 fix: 81134: display conflicted taint without a json representation.
1. string is formatted as unsafe json. Since this is created on the fly;
TaintKey and Effect are formatted as a 'key=effect' instead of '{key=effect}'
eliminating unsafe json representation.

2. Adds a fail test case for the case where a taint with same key and effect is added
and removed together.

Manual Testing

```
▶ ./_output/bin/kubectl taint nodes kind-control-plane key1=:NoSchedule key1=:NoSchedule-
error: can not both modify and remove the following taint(s) in the same command: key1=NoSchedule
```

Kubernetes-commit: 1a3eda9394b7ff473434506f2756cc9df6288cea
2021-07-29 23:26:07 +00:00
novahe 95ce5a060b remove stack trace log when sorting with a bad unsortable field
Kubernetes-commit: abf735daa83f1d931614292664c2df1c6735aebb
2021-07-03 21:34:41 +08:00
Chok Yip Lau 95dc04b3b3 Added support for multiple --from-env flags
Kubernetes-commit: 99bc2b077fd208885e76281ab8865f1e85f0abb8
2021-04-29 19:16:59 -04:00
Zhou Peng 7454a6489e [k8s.io/kubectl/pkg/drain/drain]: minor typo fixup
Signed-off-by: Zhou Peng <p@ctriple.cn>

Kubernetes-commit: 7e2d6301bf95893ea74116871d2c2f6392217105
2021-08-01 07:07:31 +08:00
Kebe 316e6d8845 Fix the code is leaking the defaulting between unrelated pod instances
Kubernetes-commit: 412962204ffdfcbe6407e66125b1b499d86d49ed
2021-07-09 09:57:05 +08:00
atiratree 1c26c91ee7 kubectl: show consistent unit format in quota describe
API returns unit format in a non deterministic manner; ie it
chooses a unit format according to a resource that gets counted first

Kubernetes-commit: 3f0b64ec9597488be6365f89cc82338bcb7a9feb
2021-05-20 15:36:04 +02:00
navist2020 2128ec58c8 remove Factory that not used
Kubernetes-commit: 0a83041d4d3698d36ade2a310184248c61eec64f
2021-05-17 16:56:12 +08:00
nobuhikosawai 1e8e38ace7 kubectl: update set command description to include cronjob resource (#102503)
* kubectl: update set command description to include cronjob resource

* kubectl: update set command description to include statefulset resource

* kubectl: update set env description to remove job from resources that can update container env

* kubectl set tests: add cronjob resource and remove job resource

* go fmt

Kubernetes-commit: 41c5bca3496b516ddf52618deb44a421b89a49f1
2021-07-09 00:50:54 +09:00
atiratree 9a63531dee update translations
Kubernetes-commit: 33e6ebc8f8df47864a77c867d78216adb70cd79d
2021-07-06 20:43:49 +02:00
Natasha Sarkar b29f07c93e Manually update kustomize attachment points.
Kubernetes-commit: a46b42a92b87c04f22c77df6d57149ad34b0ee6d
2021-07-01 17:10:28 -07:00
Andrea Hoffer 09ed00ef49 Minor adjustments to descriptions and example text
Kubernetes-commit: 6b736f348483bb6b20d4633319305960f4d9e4c1
2021-07-06 15:05:26 -04:00
caodonghui b709633a6c update url
Kubernetes-commit: a2c1b284da29ec07eaf6a0403d75cf9d881d45b8
2021-07-06 14:55:38 +08:00
yuzhiquan 160799c289 add deprecated message for igonre-errors flag, and fix unsafety http link
Kubernetes-commit: 0a38b2804d9b665627bc1bf899d711ba4adfa1b0
2021-06-08 10:49:23 +08:00
wawa0210 11174082b3 fix kubectl alpha debug node does not work on tainted nodes
Kubernetes-commit: 3ec63238c53ae3a7185db210e94494d850def3d4
2021-01-26 23:36:35 +08:00
Lee Verberne 7b8558da71 Add backwards compatibility for kubectl debug
The ephemeral containers API changed in 1.22. As a result, kubectl
debug (currently) cannot create ephemeral containers in clusters prior
to 1.22.

This change causes kubectl to retry the request using the old API when
it receives a specific error message from the server.

Kubernetes-commit: 06124c1d1c68ec4a30406bf585df2ec83231cb65
2021-06-28 18:19:50 +02:00
Chok Yip Lau 03baccf059 Added field-selector option for kubectl top pod
Kubernetes-commit: 1331c76aa3d7e5db730dc008b2ee94173ca51293
2021-05-19 15:54:39 -04:00
atiratree 9fd6965f54 update translations
- update template.pot
- reformat .po files
- regenerate .mo files
- regenarate and mark obsolete translations
- remove obsolete default/english translations

Kubernetes-commit: 194ed1408dd75ab2765d1b884128c3b7bf7c6823
2021-05-17 15:40:46 +02:00
atiratree 868d0f1252 fix update-translations.sh
Kubernetes-commit: 079d8aeb1e47f8907aa6d3760424047dccfc8279
2021-05-17 15:37:36 +02:00
Lee Verberne 119802affe Warn user for runtime support of debug targeting
Add a warning message to `kubectl debug` when using the `--target`
option as many runtimes don't support it yet.

Kubernetes-commit: 968185e1f7c4aee739d5abe6133a690c70e87d5e
2021-04-13 15:50:26 +02:00
Monis Khan 82734c256a csr: add expirationSeconds field to control cert lifetime
This change updates the CSR API to add a new, optional field called
expirationSeconds.  This field is a request to the signer for the
maximum duration the client wishes the cert to have.  The signer is
free to ignore this request based on its own internal policy.  The
signers built-in to KCM will honor this field if it is not set to a
value greater than --cluster-signing-duration.  The minimum allowed
value for this field is 600 seconds (ten minutes).

This change will help enforce safer durations for certificates in
the Kube ecosystem and will help related projects such as
cert-manager with their migration to the Kube CSR API.

Future enhancements may update the Kubelet to take advantage of this
field when it is configured in a way that can tolerate shorter
certificate lifespans with regular rotation.

Signed-off-by: Monis Khan <mok@vmware.com>

Kubernetes-commit: cd91e59f7c351fce47c064a5162c2cb79075159c
2021-06-25 22:08:10 -04:00
Nabarun Pal c4de100b6e hack: remove bindata generation logic for translations
also, remove generated bindata

Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>

Kubernetes-commit: 43c2e454a059da5cfce0430534b289dd21a0599e
2021-03-04 10:28:08 +05:30
Nabarun Pal e99a037812 kubectl: use embedded translations instead of generated bindata
Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>

Kubernetes-commit: eb75b34394964fbc325ca08a5d0b126c5ea16b6f
2021-03-04 10:26:41 +05:30
Nabarun Pal f52da0a0a3 kubectl: move translations to i18n package to kubectl staging directory
Go 1.16's embed directive doesn't allow embeding files from parent
directories. Hence, moving the translations data to inside the i18n package.

Logically speaking as well, kubectl related artifacts should be inside
the kubectl package.

Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>

Kubernetes-commit: 5ece28b77a284b24b674278378630373196789ac
2021-03-04 09:55:12 +05:30
Chris Henzie cb8bf2d275 Update helper methods to print and parse ReadWriteOncePod access mode
Kubernetes-commit: 5f98f6cfa47e2fcfad46822638b4fd167d8c41df
2021-03-10 20:51:43 -08:00
Chris Henzie 8bd9f6c9c6 Export contains access mode helper method
Will be used during validation of PVs and PVCs

Kubernetes-commit: 358d2e0bd1ffd475274ea08494bc8d39ef0e80cc
2021-06-14 19:31:57 -07:00
Sean Sullivan 42a8170920 kubectl command headers as default in beta
Kubernetes-commit: 4add8ed910654087683444ac7f8e441e8d32baa3
2021-06-26 20:53:49 -07:00