Commit Graph

19 Commits

Author SHA1 Message Date
Mahendra Bishnoi
059849703b fix grammar 2021-11-13 23:23:04 +05:30
Patrick Ohly
00e4a599f6 command lines: always show flags with hyphens
All Kubernetes commands should show flags with hyphens in their help text even
when the flag originally was defined with underscore. Converting a command to
this style is not breaking its command line API because the old-style parameter
with underscore is accepted as alias.

The easiest solution to achieve this is to set normalization shortly before
running the command in the new central cli.Run or the few places where that
function isn't used yet.

There may be some texts which depends on normalization at flag definition time,
like the --logging-format usage warning. Those get generated assuming that
hyphens will be used.
2021-09-30 13:46:49 +02:00
Patrick Ohly
21d1bcd6b8 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.
2021-09-30 13:46:49 +02:00
Nick Turner
a5b47f7dd0 Allow custom client names to be used for cloud controllers
* This allows a controller to use cloud provider managed RBAC
  when --use-service-account-credentials is set.
* Create ControllerInitFuncConstructor to pass to init funcs to avoid
  future function signature growth.
* Add comments for context around legacy naming of node controllers.
* Add example for setting client names from cloud controller manager.
2021-08-24 00:51:24 +00:00
chenyw1990
e2020f62ac add normalize function to global FlagSet 2021-03-18 09:23:52 +08:00
cici37
408258c6d5 Update to use cliflag.NamedFlagSets 2021-03-02 13:23:44 -08:00
cici37
9b3d42f20a Address comments. 2021-03-01 16:36:56 -08:00
cici37
716122ccec Update NodeIPAM wrapper 2021-03-01 13:51:59 -08:00
cici37
69fee369c9 Update extension mechanism and related sample. 2021-03-01 10:22:22 -08:00
cici37
b669f04648 Modify integration test to fill CCM test gap 2021-03-01 10:22:16 -08:00
cici37
27aaee2b40 Move initialize cloud provider with client builder reference inside controller start func 2021-03-01 10:22:10 -08:00
cici37
498fa39af2 Separate example func and add README.md 2021-03-01 10:22:09 -08:00
cici37
52bab024af Separate func 2021-03-01 10:21:57 -08:00
cici37
7b0a6db097 Add demonstration of wiring nodeIPAMController config object 2021-03-01 10:21:52 -08:00
cici37
4729fa49e1 Remove cloud provider name as input parameter. 2021-03-01 10:21:49 -08:00
cici37
2b3d2303a5 Fix flag passing in CCM. 2021-03-01 10:21:46 -08:00
changshuchao
854b74d9e2 Optimize some irregular variable names
Signed-off-by: changshuchao <chang.shuchao1@zte.com.cn>
2021-01-06 02:54:18 +08:00
Nicole Han
b80abf6d34 update cloud-controller-manager samples to read --cloud-config flag 2020-12-15 10:56:22 -08:00
cici37
443f829703 Adding sample files to demonstrate how cloud provider leverage CCM. 2020-11-11 19:50:06 -08:00