<commit_before># Administrators

## Kubernetes Deployment

YAML files have been provided for deployment in the `yaml` directory.

They are split by whether they pertain to the APEL Server or to the persistant MySQL database. These are then further divided into files for the service itself and the service's replication controller, which is responsible for keeping the service containers running.

There are, therefore, four YMAL files.

* `yaml/accounting-mysql-rc.yaml`       - This configures the replication controller for the MySQL service
* `yaml/accounting-mysql-service.yaml`  - This is the MySQL service
* `yaml/accounting-server-rc.yaml`      - This configures the replication controller for the APEL Server service
* `yaml/accounting-server-service.yaml` - This is the APEL server service

## Interacting with Running Docker Containers on Kubernetes

To do this, you must first install kubectl (See https://coreos.com/kubernetes/docs/latest/configure-kubectl.html for a guide how to do this)

1. List the "pods", you are looking for something of the form "accounting-server-rc-XXXXX"

   `kubectl -s kubernetes_ip --user="kubectl" --token="auth_token" --insecure-skip-tls-verify=true get pods --namespace=kube-system`

   Note, you will need to replace `kubernetes_ip` and `auth_token` with there proper values.

2. Open a terminal running on the Indigo Datacloud APEL Accounting Server

   `kubectl -s kubernetes_ip --user="kubectl" --token="auth_token" --insecure-skip-tls-verify=true exec -it accounting-server-rc-XXXXX --namespace=kube-system bash`

   Note, you will need to replace `accounting-server-rc-XXXXX` with its true value.

You should now have terminal access to the Accounting Server.

## Services Running in the Accounting Server Container

* `httpd`: The Apache webserver hosting the REST interface
* `cron` : Necessary to periodically run the Summariser
* `apeldbloader-cloud` : Loads received messages into the MySQL image

## Important Configuration files

* `/etc/init.d/apeldbloader-cloud` : Registers the cloud loader as a service

* `/etc/apel/cloudloader.cfg` : Configures the cloud loader

* `/etc/apel/cloudsummariser.cfg` : Configures the cloud summariser

* `/etc/httpd/conf.d/apel_rest_api.conf` : Enforces HTTPS

* `/etc/httpd/conf.d/ssl.conf` : Handles the HTTPS

## Important Scripts

* `/etc/cron.d/cloudsummariser` : Cron job that runs `run_cloud_summariser.sh`

* `/usr/bin/run_cloud_summariser.sh` : Stops the loader servic, summarises the database and restarts the loader<commit_msg>Add documentation to authorize new WP5 services<commit_after># Administrators

## Kubernetes Deployment

YAML files have been provided for deployment in the `yaml` directory.

They are split by whether they pertain to the APEL Server or to the persistant MySQL database. These are then further divided into files for the service itself and the service's replication controller, which is responsible for keeping the service containers running.

There are, therefore, four YMAL files.

* `yaml/accounting-mysql-rc.yaml`       - This configures the replication controller for the MySQL service
* `yaml/accounting-mysql-service.yaml`  - This is the MySQL service
* `yaml/accounting-server-rc.yaml`      - This configures the replication controller for the APEL Server service
* `yaml/accounting-server-service.yaml` - This is the APEL server service

## Interacting with Running Docker Containers on Kubernetes

To do this, you must first install kubectl (See https://coreos.com/kubernetes/docs/latest/configure-kubectl.html for a guide how to do this)

1. List the "pods", you are looking for something of the form "accounting-server-rc-XXXXX"

   `kubectl -s kubernetes_ip --user="kubectl" --token="<PASSWORD>" --insecure-skip-tls-verify=true get pods --namespace=kube-system`

   Note, you will need to replace `kubernetes_ip` and `auth_token` with there proper values.

2. Open a terminal running on the Indigo Datacloud APEL Accounting Server

   `kubectl -s kubernetes_ip --user="kubectl" --token="<PASSWORD>" --insecure-skip-tls-verify=true exec -it accounting-server-rc-XXXXX --namespace=kube-system bash`

   Note, you will need to replace `accounting-server-rc-XXXXX` with its true value.

You should now have terminal access to the Accounting Server.

## Services Running in the Accounting Server Container

* `httpd`: The Apache webserver hosting the REST interface
* `cron` : Necessary to periodically run the Summariser
* `apeldbloader-cloud` : Loads received messages into the MySQL image

## Important Configuration files

* `/etc/init.d/apeldbloader-cloud` : Registers the cloud loader as a service

* `/etc/apel/cloudloader.cfg` : Configures the cloud loader

* `/etc/apel/cloudsummariser.cfg` : Configures the cloud summariser

* `/etc/httpd/conf.d/apel_rest_api.conf` : Enforces HTTPS

* `/etc/httpd/conf.d/ssl.conf` : Handles the HTTPS

## Important Scripts

* `/etc/cron.d/cloudsummariser` : Cron job that runs `run_cloud_summariser.sh`

* `/usr/bin/run_cloud_summariser.sh` : Stops the loader servic, summarises the database and restarts the loader

## Authorize new WP5 components to view Summaries

* In `yaml/accounting-server-rc.yaml`, add the IAM registered ID corresponding to the service in the env variable `ALLOWED_FOR_GET`. It should be of form below, quotes included. Python needs to be able to interpret this variable as a list of strings, the outer quotes prevent kubernetes interpreting it as something meaningful in YAML. The accounting-server-rc on kubernetes will have to be restarted for that to take effect. This can be done by deleting the accounting-server-service pod. 

`"['XXXXXXXXXXXX','XXXXXXXXXXXXXXXX']".`
{'fraction_non_alphanumeric': 0.08460861917326297, 'fraction_numerical': 0.0010554089709762533, 'mean_word_length': 4.456813819577735, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '47941', 'n_tokens_mistral': 1706, 'n_tokens_neox': 1647, 'n_words': 642}