<commit_before>### Deploy on Amazon EC2

Before you start make sure:
- Your system's clock is synchronized.
- You have uploaded valid `SSH` keys to `EC2` ([doc](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html)).
- You have AWS credentials in `~/.aws/credentials` ([doc](https://github.com/aws/aws-sdk-go/wiki/configuring-sdk#shared-credentials-file)).
- You have permissions to manage `IAM`, `VPC` and `EC2` ([doc](http://docs.aws.amazon.com/IAM/latest/UserGuide/access_permissions.html)).

#### The EC2 provider

*Káto* can be deployed on *EC2* via the `katoctl ec2` provider. The `deploy` subcommand will recursively call other `katoctl` subcommands such as `ec2 setup` and `ec2 add` in order to orchestrate the deployment. Find below the output of `katoctl ec2 --help` for your reference:

```
usage: katoctl ec2 <command> [<args> ...]

This is the Káto EC2 provider.

Flags:
  -h, --help     Show context-sensitive help (also try --help-long and --help-man).
      --version  Show application version.

Subcommands:
  ec2 deploy
    Deploy Káto's infrastructure on Amazon EC2.

  ec2 setup
    Setup IAM, VPC and EC2 components.

  ec2 add
    Adds a new instance to an existing Káto cluster on EC2.

  ec2 run
    Starts a CoreOS instance on Amazon EC2.
```

#### Deploy

If you want to reuse existing *EBS* volumes you must target the `--region` and `--zone` where your volumes are stored. During the deployment a state file will be generated under `$HOME/.kato/<unique-cluster-id>.json`

A simple deploy example:
```bash
katoctl ec2 deploy \
  --cluster-id <unique-cluster-id> \
  --ns1-api-key <ns1-private-key> \
  --domain <managed-public-domain> \
  --region <ec2-region> \
  --key-pair <ec2-ssh-key-name> \
  1:m3.xlarge:kato:quorum,master,worker \
  1:m3.medium:border:border
```

A complex deploy example:
```bash
export KATO_EC2_DEPLOY_VPC_CIDR_BLOCK='10.136.0.0/16'
export KATO_EC2_DEPLOY_INTERNAL_SUBNET_CIDR='10.136.0.0/18'
export KATO_EC2_DEPLOY_EXTERNAL_SUBNET_CIDR='10.136.64.0/18'
export KATO_EC2_DEPLOY_FLANNEL_NETWORK='10.136.128.0/18'
export KATO_EC2_DEPLOY_FLANNEL_SUBNET_MIN='10.136.128.0'
export KATO_EC2_DEPLOY_FLANNEL_SUBNET_MAX='10.136.191.192'
export KATO_EC2_DEPLOY_FLANNEL_SUBNET_LEN='26'

katoctl ec2 deploy \
  --cluster-id <unique-cluster-id> \
  --ns1-api-key <ns1-private-key> \
  --sysdig-access-key <sysdig-access-key> \
  --datadog-api-key <datadog-api-key> \
  --ca-cert <path-to-crt-pem> \<commit_msg>Update docs/ec2.md<commit_after>### Deploy on Amazon EC2

Before you start make sure:
- Your system's clock is synchronized.
- You have uploaded valid `SSH` keys to `EC2` ([doc](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html)).
- You have AWS credentials in `~/.aws/credentials` ([doc](https://github.com/aws/aws-sdk-go/wiki/configuring-sdk#shared-credentials-file)).
- You have permissions to manage `IAM`, `VPC` and `EC2` ([doc](http://docs.aws.amazon.com/IAM/latest/UserGuide/access_permissions.html)).

#### The EC2 provider

*Káto* can be deployed on *EC2* via the `katoctl ec2` provider. The `deploy` subcommand will recursively call other `katoctl` subcommands such as `ec2 setup` and `ec2 add` in order to orchestrate the deployment. Find below the output of `katoctl ec2 --help` for your reference:

```
usage: katoctl ec2 <command> [<args> ...]

This is the Káto EC2 provider.

Flags:
  -h, --help     Show context-sensitive help (also try --help-long and --help-man).
      --version  Show application version.

Subcommands:
  ec2 deploy
    Deploy Káto's infrastructure on Amazon EC2.

  ec2 setup
    Setup IAM, VPC and EC2 components.

  ec2 add
    Adds a new instance to an existing Káto cluster on EC2.

  ec2 run
    Starts a CoreOS instance on Amazon EC2.
```

#### Deploy

If you want to reuse existing *EBS* volumes you must target the `--region` and `--zone` where your volumes are stored. During the deployment a state file will be generated under `$HOME/.kato/<unique-cluster-id>.json`

##### A simple deploy example:
```bash
katoctl ec2 deploy \
  --cluster-id <unique-cluster-id> \
  --ns1-api-key <ns1-private-key> \
  --domain <managed-public-domain> \
  --region <ec2-region> \
  --key-pair <ec2-ssh-key-name> \
  1:m3.xlarge:kato:quorum,master,worker \
  1:m3.medium:border:border
```

##### A complex deploy example:
```bash
export KATO_EC2_DEPLOY_VPC_CIDR_BLOCK='10.136.0.0/16'
export KATO_EC2_DEPLOY_INTERNAL_SUBNET_CIDR='10.136.0.0/18'
export KATO_EC2_DEPLOY_EXTERNAL_SUBNET_CIDR='10.136.64.0/18'
export KATO_EC2_DEPLOY_FLANNEL_NETWORK='10.136.128.0/18'
export KATO_EC2_DEPLOY_FLANNEL_SUBNET_MIN='10.136.128.0'
export KATO_EC2_DEPLOY_FLANNEL_SUBNET_MAX='10.136.191.192'
export KATO_EC2_DEPLOY_FLANNEL_SUBNET_LEN='26'

katoctl ec2 deploy \
  --cluster-id <unique-cluster-id> \
  --ns1-api-key <ns1-private-key> \
  --sysdig-access-key <sysdig-access-key> \
  --datadog-api-key <datadog-api-key> \
  --ca-cert <path-to-crt-pem> \
{'fraction_non_alphanumeric': 0.13653807311654212, 'fraction_numerical': 0.04100181781458291, 'mean_word_length': 3.854901960784314, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 12, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1005972', 'n_tokens_mistral': 1998, 'n_tokens_neox': 1847, 'n_words': 475}