Skip to content

Commit 1d7b651

Browse files
authored
Initial changes to developer guide section of docs (#690)
1 parent 7f6bb59 commit 1d7b651

12 files changed

+158
-165
lines changed

site/content/docs/developer-guide/custom-indexes.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@ weight: 500
55
---
66

77
Krew comes with a plugin index named `default` that points to the
8-
[`krew-index` repository](https://github.com/kubernetes-sigs/krew) which allows
8+
[`krew-index` repository](https://github.com/kubernetes-sigs/krew), which allows
99
centralized discovery through community curation.
1010

11-
However, you can host your own plugin indexes (and possibly remove/replace the
12-
`default` index). It’s not recommended to host your own plugin index, unless you
13-
have a use case such as:
11+
However, you can host your own plugin indexes (and possibly remove or replace the
12+
`default` index). Hosting your own plugin index is not recommended, unless you
13+
have a use case that specifically calls for it, such as:
1414

15-
- your plugin is not accepted to `krew-index`
16-
- you want full control over the distribution lifecycle of your own plugin
17-
- you want to run a _private_ plugin index in your organization (e.g. to be
18-
installed on developer machines)
15+
- Your plugin is not accepted to `krew-index`
16+
- You want full control over the distribution lifecycle of your own plugin
17+
- You want to run a _private_ plugin index in your organization (e.g.
18+
installations on developer machines)
1919

2020
Hosting your own custom index is simple:
2121

2222
- Custom index repositories must be `git` repositories.
23-
- Your clients should have read access to the repository (if the repository
23+
- Your clients should have read access to the repository. If the repository
2424
is not public, users can still authenticate to it with SSH keys or other
2525
[gitremote-helpers](https://git-scm.com/docs/gitremote-helpers) installed
26-
on the client machine).
26+
on the client machine.
2727
- The repository must contain a `plugins/` directory at the root, with at least
2828
one plugin manifest in it. Plugin manifests should be directly in this
29-
directory.
30-
- Ensure plugin manifests are valid YAML and passes Krew manifest validation
29+
directory (not in a subdirectory).
30+
- Ensure plugin manifests are valid YAML and pass Krew manifest validation
3131
(optionally, you can use the
3232
[validate-krew-manifest](https://github.com/kubernetes-sigs/krew/tree/master/cmd/validate-krew-manifest)
3333
tool for static analysis).

site/content/docs/developer-guide/develop/best-practices.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ weight: 300
66

77
{{< toc >}}
88

9-
This guide lists practices to use while developing `kubectl` plugins. Before
10-
submitting your plugin to Krew, please review these
9+
This guide describes practices to use when developing `kubectl` plugins. Before
10+
submitting your plugin to Krew, please review these practices.
1111

12-
While Krew project does not enforce any strict guidelines about how a plugin
13-
works, using some of these practices can help your plugin work for more users
12+
While the Krew project team does not strictly enforce guidelines about how a plugin
13+
works, abiding by these practices can help your plugin work for more users
1414
and behave more predictably.
1515

1616
## Choosing a language
@@ -20,17 +20,17 @@ Most `kubectl` plugins are written in Go or as bash scripts.
2020
If you are planning to write a plugin with Go, check out:
2121

2222
- [client-go]: a Go SDK to work with Kubernetes API and kubeconfig files
23-
- [cli-runtime]: Provides packages to share code with `kubectl` for printing output or [sharing command-line options][cli-opts]
24-
- [sample-cli-plugin]: An example plugin implementation in Go
23+
- [cli-runtime]: a set of packages to share code with `kubectl` for printing output or [sharing command-line options][cli-opts]
24+
- [sample-cli-plugin]: an example plugin implementation in Go
2525

2626
## Consistency with kubectl {#kubectl-options}
2727

28-
Krew does not try to impose any rules in terms of the shape of your plugin.
28+
Krew does not impose any rules in terms of the shape of your plugin.
2929

30-
However, if you use the command-line options with `kubectl`, you can make your
30+
However, if you support the common command-line options with `kubectl`, you can make your
3131
users’ lives easier.
3232

33-
For example, it is recommended you use the following command line flags used by
33+
For example, it is recommended that you support the following command-line flags used by
3434
`kubectl`:
3535

3636
- `-h`/`--help`
@@ -44,8 +44,8 @@ support the global command-line flags listed in `kubectl options` (e.g.
4444
## Import authentication plugins (Go) {#auth-plugins}
4545

4646
By default, plugins that use [client-go]
47-
cannot authenticate to Kubernetes clusters on many cloud providers. To overcome
48-
this, add the following import to somewhere in your binary:
47+
cannot authenticate to Kubernetes clusters on many cloud providers. To address
48+
this, include the following import in your plugin:
4949

5050
```go
5151
import _ "k8s.io/client-go/plugin/pkg/client/auth"
@@ -56,22 +56,21 @@ import _ "k8s.io/client-go/plugin/pkg/client/auth"
5656
[cli-opts]: https://godoc.org/k8s.io/cli-runtime/pkg/genericclioptions
5757
[sample-cli-plugin]: https://github.com/kubernetes/sample-cli-plugin
5858

59-
## Revise usage/help messages with `kubectl` prefix {#help-messages}
59+
## Revise usage and help messages with the `kubectl` prefix {#help-messages}
6060

61-
Users discover how to use your plugin by calling it without any arguments (which
62-
might trigger a help message), or `-h`/`--help` options.
61+
Many users will discover how to use your plugin by calling it without any arguments (which
62+
might trigger a help message), or with `-h`/`--help` arguments.
6363

64-
Therefore, change your usage strings to show `kubectl ` prefix before the plugin
64+
Therefore, it is helpful to change your usage strings to show the `kubectl ` prefix before the plugin
6565
name. For example
6666

6767
```text
6868
Usage:
6969
kubectl popeye [flags]
7070
```
7171

72-
To determine whether an executable is running as a plugin or not, you can look
73-
at argv[0], which would have the `kubectl-` prefix. To determine whether your
74-
program is running as a kubectl plugin or not:
72+
To determine if your executable is running as a `kubectl` plugin, you can look
73+
at `argv[0]`, which will include the `kubectl-` prefix
7574

7675
- **Go:**
7776

site/content/docs/developer-guide/develop/naming-guide.md

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,81 +4,79 @@ slug: naming-guide
44
weight: 200
55
---
66

7-
This document explains the best practices and recommendations for naming your
8-
kubectl plugins.
7+
This document describes guidelines for naming your kubectl plugins.
98

109
These guidelines are used for reviewing the plugins [submitted to Krew]({{<ref
1110
"../release/submitting-to-krew.md">}}).
1211

13-
##### _Punctuation_
12+
##### _Use lowercase and hyphens_
1413

1514
Plugin names must be all lowercase and separate words with hyphens.
1615
**Don't** use camelCase, PascalCase, or snake_case; use
1716
[kebab-case](http://wiki.c2.com/?KebabCase).
1817

19-
- **DON'T:** `kubectl OpenSvc`
20-
- **DO:** `kubectl open-svc`
18+
- **NO:** `kubectl OpenSvc`
19+
- **YES:** `kubectl open-svc`
2120

2221
##### _Be specific_
2322

24-
Plugin names should not be verbs/nouns that are generic, already overloaded, or
25-
possibly can be used for broader purposes by another plugin.
23+
Plugin names should not be verbs or nouns that are generic, already overloaded, or
24+
likely to be used for broader purposes by another plugin.
2625

27-
- **DON'T:** `kubectl login`: Tries to put dibs on the word.
28-
- **DO:** `kubectl gke-login`.
26+
- **NO:** `kubectl login` (Too broad)
27+
- **YES:** `kubectl gke-login`
2928

3029
Also:
3130

32-
- **DON'T:** `kubectl ui`: Should be used only for Kubernetes Dashboard.
33-
- **DO:** `kubectl gke-ui`.
31+
- **NO:** `kubectl ui` (Should be used only for Kubernetes Dashboard)
32+
- **YES:** `kubectl gke-ui`
3433

3534
##### _Be unique_
3635

37-
Try to find a unique name for your plugin that differentiates you from other
38-
possible plugins doing the same job.
36+
Find a unique name for your plugin that differentiates it from other
37+
plugins that perform a similar function.
3938

40-
- **DON'T:** `kubectl view-logs`: Unclear how it is different than the builtin
41-
"logs" command, or many other tools for viewing logs.
42-
- **DO:** `kubectl tailer`: Unique name, points to the underlying
39+
- **NO:** `kubectl view-logs` (Unclear how it is different from the builtin
40+
"logs" command, or many other tools for viewing logs)
41+
- **YES:** `kubectl tailer` (Unique name, points to the underlying)
4342
tool name.
4443

45-
##### _Use Verbs/Resource Types_
44+
##### _Use Verbs and Resource Types_
4645

4746
If the name does not make it clear (a) what verb the plugin is doing on a
4847
resource, or (b) what kind of resource it's doing the action on, consider
4948
clarifying unless it is obvious.
5049

51-
- **DON'T:** `kubectl service`: Unclear what this plugin is doing with
50+
- **NO:** `kubectl service` (Unclear what this plugin is doing with)
5251
service.
53-
- **DON'T:** `kubectl open`: Unclear what it is opening.
54-
- **DO:** `kubectl open-svc`: It is clear the plugin will open a service.
52+
- **NO:** `kubectl open` (Unclear what the plugin is opening)
53+
- **YES:** `kubectl open-svc` (It is clear the plugin will open a service)
5554

5655
##### _Prefix Vendor Identifiers_
5756

58-
Use the vendor-specific strings as prefix, separated with a dash. This makes it
57+
Use vendor-specific strings as prefix, separated with a dash. This makes it
5958
easier to search/group plugins that are about a specific vendor.
6059

61-
- **DON'T:** `kubectl ui-gke`: Makes it harder to search or locate in a
62-
plugin list.
63-
- **DO:** `kubectl gke-ui`: Will show up next to other gke-* plugins.
60+
- **NO:** `kubectl ui-gke` (Makes it harder to search or locate in a
61+
plugin list)
62+
- **YES:** `kubectl gke-ui` (Will show up next to other gke-* plugins)
6463

6564
##### _Avoid repeating kube[rnetes]_
6665

67-
Plugin names should not repeat kube- or kubernetes- prefixes to avoid
66+
Plugin names should not include "kube-" or "kubernetes-" prefixes to avoid
6867
stuttering.
6968

70-
- **DON'T:** `kubectl kube-node-admin`: "kubectl " already has "kube" in
71-
it.
72-
- **DO:** `kubectl node-admin`.
69+
- **NO:** `kubectl kube-node-admin` ("kubectl " already has "kube" in it)
70+
- **YES:** `kubectl node-admin`
7371

74-
##### _Avoid Resource Acronyms_
72+
##### _Avoid Resource Acronyms and Abbreviations_
7573

7674
Using kubectl acronyms for API resources (e.g. svc, ing, deploy, cm) reduces
77-
readability and discoverability of a plugin more than it is saving keystrokes.
75+
the readability and discoverability of a plugin, which is more important
76+
than the few keystrokes saved.
7877

79-
- **DON'T:** `kubectl new-ing`: Hard to spot and the plugin is for
80-
Ingress.
81-
- **DO:** `kubectl debug-ingress`.
78+
- **NO:** `kubectl new-ing` (Unclear that the plugin is for Ingress)
79+
- **YES:** `kubectl debug-ingress`
8280

83-
If you have suggestions to this guide, open an issue or send a pull request, as
84-
this is an open topic of debate with a lot of gray areas.
81+
Note: If you have suggestions for improving this guide, open an issue or send a
82+
pull request, as this is a topic under active development.

site/content/docs/developer-guide/develop/plugin-development.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,26 @@ on this topic.
1010

1111
To summarize the documentation, the procedure is to:
1212

13-
- Write an executable binary, named `kubectl-foo` to have a plugin that can be
13+
- Create an executable binary, named `kubectl-foo` (for example) to have a plugin that can be
1414
invoked as `kubectl foo`.
15-
- Place the executable to a directory listed in user’s `PATH` environment
16-
variable. (Plugins distributed with Krew don't need to worry about this).
17-
- You can't overwrite a builtin `kubectl` command with a plugin.
15+
- Place the executable in a directory that is listed in the user’s `PATH` environment
16+
variable. (You don't have to do this for plugins distributed with Krew).
17+
- You can't overwrite a built-in `kubectl` command with a plugin.
1818

19-
> **If you are writing a plugin in Go:** Consider using the [cli-runtime] project
19+
> **Note:** If you are writing a plugin in Go, consider using the [cli-runtime] project
2020
> which is designed to provide the same command-line arguments, kubeconfig
2121
> parser, Kubernetes API REST client, and printing logic. Look at
2222
> [sample-cli-plugin] for an example of a kubectl plugin.
2323
>
24-
> Also, there's an unofficial [GitHub template
24+
> Also, see the unofficial [GitHub template
2525
> repo](https://github.com/replicatedhq/krew-plugin-template) for a Krew plugin
26-
> in Go that implements some best practices mentioned in this guide, and helps
27-
> you automate releases using GoReleaser to create release when a tag is pushed.
26+
> in Go that implements some best practices covered later in this guide, and helps
27+
> you automate releases using GoReleaser to create a release when a tag is pushed.
2828
2929
[cli-runtime]: https://github.com/kubernetes/cli-runtime/
3030
[sample-cli-plugin]: https://github.com/kubernetes/sample-cli-plugin
3131

32-
While developing a plugin, make sure you check out:
32+
When developing your own plugins, make sure you check out:
3333

3434
- [Plugin naming guide]({{<ref "naming-guide.md">}}) to choose a good name
3535
for your plugin

site/content/docs/developer-guide/distributing-with-krew.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,37 @@ title: Distributing plugins on Krew
33
weight: 110
44
---
55

6-
## Why Krew? {#why}
6+
## Why use Krew for distribution? {#why}
77

8-
To install a kubectl plugin to a user’s machine, all you need to do is to place
9-
an executable in user’s `PATH` prefixed with `kubectl-` name. At this point, you
10-
might consider some other options such as:
8+
On the surface, installing a kubectl plugin seems simple enough -- all you need to do is to place
9+
an executable in the user’s `PATH` prefixed with `kubectl-` -- that you may be
10+
considering some other alternatives to Krew, such as:
1111

12-
- have the user manually download the plugin binary and set up somewhere in
13-
`PATH`
14-
- distribute the plugin executable using an OS package manager, like Homebrew
15-
(macOS), apt/yum (Linux) or Chocolatey (Windows)
16-
- distribute the plugin executable using a language package manager (e.g. npm,
12+
- Having the user manually download the plugin executable and move it to some directory in
13+
the `PATH`
14+
- Distributing the plugin executable using an OS package manager, like Homebrew
15+
(macOS), apt/yum (Linux), or Chocolatey (Windows)
16+
- Distributing the plugin executable using a language package manager (e.g. npm or
1717
go get)
1818

19-
While these approaches might work some shortcomings to think about are:
19+
While these approaches are not necessarily unworkable, potential drawbacks to consider include:
2020

21-
- how to ship updates to users (in case of manual installation)
22-
- need to package a plugin for multiple platforms (macOS, Linux, Windows)
23-
- your users need to download the language package manager (go, npm)
24-
- what if you change the implementation language (e.g. move from npm to another package manager)
21+
- How to get updates to users (in the case of manual installation)
22+
- How to package a plugin for multiple platforms (macOS, Linux, and Windows)
23+
- How to ensure your users have the appropriate language package manager (go, npm)
24+
- How to handle a change to the implementation language (e.g. a move from npm to another package manager)
2525

2626
Krew solves these problems cleanly for all kubectl plugins, since it's designed
27-
**specifically to address these shortcomings**: With Krew, you write a plugin
28-
manifest once and have a plugin that can be installed on all platforms
27+
**specifically to address these shortcomings**. With Krew, after you write a plugin
28+
manifest once your plugin can be installed on all platforms
2929
without having to deal with their package managers.
3030

3131
## Steps to get started
3232

3333
Once you [develop]({{< ref "develop/plugin-development.md" >}}) a `kubectl`
34-
plugin, here are the steps you need to follow to distribute your plugin on Krew:
34+
plugin, follow these steps to distribute your plugin on Krew:
3535

3636
1. Package your plugin into an archive file (`.tar.gz` or `.zip`).
3737
1. Make the archive file publicly available (e.g. as GitHub release files).
38-
1. Write [Krew plugin manifest]({{< ref "plugin-manifest.md" >}}) file.
38+
1. Write a [Krew plugin manifest]({{< ref "plugin-manifest.md" >}}) file.
3939
1. [Submit your plugin to krew-index]({{< ref "release/../release/submitting-to-krew.md" >}}).

site/content/docs/developer-guide/example-plugin-manifests.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ weight: 200
55
---
66

77
Learning how to [write plugin manifests]({{< ref "plugin-manifest.md" >}})
8-
can be a time-consuming tasks.
8+
can be a time-consuming task.
99

10-
Krew encourages you to copy and adapt plugin manifests of [existing
11-
plugins][list]. Since these are already reviewed and approved, your plugin can
12-
be accepted more quickly.
10+
The Krew team encourages you to copy and adapt plugin manifests of [existing
11+
plugins][list]. Since these are already reviewed and approved, your plugin is
12+
likely to be accepted more quickly.
1313

1414
* **Go:**
1515
- [tree](https://github.com/kubernetes-sigs/krew-index/blob/master/plugins/tree.yaml):

site/content/docs/developer-guide/installing-locally.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,34 @@ weight: 300
55
---
66

77
After you have written your [plugin manifest]({{< ref "plugin-manifest.md" >}})
8-
archived your plugin into a `.zip` or `.tar.gz` file, you can now test whether
8+
and archived your plugin into a `.zip` or `.tar.gz` file, you can verify that
99
your plugin installs correctly with Krew by running:
1010

1111
```sh
1212
{{<prompt>}}kubectl krew install --manifest=foo.yaml --archive=foo.tar.gz
1313
```
1414

15-
- `--manifest` flag specifies a custom manifest rather than picking it up from
15+
- The `--manifest` flag specifies a custom manifest rather than using
1616
the default [krew index][index]
1717
- `--archive` overrides the download `uri:` specified in the plugin manifest and
1818
uses a local `.zip` or `.tar.gz` file instead.
1919

2020
If the installation **fails**, run the command again with `-v=4` flag to see the
21-
verbose logs and inspect what went wrong.
21+
verbose logs and examine what went wrong.
2222

23-
If your installation **succeeds**, you should now be able to run your plugin.
23+
If the installation **succeeds**, you should now be able to run your plugin.
2424

25-
If you made your archive file available to download on the Internet, run the
25+
If you made your archive file available for download on the Internet, run the
2626
same command without the `--archive` option and actually test downloading the
2727
file from the specified `uri` and validate its `sha256` sum is correct.
2828

29-
After you have tested your plugin, uninstall it with `kubectl krew uninstall foo`.
29+
After you have tested your plugin installation, uninstall it with `kubectl krew uninstall foo`.
3030

3131
### Testing other platforms
3232

33-
If you need other `platforms` definitions that don't match your current machine,
34-
you can use `KREW_OS` and/or `KREW_ARCH` environment variables to override what
35-
OS/architecture Krew thinks it's running on.
33+
If you need to test other `platforms` definitions that don't match your current machine,
34+
you can use `KREW_OS` and `KREW_ARCH` environment variables to override the
35+
OS and architecture that Krew thinks it's running on.
3636

3737
For example, if you're on a Linux machine, you can test Windows installation
3838
with:

0 commit comments

Comments
 (0)