<commit_before># Deploying Monocular in Kubernetes

## Quickstart

Monocular is packaged as a Helm Chart that can be found in the `/deployment/monocular` directory.

> **Prerequisites**
>
> The chart is configured and tested to be used alongside an NGINX Ingress controller. Please be sure that you have a running instance in your cluster before proceeding. More information  [here](https://github.com/kubernetes/ingress/tree/master/controllers/nginx).

Install the chart:

```
helm install deployment/monocular
```

Visit [Using Helm](https://github.com/kubernetes/helm/blob/master/docs/using_helm.md) to learn more about how to use Helm.

Once deployed, your application should be available at `https://[nginx-ingress-controller-service-ip]`.

### Chart details

The chart contains 3 tiers and one ingress resource.

#### Components

  * UI: AngularJS web frontend.
  * API: Golang based backend API.
  * Prerederer: PhantomJS prerenderer for SEO purposes. More information [here](https://github.com/prerender/prerender).

#### Ingress resource

The chart includes an ingress resource that is configured to route the backend API via `[your-domain]/api` so it can be easily consumed by the UI avoiding any CORS issue or configuration.

You can configure many different settings from hosts, ingress-class to tls options using the `values.yaml` file.

# CI/CD scripts

In the `/deployment` directory you can find a set of convenience scripts helpful in CI/CD setups.

## Deploy for the first time

You can deploy a new release of the operations service
using the `deploy_install.sh` script.

### Arguments

#### Required

* `API_TAG`: Image tag to be used on the API tier, it will be appended to API_IMAGE
* `UI_TAG`: Image tag to be used on the API tier. It will be appended to UI_IMAGE

#### Optional

* `API_NAME` (default: `gcr.io/helm-ui/monocular-api`)
* `UI_NAME` (default: `gcr.io/helm-ui/monocular-ui`)
* `RELEASE_NAME` (default: `Helm's provided random name`) Helm release
  name.
* `VALUES_OVERRIDE` (default: `api.image.repository=${API_IMAGE},api.image.tag=${API_TAG},ui.image.repository=${UI_IMAGE},ui.image.tag=${UI_TAG}`) Helm values to be overridden (`helm install --set $VALUES_OVERRIDE`)
* `HELM_OPTS` (default: no value) Extra options to be passed to the helm
  command i.e --dry-run --debug

### Examples

```
# Deploy the release
API_TAG=1 UI_TAG=1 ./deploy_install.sh

# Deploy setting the release name
API_TAG=1 UI_TAG=1 RELEASE_NAME='my_release' ./deploy_install.sh

# Deploy with helm debug and dry-run
API_TAG=1 UI_TAG=1 HELM_OPTS="--debug --dry-run" ./deploy_install.sh

# Deploy overridding default values
API_TAG=1 UI_TAG=1\
 VALUES_OVERRIDE="backend.image.repository=my-image,backend.service.type=LoadBalancer"\
 ./deploy_install.sh
```

## Upgrade an existing release

You can upgrade an existing release of the operations service using the `deploy_upgrade.sh` script.

### Arguments

#### Required

* `API_TAG`: Image tag to be used on the API tier, it will be appended to API_IMAGE
* `UI_TAG`: Image tag to be used on the API tier. It will be appended to UI_IMAGE
* `RELEASE_NAME`: Helm release name.

#### Optional

* `API_NAME` (default: `gcr.io/helm-ui/monocular-api`)
* `UI_NAME` (default: `gcr.io/helm-ui/monocular-ui`)
* `SKIP_UPGRADE_CONFIRMATION` (default: false) Skip the confirmation
  prompt if an upgrade needs to be performed. Useful for unattended
  name.
* `VALUES_OVERRIDE` (default: `api.image.repository=${API_IMAGE},api.image.tag=${API_TAG},ui.image.repository=${UI_IMAGE},ui.image.tag=${UI_TAG}`) Helm values to be overridden (`helm install --set $VALUES_OVERRIDE`)
* `HELM_OPTS` (default: no value) Extra options to be passed to the helm
  command i.e --dry-run --debug

### Examples

```
# Upgrade the release in attended mode
API_TAG=1 UI_TAG=1 RELEASE_NAME='my_release' ./deploy_upgrade.sh

# Upgrade in unattended mode
API_TAG=1 UI_TAG=1 RELEASE_NAME='my-release' SKIP_UPGRADE_CONFIRMATION=true ./deploy_upgrade.sh
```
<commit_msg>NGINX ingress controller chart instructions (#182)<commit_after># Deploying Monocular in Kubernetes

## Quickstart

Monocular is packaged as a Helm Chart that can be found in the `/deployment/monocular` directory.

> **Prerequisites**
>
> The chart is configured and tested to be used alongside an NGINX Ingress controller. Please be sure that you have a running instance in your cluster before proceeding. More information [here](https://github.com/kubernetes/charts/tree/master/stable/nginx-ingress).

Install the Monocular chart:

```
helm install deployment/monocular
```

Visit [Using Helm](https://github.com/kubernetes/helm/blob/master/docs/using_helm.md) to learn more about how to use Helm.

Once deployed, your application should be available at `https://[nginx-ingress-controller-service-ip]`.

### Chart details

The chart contains 3 tiers and one ingress resource.

#### Components

  * UI: AngularJS web frontend.
  * API: Golang based backend API.
  * Prerederer: PhantomJS prerenderer for SEO purposes. More information [here](https://github.com/prerender/prerender).

#### Ingress resource

The chart includes an ingress resource that is configured to route the backend API via `[your-domain]/api` so it can be easily consumed by the UI avoiding any CORS issue or configuration.

You can configure many different settings from hosts, ingress-class to tls options using the `values.yaml` file.

# CI/CD scripts

In the `/deployment` directory you can find a set of convenience scripts helpful in CI/CD setups.

## Deploy for the first time

You can deploy a new release of the operations service
using the `deploy_install.sh` script.

### Arguments

#### Required

* `API_TAG`: Image tag to be used on the API tier, it will be appended to API_IMAGE
* `UI_TAG`: Image tag to be used on the API tier. It will be appended to UI_IMAGE

#### Optional

* `API_NAME` (default: `gcr.io/helm-ui/monocular-api`)
* `UI_NAME` (default: `gcr.io/helm-ui/monocular-ui`)
* `RELEASE_NAME` (default: `Helm's provided random name`) Helm release
  name.
* `VALUES_OVERRIDE` (default: `api.image.repository=${API_IMAGE},api.image.tag=${API_TAG},ui.image.repository=${UI_IMAGE},ui.image.tag=${UI_TAG}`) Helm values to be overridden (`helm install --set $VALUES_OVERRIDE`)
* `HELM_OPTS` (default: no value) Extra options to be passed to the helm
  command i.e --dry-run --debug

### Examples

```
# Deploy the release
API_TAG=1 UI_TAG=1 ./deploy_install.sh

# Deploy setting the release name
API_TAG=1 UI_TAG=1 RELEASE_NAME='my_release' ./deploy_install.sh

# Deploy with helm debug and dry-run
API_TAG=1 UI_TAG=1 HELM_OPTS="--debug --dry-run" ./deploy_install.sh

# Deploy overridding default values
API_TAG=1 UI_TAG=1\
 VALUES_OVERRIDE="backend.image.repository=my-image,backend.service.type=LoadBalancer"\
 ./deploy_install.sh
```

## Upgrade an existing release

You can upgrade an existing release of the operations service using the `deploy_upgrade.sh` script.

### Arguments

#### Required

* `API_TAG`: Image tag to be used on the API tier, it will be appended to API_IMAGE
* `UI_TAG`: Image tag to be used on the API tier. It will be appended to UI_IMAGE
* `RELEASE_NAME`: Helm release name.

#### Optional

* `API_NAME` (default: `gcr.io/helm-ui/monocular-api`)
* `UI_NAME` (default: `gcr.io/helm-ui/monocular-ui`)
* `SKIP_UPGRADE_CONFIRMATION` (default: false) Skip the confirmation
  prompt if an upgrade needs to be performed. Useful for unattended
  name.
* `VALUES_OVERRIDE` (default: `api.image.repository=${API_IMAGE},api.image.tag=${API_TAG},ui.image.repository=${UI_IMAGE},ui.image.tag=${UI_TAG}`) Helm values to be overridden (`helm install --set $VALUES_OVERRIDE`)
* `HELM_OPTS` (default: no value) Extra options to be passed to the helm
  command i.e --dry-run --debug

### Examples

```
# Upgrade the release in attended mode
API_TAG=1 UI_TAG=1 RELEASE_NAME='my_release' ./deploy_upgrade.sh

# Upgrade in unattended mode
API_TAG=1 UI_TAG=1 RELEASE_NAME='my-release' SKIP_UPGRADE_CONFIRMATION=true ./deploy_upgrade.sh
```

{'fraction_non_alphanumeric': 0.1121355594318465, 'fraction_numerical': 0.003613256915026165, 'mean_word_length': 4.787310742609949, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 8, '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': '4508891', 'n_tokens_mistral': 2664, 'n_tokens_neox': 2505, 'n_words': 880}