<commit_before># Deploy to a Cloud Infrastructure

We highly recommend using the new [CF Deployment](https://github.com/cloudfoundry/cf-deployment)
project as the basis for your deployment.

CF Deployment on its own does not include CF Networking, but the instructions
below will show you how to add it in.

## Using `cf-deployment`

This deployment option uses the new tooling:
- [bbl](https://github.com/cloudfoundry/bosh-bootloader), the bosh bootloader
- the new Golang [bosh-cli](https://github.com/cloudfoundry/bosh-cli)
- [cf-deployment](https://github.com/cloudfoundry/cf-deployment)

### Step 1: `bbl up` your BOSH and load balancers
Follow the instructions provided with [the `bbl` tool](https://github.com/cloudfoundry/bosh-bootloader)
to create a BOSH director and to create load balancers for CF.

The CF load balancer should use a certificate with a wildcard common name for your
Cloud Foundry.

After `bbl` is complete, it will create a `bbl-state.json` file.  Keep that in a secure, private directory
on your filesystem.

```bash
cd ~/my-deployment-credentials
ls
# bbl-state.json
```

Set some environment variables that will be used by subsequent commands:

```bash
export BOSH_USER=$(bbl director-username)
export BOSH_PASSWORD=$(bbl director-password)
export BOSH_ENVIRONMENT=$(bbl director-address)
export BOSH_CA_CERT=/tmp/$env-ca-cert
bbl director-ca-cert > $BOSH_CA_CERT
chmod 600 $BOSH_CA_CERT
export BOSH_DEPLOYMENT=cf
```

### Step 2: Seed your `vars-store`
If you don't have an existing deployment, create a new file which configures the
`system_domain` for the deployment.
```yaml
# vars-store.yml
system_domain: mysystem.example.com
```

The `system_domain` should match the common name of the cert you installed on your
`bbl` `cf` load-balancers.  For example if your cert was for `*.mycloudfoundry.mydomain`
then your `system_domain` should be `mycloudfoundry.mydomain`.

If you are upgrading an existing `cf-deployment`, use your existing `vars-store.yml`

### Step 3: Identify your "ops files"
Read the [instructions for CF Deployment Ops Files](https://github.com/cloudfoundry/cf-deployment#ops-files)
and identify the minimal set of ops files appropriate for your deployment.

For example, if you're deploying to AWS, you'll need (as of the time of this writing)
  - `$CF_DEPLOYMENT_REPO/operations/aws.yml`

In addition, **to use CF Networking, you'll need to include these two files**:

  - `$CF_NETWORKING_RELEASE_REPO/manifest-generation/opsfiles/cf-networking.yml`

  - `$CF_NETWORKING_RELEASE_REPO/manifest-generation/opsfiles/silk.yml`


### Step 4: BOSH deploy
Assemble and run a `bosh deploy` command that uses the ops files and `vars-store.yml`:

For example, on GCP you might do:
```bash
bosh deploy \
  $CF_DEPLOYMENT_REPO/cf-deployment.yml \
  -o $CF_NETWORKING_RELEASE_REPO/manifest-generation/opsfiles/cf-networking.yml \
  -o $CF_NETWORKING_RELEASE_REPO/manifest-generation/opsfiles/silk.yml \
  --vars-store=vars-store.yml
```

For AWS, you might do:
```bash
bosh deploy \
  $CF_DEPLOYMENT_REPO/cf-deployment.yml \
  -o $CF_DEPLOYMENT_REPO/operations/aws.yml \
  -o $CF_NETWORKING_RELEASE_REPO/manifest-generation/opsfiles/cf-networking.yml \
  -o $CF_NETWORKING_RELEASE_REPO/manifest-generation/opsfiles/silk.yml \
  --vars-store=vars-store.yml
```

Note that this command will add credentials (and other things) to your `vars-store.yml`.
Keep it in a private directory.

We keep ours next to the `bbl-state.json` file, checked into a private git repo.

### Step 5: Kick the tires

Get your credentials
```bash
export CF_API_ENDPONT=$(bosh int --path=/system_domain vars-store.yml)
export CF_ADMIN_USER=admin
export CF_ADMIN_PASSWORD=$(bosh int --path=/uaa_scim_users_admin_password vars-store.yml)
```

Get the [CF CLI](https://github.com/cloudfoundry/cli) if you don't already have it.

Log in to CF:
```bash
cf api $CF_API_ENDPOINT # if your cert was self-signed, you'll need to add --skip-ssl-validation
cf auth $CF_ADMIN_USER $CF_ADMIN_PASSWORD 
# or use 'cf login' for an interactive login
```

Then try out our [Cats and Dogs example](../src/example-apps/cats-and-dogs) on your new deployment.


---


## DEPRECATED: Using `cf-release` with `diego-release` tooling

This method is not recommended for new deployments.

This option requires the old Ruby bosh-cli, to be installed and aliased as `bosh`.

This deployment option assumes you already have a BOSH director on AWS where you have already successfully deployed Diego + Cloud Foundry,
by using the instructions and tooling in [the diego-release repo](https://github.com/cloudfoundry/diego-release/tree/develop/examples/aws).


1. Upload a recent stemcell (kernel 4.4 or higher) to the bosh director

2. Generate credentials
<commit_msg>docs: use api subdomain for cf api command<commit_after># Deploy to a Cloud Infrastructure

We highly recommend using the new [CF Deployment](https://github.com/cloudfoundry/cf-deployment)
project as the basis for your deployment.

CF Deployment on its own does not include CF Networking, but the instructions
below will show you how to add it in.

## Using `cf-deployment`

This deployment option uses the new tooling:
- [bbl](https://github.com/cloudfoundry/bosh-bootloader), the bosh bootloader
- the new Golang [bosh-cli](https://github.com/cloudfoundry/bosh-cli)
- [cf-deployment](https://github.com/cloudfoundry/cf-deployment)

### Step 1: `bbl up` your BOSH and load balancers
Follow the instructions provided with [the `bbl` tool](https://github.com/cloudfoundry/bosh-bootloader)
to create a BOSH director and to create load balancers for CF.

The CF load balancer should use a certificate with a wildcard common name for your
Cloud Foundry.

After `bbl` is complete, it will create a `bbl-state.json` file.  Keep that in a secure, private directory
on your filesystem.

```bash
cd ~/my-deployment-credentials
ls
# bbl-state.json
```

Set some environment variables that will be used by subsequent commands:

```bash
export BOSH_USER=$(bbl director-username)
export BOSH_PASSWORD=$(bbl director-password)
export BOSH_ENVIRONMENT=$(bbl director-address)
export BOSH_CA_CERT=/tmp/$env-ca-cert
bbl director-ca-cert > $BOSH_CA_CERT
chmod 600 $BOSH_CA_CERT
export BOSH_DEPLOYMENT=cf
```

### Step 2: Seed your `vars-store`
If you don't have an existing deployment, create a new file which configures the
`system_domain` for the deployment.
```yaml
# vars-store.yml
system_domain: mysystem.example.com
```

The `system_domain` should match the common name of the cert you installed on your
`bbl` `cf` load-balancers.  For example if your cert was for `*.mycloudfoundry.mydomain`
then your `system_domain` should be `mycloudfoundry.mydomain`.

If you are upgrading an existing `cf-deployment`, use your existing `vars-store.yml`

### Step 3: Identify your "ops files"
Read the [instructions for CF Deployment Ops Files](https://github.com/cloudfoundry/cf-deployment#ops-files)
and identify the minimal set of ops files appropriate for your deployment.

For example, if you're deploying to AWS, you'll need (as of the time of this writing)
  - `$CF_DEPLOYMENT_REPO/operations/aws.yml`

In addition, **to use CF Networking, you'll need to include these two files**:

  - `$CF_NETWORKING_RELEASE_REPO/manifest-generation/opsfiles/cf-networking.yml`

  - `$CF_NETWORKING_RELEASE_REPO/manifest-generation/opsfiles/silk.yml`


### Step 4: BOSH deploy
Assemble and run a `bosh deploy` command that uses the ops files and `vars-store.yml`:

For example, on GCP you might do:
```bash
bosh deploy \
  $CF_DEPLOYMENT_REPO/cf-deployment.yml \
  -o $CF_NETWORKING_RELEASE_REPO/manifest-generation/opsfiles/cf-networking.yml \
  -o $CF_NETWORKING_RELEASE_REPO/manifest-generation/opsfiles/silk.yml \
  --vars-store=vars-store.yml
```

For AWS, you might do:
```bash
bosh deploy \
  $CF_DEPLOYMENT_REPO/cf-deployment.yml \
  -o $CF_DEPLOYMENT_REPO/operations/aws.yml \
  -o $CF_NETWORKING_RELEASE_REPO/manifest-generation/opsfiles/cf-networking.yml \
  -o $CF_NETWORKING_RELEASE_REPO/manifest-generation/opsfiles/silk.yml \
  --vars-store=vars-store.yml
```

Note that this command will add credentials (and other things) to your `vars-store.yml`.
Keep it in a private directory.

We keep ours next to the `bbl-state.json` file, checked into a private git repo.

### Step 5: Kick the tires

Get your credentials
```bash
export CF_API_ENDPONT=$(bosh int --path=/system_domain vars-store.yml)
export CF_ADMIN_USER=admin
export CF_ADMIN_PASSWORD=$(bosh int --path=/uaa_scim_users_admin_password vars-store.yml)
```

Get the [CF CLI](https://github.com/cloudfoundry/cli) if you don't already have it.

Log in to CF:
```bash
cf api api.$CF_API_ENDPOINT # if your cert was self-signed, you'll need to add --skip-ssl-validation
cf auth $CF_ADMIN_USER $CF_ADMIN_PASSWORD # or use 'cf login' for interactive login
```

Then try out our [Cats and Dogs example](../src/example-apps/cats-and-dogs) on your new deployment.


---


## DEPRECATED: Using `cf-release` with `diego-release` tooling

This method is not recommended for new deployments.

This option requires the old Ruby bosh-cli, to be installed and aliased as `bosh`.

This deployment option assumes you already have a BOSH director on AWS where you have already successfully deployed Diego + Cloud Foundry,
by using the instructions and tooling in [the diego-release repo](https://github.com/cloudfoundry/diego-release/tree/develop/examples/aws).


1. Upload a recent stemcell (kernel 4.4 or higher) to the bosh director

2. Generate credentials

{'fraction_non_alphanumeric': 0.10003145643284052, 'fraction_numerical': 0.0025165146272412707, 'mean_word_length': 4.667260843731432, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 16, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '4763083', 'n_tokens_mistral': 3236, 'n_tokens_neox': 3039, 'n_words': 1048}