Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

site: custom index docs #618

Merged
merged 15 commits into from
Jul 8, 2020
54 changes: 54 additions & 0 deletions site/content/docs/developer-guide/custom-indexes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: Hosting Custom Plugin Indexes
slug: custom-indexes
weight: 500
corneliusweig marked this conversation as resolved.
Show resolved Hide resolved
draft: true
---

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

However, you can host your own plugin indexes (and possibly remove/replace the
`default` index). It’s not recommended to host your own plugin index, unless you
have a use case such as:

- your plugin is not accepted to `krew-index`
- you want full control over the distribution lifecycle of your own plugin
- you want to run a _private_ plugin index in your organization (e.g. to be
installed on developer machines)

Hosting your own custom index is simple:

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

Example plugin repository layout:

```text
.
└── plugins/
├── plugin-a.yaml
├── plugin-b.yaml
└── plugin-c.yaml
```

## Duplicate plugin names

Your custom index can contain plugins that have the same name as the ones in
`krew-index`.

Users of your index will need to install your plugin using the
explicit `<INDEX>/<PLUGIN>` syntax. See the [user guide][ug].

[ug]: {{< relref "../user-guide/using-custom-indexes.md">}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has considerable overlap with using-custom-indexes, and duplicates some information. Do we really need it?

(also the heading does not fit to the second paragraph)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with whatever. I think it might be good to have it repeated here as a consideration for people writing plugins for custom indexes and to let them know that people will need to install their plugin differently.

2 changes: 1 addition & 1 deletion site/content/docs/developer-guide/plugin-stats.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Plugin usage analytics
slug: plugin-stats
weight: 500
weight: 600
---

Krew does not track user behavior. However, for plugins that distribute their
Expand Down
84 changes: 84 additions & 0 deletions site/content/docs/user-guide/using-custom-indexes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
title: Using Custom Plugin Indexes
slug: custom-indexes
weight: 800
draft: true
---

Plugin indexes contain plugin manifests, which are documents that describe
installation procedure for a plugin. For discovery purposes, Krew comes with a
`default` plugin index, plugins hosted in the [`krew-index`
repository](https://github.com/kubernetes-sigs/krew-index).

However, some plugin authors may choose to host their own indexes that contain
their curation of kubectl plugins. These are called "custom plugin indexes".

## Adding a custom index
corneliusweig marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the title isn’t good.
It would be better to explain in this section “The default index” and

  • how it can be removed
  • or pointed to another repo
  • and how plugins without an explicit index name mean “default”

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the adding/removing/listing indexes sections are important to showcase the new index command right? I agree though that a section explaining the default index would be good, I can move the advanced usage section I had and change it to reflect the points you listed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think this should work well. You could also explain how plugin names are resolved. Iow, that a default/ prefix is added implicitly, if no index name is given. Then you could also explain how plugin name clashes are handled and remove the Duplicate plugin names section in the other page.


A custom plugin index can be added with the `kubectl krew index add` command:

```sh
{{<prompt>}}kubectl krew index add foo https://github.com/foo/custom-index.git
```

The URI you use can be any [git remote](https://git-scm.com/docs/git-remote)
(e.g., `[email protected]:foo/custom-index.git`).

## Removing a custom index

You can remove a custom plugin index by passing the name it was added with to
the remove command:

```sh
{{<prompt>}}kubectl krew index remove foo
```

## Listing indexes

To see what indexes you have added you can run the list command
chriskim06 marked this conversation as resolved.
Show resolved Hide resolved

```sh
{{<prompt>}}kubectl krew index list
{{<output>}}INDEX URL
default https://github.com/kubernetes-sigs/krew-index.git
foo https://github.com/foo/custom-index.git{{</output>}}
```

## Installing plugins from custom indexes

Commands for managing plugins (e.g. `install`, `upgrade`) work with custom
indexes as well.

By default, Krew prefixes plugins with a `default/` prefix. However, if you have
a plugin installed from a custom index, you need to specify it in format
corneliusweig marked this conversation as resolved.
Show resolved Hide resolved
`INDEX_NAME/PLUGIN_NAME`.

For example, to install a plugin named `bar` from custom index `foo`:

```sh
{{<prompt>}}kubectl krew install foo/bar
```

Similarly:

- To list all plugins (including the ones from custom indexes), run:

```sh
{{<prompt>}}kubectl krew search
```

- To remove a plugin, you don't need to specify its index:

```sh
{{<prompt>}}kubectl krew uninstall PLUGIN_NAME
```

- To get information about a plugin from a custom index:

```sh
{{<prompt>}}kubectl krew info INDEX_NAME/PLUGIN_NAME
corneliusweig marked this conversation as resolved.
Show resolved Hide resolved
```


> **Caveat:** If two indexes offer a plugin with the same name, only one can
> be installed at any time.