# CLI Prep Node

## Command: prep-node

This command prepares a node to be ready to be added to a cluster. The command does the following:

* Checks resources and access (Ports, CPU, RAM, HDD, SUDO, Clock Skew)
* Securely connects to a list of nodes specified
* Installs all the required prerequisites on the nodes
* Installs Platform9 host agent and other required software on the nodes
* Authorizes the nodes to be associated with the PMK management plane

This command is useful if you wish to prepare your nodes with the required prerequisites using the CLI, and then use the PMK UI to finish cluster creation.

When you create a cluster using PMK UI, the UI recommends that you use the CLI to run this command on all the nodes you wish to add to the cluster, then come back to the UI to finish cluster creation.

## Syntax Example

{% tabs %}
{% tab title="Bash" %}

```bash
pf9ctl check-node [flags]
```

{% endtab %}
{% endtabs %}

## All Available Commands and Flags

{% tabs %}
{% tab title="Bash" %}

```bash
$ pf9ctl check-node --help
Check if a node satisfies prerequisites to be ready to be added to a Kubernetes cluster. Read more
	at https://platform9.com/blog/support/managed-container-cloud-requirements-checklist/

Usage:
  pf9ctl check-node [flags]

Flags:
  -h, --help              help for check-node
  -i, --ip  strings       IP of host to be prepared
  -p, --password string   ssh password for the nodes
  -c, --skip-checks        Will skip optional checks if true
  -s, --ssh-key string    ssh key file for connecting to the nodes
  -u, --user string       ssh username for the nodes

Global Flags:
      --verbose   print verbose logs
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Bash" %}

```bash
pf9ctl prep-node -h
Prepare a node to be ready to be added to a Kubernetes cluster. Read more
	at http://pf9.io/cli_clprep.

Usage:
  pf9ctl prep-node [flags]

Flags:
  -h, --help                   help for prep-node
  -i, --ip strings             IP address of host to be prepared
      --mfa string             MFA token
  -p, --password string        ssh password for the nodes (use 'single quotes' to pass password)
  -r, --remove-existing-pkgs   Will remove previous installation if found (default false)
  -c, --skip-checks            Will skip optional checks if true
      --skip-connected         If the node is already connected to the PMK control plane, prep-node will be skipped
  -o, --skip-os-checks         Will continue prep-node even if os version checks fail
  -s, --ssh-key string         ssh key file for connecting to the nodes
  -e, --sudo-pass string       sudo password for user on remote host
  -u, --user string            ssh username for the nodes

Global Flags:
      --log-dir string   path to save logs
      --no-prompt        disable all user prompts
      --verbose          print verbose logs
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Using pf9ctl with unsupported operating systems**

pf9ctl prep node has a --skip-os-checks flag that can be used to bypass the operating system check.
{% endhint %}

## Command Examples

### Prep Local Node

{% tabs %}
{% tab title="Bash" %}

```bash
pf9ctl prep-node
2021-02-22T14:14:53.6344Z	INFO	Loading configuration details
2021-02-22T14:14:54.4674Z	INFO	Disabling swap
2021-02-22T14:14:54.4732Z	INFO	Removing swap in fstab
2021-02-22T14:14:54.5108Z	INFO	Downloading installer (this might take a few minutes...)
2021-02-22T14:15:16.4673Z	INFO	Platform9 packages installed successfully
2021-02-22T14:15:16.4674Z	INFO	Initialising the host
2021-02-22T14:16:16.9997Z	INFO	Host successfully attached to the Platform9 control-plane
```

{% endtab %}
{% endtabs %}

### Prep Remote Node

{% tabs %}
{% tab title="Bash" %}

```bash
pf9ctl prep-node -i 10.128.242.250 -u ubuntu
2021-02-22T09:17:51.0003Z	INFO	Loading configuration details
Enter Password:

2021-02-22T09:17:55.5474Z	INFO	Disabling swap
2021-02-22T09:17:55.5775Z	INFO	Removing swap in fstab
2021-02-22T09:17:55.6354Z	INFO	Downloading installer (this might take a few minutes...)
2021-02-22T09:18:17.639Z	INFO	Platform9 packages installed successfully
2021-02-22T09:18:17.6391Z	INFO	Initialising the host
2021-02-22T09:19:18.1018Z	INFO	Host successfully attached to the Platform9 control-plane
```

{% endtab %}
{% endtabs %}

## Flag Examples and Information

| Flag                  | Type   | Required/Optional | Description                                                                                                                                                                                                                                                                                                                                               |
| --------------------- | ------ | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `-u` , `--user`       | String | Optional          | Username for nodes. Required if you are creating a multi-node cluster, so the CLI can authenticate with each node. Refer to [SSH Setup for Remote Nodes](https://github.com/platform9/pcd-docs-gitbook/blob/main/kubernetes/pmk-cli-remote-ssh/README.md) under PMK CLI Overview for more information.                                                    |
| `-p` , `--password`   | String | Optional          | Password for node. You need to specify either the password or provide the password during execution if you're running the command to connect to remote nodes. Refer to [SSH Setup for Remote Nodes](https://github.com/platform9/pcd-docs-gitbook/blob/main/kubernetes/pmk-cli-remote-ssh/README.md) section under PMK CLI Overview for more information. |
| `-c`, `--skip-checks` | String | Optional          | If set to true, skip-checks will bypass prompts for optional checks during prep-node. This flag is used for cases where a node is added using a script and is automated, allowing for prompts to be bypassed.                                                                                                                                             |
| `-s` , `--ssh-key`    | String | Optional          | SSH private key for remote nodes. Refer to [SSH Setup for Remote Nodes](https://github.com/platform9/pcd-docs-gitbook/blob/main/kubernetes/pmk-cli-remote-ssh/README.md) section under PMK CLI Overview for more information.                                                                                                                             |
| `-i` , `--ip`         | String | Required          | IPs of the nodes you wish to execute prep-node. You need to specify at least one IP address for the prep-node command to work. Repeat this option multiple times to specify multiple nodes to be prepared. If you wish to also prepare the current node, specify it as ‘localhost’ or specify the current node’s IP address                               |
| `--help`              |        |                   | Show this message and exit.                                                                                                                                                                                                                                                                                                                               |
