<a id="co-install-plugin"></a>

# Confluent kubectl plugin

The Confluent for Kubernetes (CFK) bundle contains a Confluent kubectl plugin for interacting with
Confluent for Kubernetes. The plugin supports Linux, Windows, and macOS.
For more information, see [Confluent plugin](co-configure-overview.md#co-plugin).

## Install Confluent kubectl plugin

### Step 1: Download and unpack the CFK bundle

If you deployed CFK using the
[Helm repository](co-deploy-operator.md#co-deploy-from-helm-repo), download and unpack the
CFK bundle as described in [Step 1 of the download bundle procedure](co-deploy-operator.md#co-download-bundle).

If you deployed CFK using the [download bundle](co-deploy-operator.md#co-download-bundle),
skip this step.

### Step 2: Remove any older plugin (upgrades only)

If you are upgrading from an older version of the Confluent plugin, delete the
old plugin from the directory where you installed it.

### Step 3: Check your machine architecture

Check the `arm64` or `amd64` architecture of the machine:

```bash
arch
```

Expected: Your machine’s architecture, for example, `arm64` or `amd64`.

### Step 4: Unpack the plugin

From the directory where you deployed CFK, unpack the `kubectl` plugin that
matches your client environment (Linux, Windows, or Mac OS/Darwin) into your
local executables directory. On Mac OS and Linux, the directory is
`/usr/local/bin/`.
This allows the standard `kubectl` command-line tool to find the plugin. Use
the architecture you retrieved in the previous step (`amd64` or `arm64`):

```bash
tar -xvf kubectl-plugin/kubectl-confluent-<environment>-<architecture>.tar.gz \
   -C <local directory for the plugin>
```

For example, on Mac OS with the `arm64` architecture type:

```bash
tar -xvf kubectl-plugin/kubectl-confluent-darwin-arm64.tar.gz \
   -C /usr/local/bin/
```

Expected: `x kubectl-confluent`

#### NOTE
If `/usr/local/bin/` is not writable by your user, prefix the command
with `sudo`.

Verify the plugin is available through `kubectl`:

```bash
kubectl confluent --help
```

Expected: The help output for the `confluent` plugin, listing the available
commands. For example, `cluster`, `kraft`, and `connector`.

<a id="co-install-plugin-using-krew"></a>

## Install Confluent plugin using Krew

Krew is the plugin manager for `kubectl`. To install the Confluent kubectl plugin
using Krew, complete the following steps:

### Step 1: Install Krew

Install Krew as described in the [Krew User Guide](https://krew.sigs.k8s.io/docs/user-guide/).

### Step 2: Download and unpack the CFK bundle

If you deployed CFK using the
[Helm repository](co-deploy-operator.md#co-deploy-from-helm-repo), download and unpack the
CFK bundle as described in [Step 1 of the download bundle procedure](co-deploy-operator.md#co-download-bundle).

If you deployed CFK using the [download bundle](co-deploy-operator.md#co-download-bundle),
skip this step.

### Step 3: Go to the plugin directory

Go to the `kubectl-plugin` sub-directory under the directory where you
unpacked the CFK bundle.

### Step 4: Remove any older plugin (upgrades only)

If you are upgrading from an older version of the Confluent plugin, delete the
old plugin:

```bash
kubectl krew uninstall confluent
```

### Step 5: Install the plugin

Check the `arm64` or `amd64` architecture of the machine:

```bash
arch
```

Expected: Your machine’s architecture, for example, `arm64` or `amd64`.

Using the architecture you retrieved (`amd64` or `arm64`), install the
plugin based on the OS and its architecture type:

```bash
kubectl krew install \
  --manifest=confluent-platform.yaml \
  --archive=kubectl-confluent-<environment>-<architecture>.tar.gz
```

For example, to install the plugin on Mac OS with the `arm64` architecture
type:

```bash
kubectl krew install \
  --manifest=confluent-platform.yaml \
  --archive=kubectl-confluent-darwin-arm64.tar.gz
```

Expected: `Installed plugin: confluent`

## Related content

* For an overview of Confluent kubectl plugin commands, see [Confluent plugin](co-configure-overview.md#co-plugin).
* To deploy CFK before installing the plugin, see [Deploy Confluent for Kubernetes](co-deploy-operator.md#co-deploy-operator).
